Commit graph

6071 commits

Author SHA1 Message Date
Ilya 626a83bcd4
Fix tab completions for a hash table (#6839)
Now working:
- Get-Date | Sort-Object @{Expression=<tab>
- Get-Date | Sort-Object @{Expression=...;<tab>
2018-05-21 09:05:59 +05:00
Travis Plunk b43d3e5d00
stop corrupting memory in libpsl-native SetDate (#6881)
stop corrupting memory in libpsl-native SetDate
Addresses #6872 - the first step
2018-05-18 12:56:09 -07:00
Travis Plunk 731efc2369 Update signing xml based on new signing guidelines (#6893) 2018-05-18 11:55:51 -07:00
Klaudia Algiz 4070d51ee1 Add functions into build.psm1 to Save and Restore PSOptions between different sessions. (#6884)
Add functions into build.psm1 to Save and Restore PSOptions between different sessions.
2018-05-17 19:04:20 -07:00
Klaudia Algiz 2df9aac811 Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests (#6682)
Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests.
Get rid of try { } catch { } formula to assert that errors were thrown.
Small fixes in tests to obey the new Pester -Parameter syntax.
2018-05-17 14:42:04 -07:00
Steve Lee ed282ce0ef Update PowerShell to build against netcoreapp.2.1-rc1 (#6873) 2018-05-16 23:18:53 -07:00
Matthew Bobke 4e3db1bb93 Fix 'Set-Location DriveName:' to restore current working directory in the drive (#6774) 2018-05-16 17:13:22 -07:00
Dongbo Wang aa0af5ed56
Further improve PSMethod to Delegate conversion (#6851)
Refactor code to make it easier to maintain and a little faster. Changes are as follows:

1. Support finding a matching signature with variance. But make PowerShell prefer exact match over a match with variance.
2. The metadata signatures in `PSMethod<..>` are generated based on the array of method overloads in `MethodCacheEntry.MethodInformationStructures`, in the exact same order. So in `LanguagePrimitive.ConvertViaParseMethod`, when we try to figure out if there is a match using the metadata signatures in `PSMethod<..>`, we can get the index of the matching signature, and the same index should locate the matching method in `MethodCacheEntry.MethodInformationStructures`. Therefore, we don't need to compare signatures again in the actual conversion method, and instead, we can just leverage the index we found when figuring out the conversion in `ConvertViaParseMethod`.
   - This gets rid of the reflection call `GetMethod("Invoke")` and the subsequent signature comparisons in the final conversion method.
   - Also, when comparing signatures using `PSMethod<..>` in `ConvertViaParseMethod`, we can just use the generic argument types of each `Func<..>` metadata type, instead of calling `GetMethod("Invoke")` and then `GetParameters()`. This makes the code for comparing signatures simpler (the type `SignatureComparator`).
   - Move `MatchesPSMethodProjectedType` from `PSMemberInfo.cs` to the type `SignatureComparator` in `LanguagePrimitives.cs`, as it's closely related to the signature comparison. Also, renamed it to `ProjectedTypeMatchesTargetType`.
   - These changes make PSMethod-to-Delegate conversion a little faster, but no big improvement, as the true bottleneck probably is in delegate creation(?). Actually, the performance of this conversion is not critical at all at this moment because this feature should rarely be used in any hot script path. So this exercise is mainly for fun. 
3. Remove `PSEnum<T>`. We can directly use enum types when constructing the metadata type `Func<..>`.
4. Remove the code that generates metadata signatures for generic method definitions (call `MakeGenericMethod` with fake types like `GenericType0`, `GenericType1`). This is because:
   - We don't support convert generic method to delegate today, so may be better not spending time on preparing the metadata signature types for those methods. 
   - When the day comes that we need to support it, it's better to use generic argument types directly to construct the `Func<..>` metadata types. I left comments in `GetMethodGroupType` method in `PSMemberInfo.cs` to explain why that approach is better.
2018-05-15 11:45:04 -07:00
Travis Plunk 472b5f7bd1
Enable full symbols for windows (#6853)
The main purpose of this was to enable full symbols for windows release build.
Also makes explicit where we are optimizing and where we are not optimizing due to https://github.com/dotnet/corefx/issues/29700
2018-05-14 15:01:44 -07:00
Dongbo Wang 0a322ddb70
Update installation doc about Raspbian (#6859) 2018-05-14 12:39:38 -07:00
Mark Kraus 525f5933b1 Fix Web Cmdlets for .NET Core 2.1 (#6806)
closes #6728
Breaking change approved in #6728
This PR switches the logic of when the Web Cmdlets handle redirects when the Authorization header is present. .NET Core 2.1 no longer sends the Authorization header by default (dotnet/corefx#26864). however, we introduced the ability to do so leveraging the previous default behavior through the use of the -PreserveAuthorizationOnRedirect switch.

This PR also corrects a bug introduced 6.0.0 where certain redirect types redirect from POST to GET were set which should have passed through POST to POST and some were improperly passing through POST to POST which should have been doing POST to GET. This correction is a breaking change. It was made apparent as now the redirection behavior is being managed by CoreFX which is doing the correct behavior, tests were added for both when CoreFX and the Web Cmdlets manage redirection.
2018-05-14 11:37:30 -07:00
Aditya Patwardhan d07a3e7c2f
Add functions to merge Pester and Xunit logs (#6854) 2018-05-10 17:46:45 -07:00
Dongbo Wang db45785341
Fix a module-loading regression that caused an infinite loop (#6843)
This regression was introduced by #6523, in `PSModuleInfo.cs`. A circular nested module check was removed because the comment there suggested it happens only with a deprecated workflow module. This causes a `StackOverflow` exception when running into circular nested modules.

Circular nested modules could happen for a module that is not well structured. For example, the module folder `test` contains two files: `test.psd1` and `test.psm1`, and `test.psd1` has the following content:
   @{ ModuleVersion = '0.0.1'; RootModule = 'test'; NestedModules = @('test') }

The same value `test` is put in both RootModule and NestedModule, which will end up with a module whose nested module points to itself.

There are two changes in this PR:
1. Add back the check for circular nested modules in `PSModuleInfo.cs`.
2. Remove a wrong `Dbg.Assert` in `ModuleCmdletBase.cs` and two checks before it.
   - For the assertion `Dbg.Assert(newManifestInfo.SessionState == ss`, when facing the example above, the nested module will first be loaded with a different session state, and then when trying to load the root module, the same loaded nested module will be reused for it. So 'newManifestInfo.SessionState' is not `ss`. The assertion will fail in that case.
   - For the two checks before the assertion, they are not needed anymore based on the comments there.
2018-05-10 16:09:36 -07:00
Travis Plunk 4af9f4edac
fix create docker manifest script to work with more complex tags and with repeated use (#6852)
fix create docker manifest script to work with more complex tags and with repeated use
- add characters to validation pattern
- purge manifest after pushing as there is no other way to delete the manifest.
2018-05-10 14:36:47 -07:00
Mark Kraus 0f036d9939 Enable Web Cmdlets Tests for Greater Platform Support (#6836) 2018-05-09 16:35:52 +05:00
Steve Lee 793160228a Fix crash when terminal is reset (#6777)
* fix crash when terminal is reset

* fix check before removing characters
2018-05-08 12:53:13 -07:00
Dongbo Wang 1de9fb5589
Fix build.psm1 to not add tool path to $PATH twice (#6834) 2018-05-08 09:20:39 -07:00
Mark Kraus f54a0ab033 Quote Multipart/Form-Data Field Names (#6782) 2018-05-08 09:18:09 +05:00
Ilya 4737ebae20
Remove web cmdlet tests using proxy env variables (#6808) 2018-05-08 09:15:49 +05:00
Sergey Vasin d1b9aa7eae Remove empty branch and add Dbg.Assert in ExportCsvHelper. (#6816)
Remove Dbg.Assert and add ArgumentNullException.
2018-05-08 08:44:50 +05:00
Travis Plunk f33689b4cb
Update docker files to allow specifying pwsh and from image version (#6835)
Update docker files to allow specifying pwsh and from image version
- Also updated to install security updates when building images
2018-05-07 18:01:12 -07:00
Travis Plunk 8f37c920ef
Blacklist System.Windows.Forms form loaded to prevent a crash (#6822)
Blacklist `System.Windows.Forms` (`WinForms`) from being loaded to prevent a crash
2018-05-07 16:38:27 -07:00
Andrew e0ee13c699 Updates to fedora27 and kalilinux dockerfiles (#6819)
This PR addresses 2 issues:

fedora27 dockerfiles were missing compat-openssl10 prerequisite that on Linux-based Docker hosts produced error No usable version of the libssl was found during Restore-PSPester.
kalilinux PS package validation is failing because of open issue #5413 , so disabling this config for now.
2018-05-07 13:02:01 -07:00
Robert Holt d96a321b49 Change packaging to support Ubuntu 17.10 and 18.04 (#6769)
Ubuntu 17.04 is EOL, so we need to update our packaging for Ubuntu 17.10. This updates the package script and build.psm1 to use 17.10 rather than 17.04.
2018-05-07 12:30:58 -07:00
Sergey Vasin 0b414f67a0 Change -Quiet parameter of Invoke-Pester to -Show None. (#6798) 2018-05-04 09:54:00 -07:00
Robert Holt 5cc27e2059 Add code coverage report generation instructions (#6515)
* Add code coverage report generation instructions

* Add Publish-PSTestTools in docs

* Add references to coverage comparison commands
2018-05-04 09:51:08 -07:00
Sergey Vasin 1be0594f45 Improve code coverage in Export-Csv.Tests.ps1. (#6795)
* Improve code coverage in Export-Csv.Tests.ps1.

* Change test logic.
2018-05-04 09:46:26 -07:00
Ilya c1026b3ae8 Remove 'more' function and move the $env:PAGER capability into the help function (#6059) 2018-05-04 09:25:05 -07:00
Patochun 145cb77226 Update Tests Isfile to correct response for "/" (#6754)
I Think the good answer for "/" is a directory, not a file.
So I recommand to change EXPECT_TRUE by EXPECT_FALSE for this case.
2018-05-03 14:28:44 -07:00
PRASOON KARUNAN V ec678be4f4 Implementation of -lp alias for -LiteralPath variable #6732 (#6770)
Implementation of -lp alias for -LiteralPath variable for issue #6732 

Add-Content 

Add-Type 

Clear-Content 

Clear-Item 

Clear-ItemProperty 

Convert-Path 

Copy-Item 

Export-Alias 

Export-Clixml 

Export-Csv 

Export-FormatData 

Format-Hex 

Get-ChildItem 

Get-Content 

Get-FileHash 

Get-Item 

Get-ItemProperty 

Get-ItemPropertyValue 

Import-Alias 

Import-Clixml 

Import-Csv 

Import-PowerShellDataFile 

Move-Item 

Out-File 

Push-Location 

Remove-Item 

Rename-Item 

Resolve-Path 

Select-String 

Select-Xml 

Set-Content 

Set-Item 

Set-ItemProperty 

Set-Location 

Split-Path 

Start-Job 

Start-Transcript 

Tee-Object 

Test-Path 

Unblock-File
2018-05-03 14:22:48 -07:00
Ilya 84344cbb32 Update PowerShell to build with .NET Core SDK 2.1.300-rc1-008662 (#6718)
* Build Update
- Change `TargetFramework` to `netcoreapp2.1` and removed unnecessary `RuntimeFrameworkVersion` from `PowerShell.Common.props`
- Update dotnet SDK to 2.1.300-rc1-008662
- Update `TypeGen` target in `Build.psm1` to work with 2.1
- Rename macOS runtime to `osx-x64` as the old build logic expects 10.12 and breaks running on 10.13 system.
- Remove `PackageReference` to `System.Memory` as it's part of dotnetcore 2.1
- Update search for `crossgen` executable to find the matching version

* Test Update
- Update test tools `WebListener` to latest `asp.net core`
- Marked `AuthHeader Redirect` tests as `Pending` due to change in CoreFX
2018-05-02 16:58:39 -07:00
Christoph Bergmeister 16e1823e33 Packaging: Add registry keys to support library folder background for explorer context menu (#6784)
Fixes #6590 by adding registry keys to support the existing explorer context menu also when being inside a library folder. It follows the existing pattern that was already applied to special cases such as drives, Desktop, etc.
Manually Tested on Win 10 1709
Thanks to @mklement0 for triaging the issue and already researching the required registry key (he should also be included in the release notes)
2018-05-02 14:43:25 -07:00
Dan Travison 385cc1b796 Disallow Basic Auth over HTTP on Unix (#6787)
Disallow Basic Auth over HTTP on Unix

Fix: #6779
2018-05-02 14:29:10 -07:00
Steve Lee 77d10e969e Fix Format-Table where rows were being trimmed unnecessarily if there's only one row of headers (#6772) 2018-05-02 17:59:48 +05:00
Aditya Patwardhan c51a6e38cf
Fix test and infrastructure blocking code coverage runs (#6790)
* Fix Remove-Item test to use a test directory instead of relying on pre-existing directory
* Increase timeout as we are regularly going over it.
2018-05-01 17:28:57 -07:00
Andrew 0e8665dfc0 Updated Docker package tests, fixed error on opensuse42 (#6783)
This PR addresses minor issues with PS-package docker tests.

Historically rpm package version string was different from other packages, however, this is no longer the case, so updating tests to account for that (to simplify things - removing RPM-version parameter from dockerfiles because it is no longer used).
Configs that use 'linux-x64.tar.gz' (currently only "opensuse42.2") are failing, so fixing that in the script.
2018-05-01 10:38:43 -07:00
Bryan Harmat 03b1f2bb99 tools: fix comparison to see if sudo test is needed in install-*.sh (#6771)
The comparison to test if we were using sudo was failing when running as root. We would then run -v, and get a bad error message. fixing the comparison.
2018-05-01 10:35:19 -07:00
Robert Holt 9ca059dcf8 Revert changes from PR #6600 which cause a regression in drive behavior (#6751)
This reverts the commit 35d8de927b, which caused a regression in drive behavior where drive paths were not restored. See issue #6749.
2018-04-30 15:25:11 -07:00
Klaudia Algiz bee98547e4 Fix Select-Object.Tests.ps1 which might fail for Unix OS. (#6747)
Fix Select-Object.Tests.ps1 which might fail for Unix OS.
In the test, the processes which name matches i* are selected and it checks if there is non zero number of these processes. The test assumes that there is always at least one process, probably `init` - idle, but on Unix idle process does not have the name and hence the test might fail
2018-04-30 13:09:16 -07:00
Dongbo Wang 1f9e9d243d Update 'Get-ChangeLog' to make it more accurate (#6764)
Update 'Get-ChangeLog' to make it more accurate

Use "||" as the delimiter instead of "|", so it works for commit message that has the pipeline operator in it.
Handle merges that create a merge node in history.
Do not treat powershell team members as external contributors.
2018-04-30 13:00:28 -07:00
Robert Holt 0c3f429780 Add tests for PowerShell classes inheriting from abstract .NET classes (#6752) 2018-04-30 10:17:20 -07:00
Dongbo Wang 8aec158519
Clean up uses of CommandTypes.Workflow and WorkflowInfo (#6708)
[breaking change] Clean up code related to the uses of `CommandTypes.Workflow` and `WorkflowInfo` in `System.Management.Automation`. This change mainly affects help provider code.

This PR includes a few minor breaking changes:
- Change the `public` constructors of `WorkflowInfo` to `internal`. We don't support workflow in PSCore, so I think it makes sense to not allow people to create `Workflow` instances.
- Remove the type `System.Management.Automation.DebugSource` since it's only used for workflow debugging.
- Remove the overload of `SetParent` from the abstract class `Debugger` that is only used for workflow debugging.
- Remove the same overload of `SetParent` from the derived class `RemotingJobDebugger`.
2018-04-27 23:02:15 -07:00
Sergey Vasin 24069241bc Fix CimCmdlets tests. (#6755) 2018-04-28 09:48:13 +05:00
Aditya Patwardhan 64050a4687 Added Publish-NugetToMyGet to exported functions in psd1 (#6763)
Added the missing export for Publish-NugetToMyGet.
2018-04-27 16:26:13 -07:00
Dongbo Wang aac9467061
Fix preview download links in README.md (#6762)
Replace `~` with `-` for preview download links in README.md
The file names have `~` in them, but when uploading files to Github, `~` will be automatically replaced. So we use `-` for the packages uploaded to Github.
2018-04-27 15:53:50 -07:00
Klaudia Algiz e9b045e819 Update Start-PSPester and Restore-PSPester cmdlets in build.psm1 to check for Pester 4.2 (#6667)
Update Start-PSPester and Restore-PSPester cmdlets in buil.psm1 to check for Pester 4.2 to support exception passthru.
2018-04-27 15:34:54 -07:00
Dongbo Wang 5fd0d6962b
Merge the release branch of v6.1.0-preview.2 to master 2018-04-27 14:22:23 -07:00
Aditya Patwardhan 2c3177a08d Add tests for PowerShell hosting API to verify MyGet packages (#6737) 2018-04-27 13:25:33 -07:00
Dongbo Wang c5415d31a6
Change line ending from CRLF to LF in Microsoft.PowerShell.Management.psd1 (#6758) 2018-04-27 11:05:24 -07:00
Dongbo Wang 9e59bc122a Update the preview version to 6.1.0-preview.2 in README.md 2018-04-27 00:54:42 +00:00