Commit graph

87 commits

Author SHA1 Message Date
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
Bruce Payette bbb4f2ea84 Fix for #4520 '-ArgumentList should accept @() or $null' (#6597)
* Fix for #4520 '-ArgumentList should accept @() or $null'
Removed the [ValidateIsNotNulOrEmpty] attribute from the parameter.

* Fixed null and @() empty list tests to not both test null

* [Feature] Fixed test issue on non-Windows; added code to suppress displaying new windows on Windows.
2018-06-22 11:29:46 -07:00
Ilya e177fcaef6 CodeFactor code style cleanup: replace literal empty strings with 'string.Empty' (#6950) 2018-06-12 12:30:10 -07:00
Klaudia Algiz f0b6ef2eb4 Terminate the loop in PsUtils.GetMainModule() which was infinite in case there was no main module. (#6358)
* Terminate the loop in GetMainModule if main module is null.

* Run tests with FileVersionInfo also on non-windows platforms. Add test for process which main module can be null.
2018-04-03 10:58:06 -07:00
Kevin Marquette 548850d249 Add 'Path' alias to '-FilePath' parameters and others for several commands (#5817) 2018-02-27 13:05:58 -08: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 847846d834 [feature] (#4960)
remove -computer support since corefx Process.GetProcesses(computer) returns local processes
2017-10-18 15:49:45 -07:00
James Truher [MSFT] 0229451148 Validate product resource strings against resx files (#4811) 2017-09-18 09:20:46 -07:00
Sarith Sutha f4b075c856 Add -WhatIf switch to Start-Process cmdlet (#4735)
* Add -WhatIf switch to Start-Process cmdlet
* Add test for the -WhatIf switch 

* Added a test to ensure that using a whatif switch prevents the action from being performed.

* Incorporated code review comments

* merged two tests into one as suggested

* Included the error action at the end of the cmdlet

* Remove extra space before `StringUtil` and new line

* Renamed the resource string id ProcessStartInfo to StartProcessTarget
2017-09-08 09:18:13 +04: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 649ff285ee Clean up '#if CORE' in ProcessCodeMethods.cs and 'ClrFacade.GetSafeProcessHandle' (#4428) 2017-08-08 09:20:57 -07:00
Dongbo Wang 1462ac300b Clean up ClrFacade.cs - remove ClrFacade.PtrToStructure (#4379) 2017-07-29 22:34:31 -07:00
Dongbo Wang 8ae6c5bb3b Refactor PowerShell Core to use the default CoreCLR loader instead (#3903)
Remove the code that spins up our own assembly load context. Keep the code that registers our `Resolve` method to the default loader's `Resolving` event, so that we can continue to do special assembly resolution as needed (such as the GAC probing logic needed for consuming FullCLR PS modules).

Essentially, the assembly `Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll` is not needed anymore, the remaining code should be moved to S.M.A.dll. However, that will break DSC and other native hosts that are hosting powershell. So this assembly is kept for now.
2017-06-05 20:59:30 -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
George Chakhidze 47ec6b2a86 Use IntPtr(-1) for INVALID_HANDLE_VALUE instead of IntPtr.Zero (#3544)
- Fix incorrect handling of 'GetCurrentProcess()' API return value in 'IsWow64()' function (MainEntry.cpp)
- Remove unused INVALID_HANDLE_VALUE field from 'ProcessNativeMethods' class (Process.cs)
2017-04-13 17:00:56 -07:00
Dongbo Wang 7f83c48ca5 Add support to ShellExecute in powershell core when it's running on Windows full SKUs (#3281)
* Add ShellExecute support to PowerShell core on windows full desktop
* Add tests for Start-Process and update existing related tests
2017-03-14 11:11:41 -07:00
Staffan Gustafsson b4049879d4 Adding Parent extended property to System.Diagnostics.Process (#2850) 2017-03-06 15:21:39 -08:00
Jason Shirk (POWERSHELL) 386b4f37f4 Remove CheckForSevereException and private FailFast
Our private implementation of FailFast was likely introduced
when each individual application needed it's own code to
get Watson reports. The CLR takes care of this for us now,
so we don't need our implementation.

Our method CheckForSevereException was also introduced in
the early days of the CLR - the exceptions it was checking
for aren't actually raised the CLR anymore, they just FailFast.
I removed them as there is a tiny bit of overhead (in code size)
and also in the generated code, e.g. dynamic sites called the method.
2016-12-01 13:46:56 -08:00
Sergei Vorobev 6992a6479a Merge pull request #2260 from jsoref/spelling-public
Fix spelling in public APIs
2016-09-19 17:33:46 -07:00
charub 3d7beb4425 Provide an unsupported message for 'Verb' parameter (#1691)
Add the 'Verb' parameter to Powershell core and add an unsupported message
for the same.
2016-09-15 10:50:36 -07:00
Dongbo Wang 58a2ba730d Merge pull request #2046 from xiaoyinl/use-https-links
Use HTTPS links for go.microsoft.com
2016-09-01 17:23:09 -07:00
Josh Soref 0bba0328bc spelling: public identifiers in src/Microsoft.PowerShell.Commands.Management 2016-09-01 16:08:57 +00:00
Josh Soref eb3fd7ae6c Spelling comments (#2066)
* spelling: comments in src/Microsoft.Management.Infrastructure.CimCmdlets

* spelling: comments in src/Microsoft.PackageManagement.ArchiverProviders

* spelling: comments in src/Microsoft.PackageManagement.CoreProviders

* spelling: comments in src/Microsoft.PackageManagement.MetaProvider.PowerShell

* spelling: comments in src/Microsoft.PackageManagement.MsiProvider

* spelling: comments in src/Microsoft.PackageManagement.MsuProvider

* spelling: comments in src/Microsoft.PackageManagement.NuGetProvider

* spelling: comments in src/Microsoft.PackageManagement.PackageSourceListProvider

* spelling: comments in src/Microsoft.PackageManagement

* spelling: comments in src/Microsoft.PowerShell.Activities

* spelling: comments in src/Microsoft.PowerShell.Commands.Diagnostics

* spelling: comments in src/Microsoft.PowerShell.Commands.Management

* spelling: comments in src/Microsoft.PowerShell.Commands.Utility

* spelling: comments in src/Microsoft.PowerShell.ConsoleHost

* spelling: comments in src/Microsoft.PowerShell.Core.Activities

* spelling: comments in src/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext

* spelling: comments in src/Microsoft.PowerShell.CoreCLR.Eventing

* spelling: comments in src/Microsoft.PowerShell.Diagnostics.Activities

* spelling: comments in src/Microsoft.PowerShell.GraphicalHost

* spelling: comments in src/Microsoft.PowerShell.LocalAccounts

* spelling: comments in src/Microsoft.PowerShell.Management.Activities

* spelling: comments in src/Microsoft.PowerShell.PSReadLine

* spelling: comments in src/Microsoft.PowerShell.PackageManagement

* spelling: comments in src/Microsoft.PowerShell.ScheduledJob

* spelling: comments in src/Microsoft.PowerShell.Security.Activities

* spelling: comments in src/Microsoft.PowerShell.Security

* spelling: comments in src/Microsoft.PowerShell.Utility.Activities

* spelling: comments in src/Microsoft.PowerShell.Workflow.ServiceCore

* spelling: comments in src/Microsoft.WSMan.Management.Activities

* spelling: comments in src/Modules

* spelling: comments in src/Schemas

* spelling: comments in src/libpsl-native

* spelling: comments in src/powershell-native

* spelling: comments in build.psm1

* spelling: comments in src/System.Management.Automation/CoreCLR

* spelling: comments in src/System.Management.Automation/DscSupport

* spelling: comments in src/System.Management.Automation/cimSupport

* spelling: comments in src/System.Management.Automation/commands

* spelling: comments in src/System.Management.Automation/engine/Modules
2016-08-26 13:46:03 -07:00
xiaoyinl f538eeb416 Use HTTPS links for go.microsoft.com
I replace all occurrences of http://go.microsoft.com with https://go.microsoft.com in text files.
2016-08-23 21:21:31 -04:00
PowerShell Team ae8d2ed794 Refactor - convert to auto-property
Mostly using R# to automatically refactor, with some manual
fixups where it wouldn't work automatically (e.g. xml comments
on fields) or some it seemed to miss.

Some minor code reformatting was also done on properties near
other stuff I was manually inspecting.
2016-08-03 12:14:28 -07:00
PowerShell Team 403ae3f53f Initial run of code formatter
I (Jason Shirk) ran https://github.com/dotnet/codeformatter with the default rules, basically:

    codeformatter /nocopyright "/c:DEBUG,UNIX,CORECLR" @files.rsp

This caused a few problems building, which were fixed up manually.

Notable changes:

`this.` is removed unless needed to disambiguate.
private instance fields are renamed to have a `_` prefix.
private static fields are renamed to have a `s_` prefix.

I left some projects alone (like PackageManagement) and also left some generated code alone.
2016-08-01 15:57:03 -07:00
Jason Shirk (POWERSHELL) 673dd2c355 Change preprocessor macro LINUX to UNIX 2016-07-22 10:49:45 -07:00
Andrew Schwartzmeyer 2abe461992 Refactor to use GetUserFromPid 2016-07-13 15:46:25 -07:00
Andrew Schwartzmeyer e6d3cbcce0 Implement Get-Process -IncludeUserName for Linux
So much plumbing. The correct way to identify the owner of a process on
Linux is to get the owner of the /proc/<PID> file. However, .NET Core
has no API to get this information, thus it had to be plumbed through to
the native library.
2016-07-13 15:46:25 -07:00
Andrew Schwartzmeyer 2f892e8127 Use Marshal.ZeroFreeCoTaskMemUnicode
This removes the ClrFacade function of the same name as this API is in
.NET Core 1.0 Marhsal class, not SecureStringMarshal.
2016-06-27 15:30:47 -07:00
PowerShell Team 8ee6d6ca43 Update files from Source Depot changeset [SD:715912]
Corresponds to 77eda782aa78ba8b7a36c51ee619629ce6c990f2 in psl-monad.
2016-06-15 18:02:03 -07:00
Andrew Schwartzmeyer f5410a18ce Replace IsWindows method with property
And add *correct* IsLinux and IsOSX properties.
2016-04-08 14:54:41 -07:00
PowerShell Team 78a18c3f70 Revert "Update files from psl-monad"
This reverts commit 9ed2c2a68b.
This commit is here to make source-depot branch a parent of master
2016-04-06 12:03:50 -07:00
PowerShell Team 9ed2c2a68b Update files from psl-monad
This commit uses psl-monad branch source-depot 28156300
And corresponds to [SD:692351]
2016-04-06 11:55:18 -07:00
PowerShell Team 45140c5752 Move files from psl-monad submodule to super-project
This commit uses master branch 860eb5d
2016-03-30 20:01:33 -07:00
PowerShell Team 60b3b304f2 Move files from psl-monad submodule to super-project
This commit uses psl-monad branch source-depot 7209cb9
And corresponds to [SD:688741]
2016-03-30 17:16:23 -07:00