Commit graph

112 commits

Author SHA1 Message Date
Dongbo Wang 2f57bf848b
Change Target from a CodeProperty to be an AliasProperty that points to FileSystemInfo.LinkTarget (#16165) 2021-10-05 10:29:16 -07:00
xtqqczze 03b07a0062
Enable IDE0044: MakeFieldReadonly (#13880)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0044
2021-07-07 09:33:19 +05:00
dinhngtu ea19ceac4a
Wait for SSH exit when closing remote connection (#14635) 2021-06-03 13:19:11 -07:00
Steve Lee fc1d5ef096
Default to MTA on Windows platforms where STA is not supported (#15106) 2021-04-22 08:38:13 -07:00
xtqqczze bb78d4b5c0
Fix IDE0090: Simplify new expression part 6 (#14338)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0090
2020-12-09 08:52:00 +05:00
xtqqczze 52ecb6d18e
Run dotnet-format to improve formatting of source code (#13503) 2020-11-04 11:13:56 -08:00
xtqqczze 8f37cced70
Cleanup: remove duplicate words in comments (#13539) 2020-08-31 11:39:00 -07:00
Dongbo Wang 4b9b0788ed
Revert "Use is null syntax (#13277)" (#13322)
This reverts commit 6c03776d74.
2020-07-30 16:06:38 -07:00
xtqqczze 6c03776d74
Use is null syntax (#13277)
Replace `== null` with `is null`
2020-07-30 18:04:03 +05:00
Dongbo Wang cfb1952fd2
Use temp personal path at Runspace startup when env 'HOME' not defined (#13239) 2020-07-23 10:24:42 -07:00
xtqqczze e93381e73e
Add readonly modifier to internal static members (#11777)
# PR Summary

* Add readonly modifier to internal static members.

## PR Context

## PR Checklist

- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
    - Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
    - If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
    - [x] None
    - **OR**
    - [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
        - [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
    - [x] Not Applicable
    - **OR**
    - [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
        - [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
    - [x] N/A or can only be tested interactively
    - **OR**
    - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- **Tooling**
    - [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    - **OR**
    - [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
        - Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host).
        - Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        - Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions).
        - Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
2020-05-31 05:10:22 +00:00
Steve Lee b7cb335f03
Update copyright notice to latest guidance (#12190) 2020-03-24 11:08:37 -07:00
Ilya 2e8ced4856
Use new string.Split() overloads (#11867) 2020-03-13 17:46:05 +05:00
xtqqczze a34d0f3e80
Reformat code according to EditorConfig rules (#11681) 2020-01-31 14:56:22 -08:00
James Truher [MSFT] bcc5acb0bd Fix for issue on raspbian for setting date of file changes in UnixStat Experimental Feature (#11313) 2019-12-12 12:25:16 -08:00
James Truher [MSFT] fe712f8de2 Experimental Feature: Provide Unix stat information in filesystem output (#11042) 2019-11-15 17:26:11 -08:00
Dongbo Wang ec105da3f1 Some code cleanup work (#10698)
* Move Utils.GetUserConfigurationDirectory to Platform.ConfigDirectory
* Unify the use of Platform.ConfigDirectory and Platform.CacheDirectory
2019-10-07 14:15:01 +05:00
James Truher [MSFT] fe2cc6aca8 Additional Telemetry - Implementation of RFC0036 (#10336) 2019-08-15 16:13:53 -07:00
Ilya 78d64664ce Use IPGlobalProperties on all platforms for getting host name (#9530) 2019-05-08 16:25:02 -07:00
Ilya 8bd16d13cb Remove IsSymLink() P/Invoke on Unix (#9534) 2019-05-07 13:31:54 -07:00
Ilya 2be3db8ab8
Cleanup unused pinvokes on unix (#9531)
* Remove TemporaryDirectory()
* Remove GetUserName()
* Use Environment.UserName on Unix
* Remove old comment
* Use Environment.UserName on Windows too
2019-05-07 10:22:01 +05:00
Ilya bd6fdae735
Cleanup: sort usings (#9490) 2019-04-30 10:25:11 +05:00
Ilya d80154430d Style: Change first char to upper in summary comments (#8597) 2019-01-09 13:07:40 -08:00
Ilya 233b54ed65 Style: Add a space after "//" in comments and remove unneeded comments after "}" (#8576) 2019-01-05 17:51:20 -08:00
Ilya 1be3f4cc0e Style: Add the ending period to the XML document texts (#8577) 2019-01-05 15:40:24 -08:00
Ilya dfd2f69369
Style: Change 'String.' to 'string.' (#8568) 2018-12-31 20:44:16 +05:00
Ilya 56569b9315
Style: Replace String.IsNullOrEmpty with string.IsNullOrEmpty (#8557) 2018-12-31 15:10:15 +05:00
Steve Lee 4af3068566 Code cleanup: Add space after closing brace where needed (#8530)
* Update TestService

* Update WebListener

* Update Controllers

* Update ExpTest

* Update MyApp

* Update Logic

* Update Logic

* Update MyApp

* Update Microsoft.Management.Infrastructure.CimCmdlets

* Update Microsoft.PowerShell.Commands.Diagnostics

* Update Microsoft.PowerShell.ScheduledJob

* Update Microsoft.WSMan.Management

* Update Microsoft.WSMan.Runtime

* Update ResGen

* Update TypeCatalogGen

* Update commands

* Update Eventing

* Update Reader

* Update utility

* Update ShowCommand

* Update trace

* Update WebCmdlet

* Update Common

* Update CoreCLR

* Update common

* Update format-object

* Update format-wide

* Update out-file

* Update out-printer

* Update out-string

* Update OutGridView

* Update LocalAccounts

* Update Commands

* Update security

* Update CoreCLR

* Update DscSupport

* Update engine

* Update help

* Update logging

* Update namespaces

* Update security

* Update utils

* Update config

* Update perfCounters

* Update tracing

* Update cmdletization

* Update other

* Update cim

* Update xml

* Update CoreCLR

* Update common

* Update DefaultFormatters

* Update out-console

* Update out-textInterface

* Update DisplayDatabase

* Update Utilities

* Update COM

* Update ComInterop

* Update CommandCompletion

* Update debugger

* Update ExperimentalFeature

* Update hostifaces

* Update interpreter

* Update lang

* Update Modules

* Update parser

* Update runtime

* Update client

* Update commands

* Update common

* Update fanin

* Update server

* Update WireDataFormat

* Update Binding

* Update Operations

* Update interface

* Update cmdletization

* Update cim

* Update management

* Update WindowsTaskbarJumpList

* Update msh
2018-12-24 11:20:06 +05:00
Meir Blachman b7b386d209 Remove comments after closing brackets (#8344) 2018-12-08 21:53:30 +05:00
Dongbo Wang c1e171622a
More changes and cleanup to reduce the startup time (#8396)
Major changes are:
- Rename `s_wasSystemPolicyDebugPolicy` to `s_allowDebugOverridePolicy` to make it less confusing. Also slightly refactor `HelperSecurity.psm1` and `ConstrainedLanguageDebugger.Tests.ps1` to remove unneeded code. There is no functional change in this commit.
- Remove the unneeded static property `IsInbox`, as PowerShell Core won't be shipped in-box with Windows in the foreseeable feature. Even if we do in future, we won't be needing it because Windows PowerShell will probably be gone by that time.
- Update 'BindRunspace' to avoid getting all commands and unneeded method calls.
- Avoid creating a `IsSafeValueVisitor` every time when `IsScriptBlockInFactASafeHashtable` runs.
2018-12-05 18:29:50 -08:00
Ilya b8fb55340d
Cleanup FileSystemProvider from runtime checks (#7655)
Replace runtime checks with compile time checks.
Remove unneeded methods.
2018-09-09 00:40:06 +05:00
Ilya 4fc784e840 Bulk update code base to put 'null' on the right-hand-side of a comparison expression (#6949) 2018-06-25 14:37:09 -07:00
Ilya 81244fb907 Avoid calling native APIs to check for existence of FileSystem items (#6929)
- Use File.GetAttributes() instead of p/invokes to check for existence of FileSystem items. The method throws access exceptions which we use for better error messages.
- Remove the word 'Native' from method names.
2018-06-14 11:35:44 -07:00
Ilya e177fcaef6 CodeFactor code style cleanup: replace literal empty strings with 'string.Empty' (#6950) 2018-06-12 12:30:10 -07:00
Ilya c297eac50e
Cleanup NonWindowsGetDomainName() (#6948)
Add an optional extended description…
2018-05-31 10:18:33 +05:00
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00
Steve Lee 4bc52d2358 Use consistent '(c)' for copyright symbol (#5210)
- Remove the year about copyright
- Fix casing of `All rights reserved`
- Replace Unicode characters representing single quote with a single quote
2017-10-26 14:12:19 -07:00
Steve Lee 7c9b188c13 Rename $IsOSX to $IsMacOS (#4757) 2017-09-07 10:34:40 -07:00
Dongbo Wang 384a9fe3fc Clean up ShellExecute code to use the .NET Core implementation (#4523)
* Clean up ShellExecuteHelper and enable ShellExecute in NativeCommandProcessor

* Minor fix

* [Feature] Fix NativeCommandProcessor to clean up in case an exception is thron

* [Feature] Update tests

* [Feature] Address comments

* address one more comment

* Address some more comments
2017-08-10 13:32:57 -07:00
Ilya 5890c51e20 Cleanup '#if CORE' in CorePsPlatform.cs (#4415) 2017-07-31 13:02:14 -07:00
jeffbi 1688703caf Make Get-ChildItem follow symlinks on demand, with checks for link loops (#4020)
Add the dynamic parameter `-FollowSymlink` to `Get-ChildItem`.
Add a mechanism for tracking visited directories.
Add native code to get device/inode information on Unix/Windows.
Add warning when refusing to enter an already-visited directory.
2017-07-06 12:28:27 -07:00
Ilya 598cebf7b2 Add cache for GetApplicationBase (#3969) 2017-06-20 15:08:02 -07:00
Paul Higinbotham 578f9e5e8b Fix Linux platform SSH process creation for remoting (#3901)
* Fix SSH process creation on Linux platforms

* Fixed typos

* Added UNIX managed code StartProcess

* Fixed compile errors

* Changed process create to return pid

* Now resolve full SSH command file path for all platforms

* Removed data reader error handling because it conflicts with SSH errors in the error stream

* Clean up work

* Fix for file line endings

* More clean up

* Change to Linux platform SSH process creation to create process in new session

* Added third party license text for DotNet Core

* Removed process creation in new session and added suppress SIGINT

* Removed unneeded code for creating SSH process

* Fixed Unix compile errors

* Changes for code review

* Response to more code review comments

* Removed unneeded using statements
2017-06-14 15:56:56 -07:00
jeffbi 8183732d99 Use more accurate test to check if source and destination paths are pointing the same file (#3441)
Rather than relying on case-insensitive string compares of source and destination paths, use operating system calls to determine whether two paths refer to the same file. This solves not only the case-insensitivity issue but also allows the cmdlet to operate properly if the destination is a hard or symbolic link to the source.
The Windows side is implemented in C#. The Unix side is implemented partially in native code.
2017-04-21 16:09:53 -07:00
Dongbo Wang 7a55bf98b2 Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 11:52:38 -07:00
Steve Lee 753b1965a0 Fix crash at startup when env:HOME not set (#3437)
There are cases like using PowerShell via Puppet where the account being
used does not have a home directory.  Updated PowerShell to use a process
specific temporary directory if HOME, CONFIG, CACHE, and DATA directories
are not available.  Temporary directory is removed when last runspace
is disposed.
2017-04-09 09:23:06 -07:00
Staffan Gustafsson b4049879d4 Adding Parent extended property to System.Diagnostics.Process (#2850) 2017-03-06 15:21:39 -08:00
Steve Lee a2687bfb59 Allow profile directory creation failures for Service Account scenarios (#3244)
XDG profile directory creation can fail for accounts that do not have home directories.

The module analysis was trying to persist it's cache in an XDG profile directory.
The cache is less critical than it once was, so it's reasonable to not cache if there is no good place to do so.

Fixes #3011
2017-03-05 22:05:10 -08:00
Jason Shirk 02b5f357a2 Remove trailing whitespace (#3001) 2017-01-16 13:31:14 -08:00
Andrew Schwartzmeyer e630c6f79c Fix GetCurrentThreadId 2016-10-14 15:43:00 -07:00