Commit graph

1686 commits

Author SHA1 Message Date
Ilya 450d884668
Add test for $error[0] tab completion (#7924) 2018-10-03 12:34:21 +05:00
Ilya d862d4075f
Add EscapeHandling parameter in ConvertTo-Json cmdlet (#7775)
Add EscapeHandling parameter in ConvertTo-Json cmdlet to allow escape the HTML (<, >, &, ', ") and control characters (e.g. newline).
2018-10-02 10:54:33 +05:00
Ilya 0727f96d97
Replace hang term (#7902) 2018-10-02 08:11:38 +05:00
Robert Holt 649d342a07 Replace test certificates with self-signed certificate generating command (#7875) 2018-10-01 14:40:48 -07:00
Benjamin P. McKenna 39252b4938 Add '%F' case to Get-Date -UFormat (#7630) 2018-10-01 08:39:14 +05:00
James Truher [MSFT] 98cf44cdec Test changes needed for running in a container (#7869) 2018-09-28 13:49:31 -07:00
Steve Lee cc44781b5b Ensure NestedModules property gets populated by Test-ModuleManifest (#7859) 2018-09-28 13:28:08 -07:00
Joel Sallow 8f4b66af29 Add C#-style type accelerators and suffixes for ushort, uint, ulong, and short literals (#7813)
[breaking change]
Add the following type accelerators: [short], [ushort], [uint], [ulong].
Add the following numeric literal suffixes:
 - 'u' suffix (uint/ulong)
 - 's' suffix (short)
 - 'ul' suffix (ulong)
 - 'us' suffix (ushort)
2018-09-28 13:27:32 -07:00
PRASOON KARUNAN V e6702fe780 Get/Add-Content throws improved error when targeting a container (#7823) 2018-09-28 20:36:13 +05:00
Robert Holt bd5f7719bc Add version checking tests for Import-Module (#7499) 2018-09-27 17:08:54 -07:00
Andrew bc5fe72096 Updating test gallery URL in PackageManagement tests (#7879) 2018-09-27 14:23:10 -07:00
Steve Lee 769ba7b95c Update PowerShellGet to 2.0.0 (#7831) 2018-09-24 14:58:13 -07:00
Travis Plunk 8a0abf459c
update markdown tests (#7838)
update markdown tests

  - explicitly use gulp 4.0 beta because 3.9 depends on a vulnerable package
2018-09-24 10:14:43 -07:00
Dongbo Wang 0f0c46dfe5 Update to .NET Core 2.1.4 with SDK 2.1.402 (#7834) 2018-09-21 13:25:03 -07:00
Dongbo Wang b6d12a35ed [Feature] Fix .NET adapter to be able to get members from System.IntPtr (#7808)
The type System.IntPtr has an explicit cast operator defined that takes a pointer type System.void* parameter. Now we handle that type properly in GetPSMethodProjectedType.
2018-09-20 08:15:42 +05:00
Staffan Gustafsson eb286332cf Create inferred types for Select-Object, Group-Object, PSObject and Hashtable (#7231)
Fixes #7230.

Adding the concept of a PSSyntheticTypeName, derived from PSTypeName,
that extends it with a list of synthetic members.

This allows us to express the inferred type of
```
[pscustomobject] @{
   A = 1
   B = "2"
}
```
as a "PSObject#A:B" and with information about the types of A and B.

This is also used to annotate the output of
```
Select-Object -Property
Select-Object -ExcludeProperty
Select-Object -ExpandProperty
```
Finally, it adds information about the types of the
`Group` and `Value` properties of the output of `Group-Object`
2018-09-19 15:43:22 -07:00
Ilya cc5f36c67a
Allow numeric Ids and name of registered code pages in '-Encoding' parameters (#7636)
Enhance the encoding transformation attribute:
- to allow numeric Ids of registered code pages (like -Encoding 1251)
- to allow string names of registered code pages (like -Encoding "windows-1251")
2018-09-19 18:53:03 +05:00
Christoph Bergmeister [MVP] 4bc22d92df Add support for 'cd +' (#7206)
'cd +' adds the ability to revert 'cd -' by having another bounded stack with the same limit for 'redo' actions.
Behaviour is similar to back/forward navigation in explorer.exe
When the location is set to a path and the redo stack is non-empty then the redo stack gets flushed.
When cd + happens, then the redo stack is pushed to as well for a more intuitive way of navigating backwards and forwards.
All the work is done of course on the Set-location cmdlet, which is aliased to cd on all platforms.
2018-09-19 12:50:30 +05:00
Robert Holt 3c67fa3411 Add tests for Import-Module -Force (#7491) 2018-09-19 09:32:35 +05:00
Andrew e725a030d7 Updating ModulePath.Tests for fxdependent package (#7772) 2018-09-17 13:22:00 -07:00
Dongbo Wang 285e471034
Fix .NET adapter to not throw when fails to create a PSMethod due to ByRef-like type (#7788) 2018-09-17 12:45:55 -07:00
Dongbo Wang 720e842c86
Support calling method with ByRef-like type parameters (#7721)
Support calling methods with ByRef-like type parameters in PowerShell, as long as the argument specified for the parameter can be implicitly/explicitly converted to the ByRef-like type.

We cannot create an instance of a ByRef-like type in PowerShell, but there are types that can be implicitly or explicitly converted to ByRef-like types, such as `T[] -> Span<T>`, `T[] -> ReadOnlySpan<T>`, `String -> ReadOnlySpan<T>`. `ArraySegment<T> -> Span<T>`, `ArraySegment<T> -> ReadOnlySpan<T>`. With changes in this PR, we can call methods with ByRef-like parameter types by providing the arguments of the types that can be cast to the target ByRef-like type.

**What is enabled?**
1. Invoking methods that have ByRef-like parameters, but the return type is not ByRef-like.
2. Invoking constructors with ByRef-like parameters via `[target-type]::new` syntax, but the `target-type` is not ByRef-like.
3. Accessing indexers that have ByRef-like parameters, but the return type is not ByRef-like.
2018-09-11 16:57:35 -07:00
ThreeFive-O 32cdbe688e Fix pipeline test where SmtpServer key was set wrong in pipeline object (#7745)
Fix SmtpServer key (was $SmtpServer) in hashtable object.
Removed double quotes for all keys in hashtable object.
2018-09-11 09:29:10 +05:00
Aditya Patwardhan 2e3069900b Update version for powershell release 6.1.0 (#7751) 2018-09-10 13:08:42 -07:00
Dan Travison 4683934793 Update PowerShell to handle the case where the Windows PowerShell module path is already in the environment's PSModulePath (#7727)
This change updates ModuleIntrinsics.GetModulePath to handle the case where the Windows PowerShell module path is already in the environment's PSModulePath or when launched from a different version of PowerShell.

Previously, GetModulePath would append $PSHOME\Modules to the PSModulePath after removing the path for the launching version without considering the Windows PowerShell module path. The result, was the Windows PowerShell modules were found first and loaded incompatible modules; such as the built-in modules.

The change detects the Windows PowerShell module path and inserts $PSHOME\Modules path before it. The new test simulates launching from a different version of pwsh that has already added the Windows PowerShell module path.

Fixes #7679
2018-09-10 10:58:38 -07:00
Travis Plunk 2141c2a8e3
Add daily build non-windows platforms (#7683)
Add daily build non-windows platforms
  - Also, make the [Feature] tag work in VSTS for non-windows
  - Also, add a way to force feature tests to run
  - Also, fix an issue where `-workingdirectory` didn't work when running async
2018-09-06 12:27:49 -07:00
Sergey Vasin ccd2e536cb Fix module specification hashtable in ModuleSpecification.Tests.ps1 (#7663) 2018-09-04 10:06:35 -07:00
Travis Plunk e2a45f0992
Add tests to report when package references are out of date (#7661)
Add tests to report when package references are out of date
  - Also, update the packaging script to generate updated `files.wxs`
2018-08-31 12:50:51 -07:00
Ilya c34d3ef332 Update to latest package references, runtime framework, and SDK (#7646)
* Move to .Net Core SDK 2.1.401 and runtime 2.1.3

* Update package references
2018-08-30 18:39:44 -07:00
Christoph Bergmeister [MVP] b3c961f882 Update docs about .NET Core version 2.0 to be about version 2.x (#7467) 2018-08-30 16:51:52 -07:00
James Truher [MSFT] bc1aac78d3 Change logic for downloading zip files based on job id (#7653) 2018-08-30 11:23:19 -07:00
Patrick Meinecke 5c2faaf02e Enable indexing operations on objects that implement ITuple (#7633)
This change enables index operations on objects that implement `ITuple` and other interfaces that have `DefaultMemberAttribute` declared, including slicing and negative indexing.
2018-08-30 10:54:26 -07:00
Yuriy Kushnir 165f2c9a42 Use non-virtual call to invoke 'family or assembly' methods on base class from PowerShell class (#7622) (#7624) 2018-08-28 22:24:06 -07:00
zhenggu 358e8abefe Fix Set-Service -Status Stopped to stop services with dependencies (#5525) 2018-08-28 11:03:12 -07:00
Staffan Gustafsson 87ccd0aa40 Only display properties with values for MeasureInfo (#7104)
* Adding support for built-in List formats to include ItemSelectionCondition
* Adding ItemSelectionCondition to GenericMeasureInfo
* Adding tests for MeasureInfo format-list
* Adding positive tests
2018-08-28 08:18:56 +05:00
Staffan Gustafsson 1bfe96d3c4 Add Duration property to HistoryInfo (#5208)
* Remove regions in HistoryInfo class
* Auto properties refactoring in HistoryInfo
* Adding Duration property to HistoryInfo
* Rename ExecutionTime => Duration
2018-08-28 08:03:07 +05:00
Aditya Patwardhan aec954e3ed Fix null reference when markdown content is empty (#7463) 2018-08-27 11:58:19 +05:00
Dongbo Wang 86469bda33
Handle operations with ByRef-like types gracefully in PowerShell (#7533)
ByRef-like types are supposed to be used on stack only, so we need to fail gracefully when accessing properties, calling methods, or creating objects related to ByRef-like types.
2018-08-26 12:50:58 -07:00
Travis Plunk bf0787f9a0
Make -settingfile work for scriptblock logging on windows (#7631)
Make `-settingfile` work for scriptblock logging on windows
  - Move EarlyParse to the first thing in the ManagedEntrance so that we don't cache the settings before we parse the settings file.
  - Added a test case to prevent regression
    - I'm working on more test cases.  Therefore, I used the TestCases parameter.
  - Changed the macOS tests back to CI as I think they are stable enough now.
2018-08-26 11:03:28 -07:00
Travis Plunk 6c454c6ea8
Update test which assumes all previews have the name preview in the version. (#7625) 2018-08-23 17:19:45 -07:00
Ilya 75c70a2a7c Update pester syntax in Set-Location test (#7615) 2018-08-23 15:15:03 -07:00
Dan Travison 23832e5e95 Update 'SSHConnectionInfo Class Tests' $skipTest expression to use collection semantics instead of relying on $null (which causes a type cast exception). (#7610) 2018-08-23 15:10:39 -07:00
Travis Plunk d6817a42e4
Add Linux ScriptBlock logging test (#7599) 2018-08-22 16:34:03 -07:00
Bruce Payette 4943bbfd9e Add LocationChangedAction handler and tests to support the Windows Compat module (#7552)
Add LocationChangedAction handler and tests to support the Windows Compat module.
2018-08-22 12:08:03 -07:00
Travis Plunk 97d2e10c22
Merge release v6.1.0 rc.1 into master (#7608) 2018-08-22 12:06:00 -07:00
Travis Plunk 849f6fb147
Add test for scriptblock logging for macOS (#7586) 2018-08-21 13:20:54 -07:00
Aditya Patwardhan cbbc8192c4 Merged PR 4656: Add back the powershell-core source for hosting tests 2018-08-21 17:24:06 +00:00
Travis Plunk 40532d9a2e
Add VSTS CI for Windows (#7536)
- Add VSTS CI for Windows
    - Disable `Access-denied test for Get-Item C:\windows\appcompat\Programs\Install -ErrorAction Stop`, because the path does not always exist
        - https://github.com/PowerShell/PowerShell/issues/7553
    - Disable `Should give .sys file if the fullpath is specified with hidden and force parameter`, because pagefile.sys doesn't always exist and other files don't meet test's requirement.
        - https://github.com/PowerShell/PowerShell/issues/7554
    - Disable some `Test-Connection` tests for same reasons they failed on VSTS Linux
        - https://github.com/PowerShell/PowerShell/issues/7555
    - Disable `Test-FileCatalog should pass when catalog is in the same folder as files being tested`, because the CmdLet does not work in that scenario
         - Also, give details needed to investigate when the test fails
         - https://github.com/PowerShell/PowerShell/issues/7556
    - Update `appveyor.psm1` to work with VSTS
    - Update `HelpersRemoting.psm1` `New-RemoteSession` to work for CimSession (discovered an issue during the investigation)
    - Update `Test wildcard with drive relative directory path` to work when there are multiple drives
         - Disable on non-windows machines since the test is assuming drive letters
    - Update `New-CimSession` Tests to requireAdmin
         - Also, make sure session name is a string
    - Add functions to save and restore psoptions
    - update `.gitatttributes` so files clone like they do on appveyor
2018-08-17 22:06:51 -07:00
Aditya Patwardhan 96b2c83c59 Update reference to use packages from NuGet.org (#7525)
Update psrp and libpsl reference to Microsoft.PowerShell.Native
Keep the reference to powershell.myget.org in nuget.config for PSDesiredStateConfiguration and PowerShellHelpFiles
Update hosting tests
Update hosting.tests.csproj in preparation on next release with version 6.1.0-rc.1
Update Microsoft.Management.Infrastructure to version 1.0.0
2018-08-16 15:56:15 -07:00
Travis Plunk a746fd29ec
Revert "Throw error on entering non-existing type in Get-FormatData (#7434)" (#7546)
Revert "Throw error on entering non-existing type in Get-FormatData (#7434)
This reverts commit b754cd80d5.

Per this comment https://github.com/PowerShell/PowerShell/pull/7434#issuecomment-413696259
2018-08-16 15:46:12 -07:00
Travis Plunk 0a1a47e8b0
Make sure we do not upload artifacts during a pull request (#7535) 2018-08-16 13:11:24 -07:00
Paul Higinbotham a21366710c Updated thread job to version 1.1.2 (#7522)
Added fix to remove unneeded validation attribute for Arguments parameter, and made tests work with strict mode.
2018-08-14 17:09:48 -07:00
Travis Plunk 965552873c
Add Linux VSTS CI (#7527)
Update Start-PSPester and Start-PSxUnit to upload test results when running in VSTS
Disable tests which require non-root using when running as root
remove verifications in Test-Connection tests which verify buggy behavior
Skip tests which don't behave correctly in VSTS (due to running in a container?)
- Test-Connection - #7528
- Set-Date - #7529
2018-08-14 16:23:50 -07:00
Steve Lee 769b02ab98 Save modules to un-versioned folder to enable servicing (#7518)
Remove code from build.psm1 that save the modules to a versioned folder. For servicing reasons after release it is preferred and easier to not have the versioned folder so that we can directly replace modules that need to be serviced (MSI specifically makes it difficult to service a module if the folder path changes).
2018-08-14 10:15:05 -07:00
Travis Plunk b3d0913d74
Add CI definition for VSTS for macOS (#7490)
Add CI definition for VSTS for macOS
  - Add VSTS YAML for mac
  - Add a function to upload log files during a test on VSTS
2018-08-10 15:13:31 -07:00
Staffan Gustafsson 3aaa1816d1 Adding 'LanguagePrimitives.TryCompare' to provide faster comparisons (#7438) 2018-08-10 10:20:27 -07:00
Syed Faraaz Ahmad b754cd80d5 Throw error on entering non-existing type in Get-FormatData (#7434)
Write non-terminating error when `Get-FormatData` doesn't found a type definition for the provided type,
2018-08-10 09:34:02 +05:00
Staffan Gustafsson 618d9f31a0 Add '-SkipIndex' parameter to 'Select-Object' (#7483) 2018-08-09 11:59:54 -07:00
Dongbo Wang ca64bfb3e3
Update the 'HelpUri' for 'Get-ExperimentalFeature' (#7466) 2018-08-08 12:38:07 -07:00
Travis Plunk d29349bb4d
Default to DefaultConsoleWidth when DotNet says WindowWidth is 0 (#7465)
Default to DefaultConsoleWidth when DotNet says WindowWidth is 0

This resolves an issue in an environment like VSTS when pwsh is spawned and DotNet is not able to determine the Console Width.
* Port changes from #6883 by @kalgiz
2018-08-07 15:27:42 -07:00
Travis Plunk 1523c218a6
Make sure that SettingFile arg is parsed before we load the settings (#7449)
Make sure that SettingFile arg is parsed before we load the settings

- Add ability to parse some setting before console host is created
- Trigger the Parse before the console host is created
- disable snapin loading from loading setting before this point
- re-enable mac logging tests.

Also, fix the following Travis-ci issues:

- make sure the Linux and macOS caches are separate to reduce the size
- update the macOS image to the closest image as used by the official build system (equivalent to VSTS hosted mac builds)
2018-08-07 15:01:31 -07:00
Bruce Payette 0c11582e6c Make Native globbing on UNIX return an absolute path when it is given an absolute path (#7106)
Fix #7089. Native globbing on UNIX was turning absolute paths into relative paths when it shouldn't. The code suppresses generating a relative path for paths starting with '~'. It also need to do the same for paths starting with '/'.
2018-08-07 14:38:22 -07:00
Steve Lee 36dc96af0e Fix error message for Add-Type when -AssemblyName with wildcard is not found (#7444) 2018-08-06 11:12:39 -07:00
kwkam fbfbb4f005 [Feature] Fix Move-Item -Path with wildcard char (#7397)
Unescape non-literal, non-glob path in ProccessRecord and
set the context.SuppressWildcardExpansion in RenameItem.
This solve the issue where Rename-Item complains -Path does not exist
when both -Path and CWD contains special characters.
2018-08-05 17:31:06 +05:00
Robert Holt dbdcf6e5eb Fix to not duplicate the System32 module path when starting pwsh from pwsh (#7414) 2018-08-03 11:22:30 -07:00
Dongbo Wang 25c127c3bc
Update CI scripts to support running tests for experimental features (#7419) 2018-08-03 11:20:14 -07:00
Steve Lee f8b3abaac7 Add support for passing files and markdown directly to Show-Markdown (#7354)
* add support for -Path/-LiteralPath and piping strings directly to Show-Markdown

* update tests to set vt100 support
2018-08-02 15:49:38 -07:00
Christoph Bergmeister [MVP] 5717a5dffc Add xunit project to PowerShell.sln and make it runable from within VisualStudio (#7254)
* add csproj ref to sln

* Remove Microsoft.NET.Test.Sdk NuGet reference. The xunit.runner.visualstudio package is now sufficient for running tests in VS in the latest version (15.7.5)

* use RTM versions of XUnit 2.4.0 that got published today

* Update XUnit in hosting project as well to newer release
2018-08-02 11:51:04 -07:00
Dongbo Wang 73b6d810bd
Make logging tests for macOS pending (#7433) 2018-08-01 16:49:39 -07:00
Sergey Vasin 740d059d51 Change parameters order in Get-Help and help in order to get first -Full and then -Functionality when using Get-Help -Fu<tab> and help -Fu<tab>. (#7370) 2018-07-31 11:13:18 +05:00
Sergey Vasin 58ac08c60a Use -HaveCount instead of -Be in Where-Object.Tests.ps1. (#7379) 2018-07-31 08:51:42 +05:00
Sergey Vasin da6d2647ac Use -BeExactly and -HaveCount instead of -Be in TabCompletion.Tests.ps1. (#7380) 2018-07-30 10:32:52 +05:00
Sergey Vasin 9e30419501 Use -BeExactly and -HaveCount instead of -Be in BugFix.Tests.ps1. (#7386) 2018-07-30 08:17:28 +05:00
Aditya Patwardhan 4e7c2ed663 Fix several issues in Markdown cmdlets (#7329)
- Formatting file should be used for `MarkdownOptionInfo` object instead of the types file for adding script property.
- Downlevel windows consoles which do not support VT100 escape sequences should be handled gracefully.
- Add helpuri fwlink for cmdlets.
- Make `-Path` a positional parameter for `ConvertFrom-Markdown`
- make `-InputObject` a positional parameter for `Set-MarkdownOption`
2018-07-27 17:26:35 -07:00
Steve Lee b767d5cacd Fix IsHardLink() to return false instead of throwing exception when unable to determine (#7355) 2018-07-26 10:08:38 -07:00
Paul Higinbotham 20f7577548 Fix ThreadJob tests so that they will run more reliably (#7360) 2018-07-26 10:02:05 -07:00
Dan Travison 936626b7e8 Update PowerShell to reference 'psrp.1.4.5-0' on Unix build (#7350) 2018-07-25 10:04:00 -07:00
Dongbo Wang 87d8fc969c
Fix sequence point update for switch/if/for/while/do-while/do-until statements (#7305)
- Make switch-statement report correct error position when it fails to evaluate the condition.
- Make for-statement report correct error position when it fails to evaluate the initializer.
- For the condition of `if/for/while/do-while/do-until` statements, the sequence point update is either duplicate in some cases (for `if/for/while`) which causes debugger to stop at the condition twice  before moving forward, or missing (for `do-while/do-until`) which causes debugger to skip the condition. They are fixed.
2018-07-25 09:56:32 -07:00
Adam Gauthier e34554c3ca Ignore Newtonsoft.Json metadata properties in ConvertFrom-Json (#7308)
Some values are not converted from json to PSCustomObject, because Newtonsoft.Json reads them and thinks they are metadata properties only useful for deserialization. This change makes Newtonsoft.Json "ignore" those properties so they are converted correctly from json to PSCustomObject.
2018-07-25 08:56:49 +05:00
Steve Lee f5a7d79175 Add support for parsing Link Header with variable whitespace (#7322)
Fix is to change the regex to allow for variable or no whitespace and associated tests to handle these two cases.
2018-07-24 10:56:00 +05:00
Steve Lee 0a2f9c8821 Update Enable-PSRemoting so configuration name for Preview releases (#7202)
The intent was to have the version of the PSSessionConfiguration name not include the `v` for the version string.  Also, Preview releases should standardize on `PowerShell.6-Preview` instead of clobbering `PowerShell.6` so that stable and preview can co-exist side-by-side.

Need to verify on Win10 IoT if `Install-PowerShellRemoting.ps1` is still needed anymore as it may be possible to run `pwsh -c enable-psremoting` from within Windows PowerShell Core removing the need for that script which duplicates `Enable-PSRemoting` capability.

Update: Not able to get the current master build working on Win10 IoT, getting `Invalid access to memory` error.  Will have to investigate this separately from this PR and keep `Install-PowerShellRemoting.ps1` for now.

Fix https://github.com/PowerShell/PowerShell/issues/7119
2018-07-16 19:35:48 -07:00
Robert Holt c94fc31f97 Enforce the 'CompatiblePSEditions' check for modules from the legacy 'System32' module path (#7183)
- Add `%WINDIR%\System32\WindowsPowerShell\v1.0\Modules` (Windows PowerShell $PSHOME) to the end of the default PSCore 6 module path (i.e. the module path as initially set at startup).
- Cause an error to be thrown by `Import-Module` when a module with `CompatiblePSEditions` not containing `"Core"` is being loaded from the 'System32' module path.
- Suppress output of modules listed by `Get-Module -ListAvailable` from Windows PowerShell $PSHOME when `CompatiblePSEditions` does not contain `"Core"`.
- Introduce the `-SkipCompatibilityCheck` switch parameter on both `Import-Module` and `Get-Module` to respectively allow importing incompatible modules and listing incompatible modules.
- Adds a  `PSEdition` column to the `PSModuleInfo` table view format.
- Ensures that completions are not given for incompatible modules on the System32 module path.
2018-07-16 16:58:40 -07:00
Dongbo Wang 6f3e9d0881
Added Markdown rendering cmdlets (#6926)
- `ConvertFrom-Markdown` is used for converting a markdown document or string to a MarkdownInfo object. It can optionally return an HTML or a VT100 encoded string in addition to an AST of the markdown document.
- `Show-Markdown` is used to either display the VT100 encoded string on the console or redirect the HTML string to the browser.
- `Set/Get-MarkdownOption` cmdlets are used to view or set markdown rendering options.
2018-07-13 13:56:17 -07:00
Aditya Patwardhan ab07b85f01
Merge pull request #7284 from daxian-dbw/removeVB
Remove the 'VisualBasic' support from Add-Type
2018-07-13 13:48:50 -07:00
Bruce Payette f4a50eda0d Fix prompt string to be platform agnostic and keep its trailing spaces (#7255) 2018-07-13 01:22:10 -07:00
Bruce Payette 716ed2acbd Fix a parsing error when 'break' and 'continue' are used in a switch statement in a finally block (#7273) 2018-07-13 01:19:47 -07:00
Dongbo Wang c34866d0fa [Feature] Remove 'VisualBasic' support from Add-Type 2018-07-12 23:50:09 -07:00
Travis Plunk b15709f444 update to latest package references, runtime framework, and SDK (#7272)
* update to latest package references

* update runtime framework

* update sdk

* automatically read NuGet package dependency info from csproj, where version info is fully qualified

* update file.wxs
2018-07-13 09:00:35 +05:00
Aditya Patwardhan e711c5dcc3 [Feature] Address code review comments 2018-07-12 17:17:50 -07:00
Aditya Patwardhan 731afbf14d [Feature] Add markdown cmdlets to default commands list 2018-07-12 17:17:50 -07:00
Aditya Patwardhan a78d006ac1 Added missing error messages 2018-07-12 17:17:50 -07:00
Aditya Patwardhan 481d3b1ebf [Feature] Add more tests 2018-07-12 17:13:55 -07:00
Aditya Patwardhan 275e109202 [Feature] Address code review comments 2018-07-12 17:13:55 -07:00
Aditya Patwardhan 32876c89e7 Added Tests for Markdown cmdlets 2018-07-12 17:13:55 -07:00
Aditya Patwardhan 75ba74cce6
Merge pull request #7242 from daxian-dbw/exp
Add support to experimental features

RFC: https://github.com/PowerShell/PowerShell-RFC/pull/114

Goals:

Allow experimental features to be declared by PowerShell engine and modules.
Allow experimental features to be enabled via powershell.config.json
Allow Function, Cmdlet, parameters and parameter sets to be shown to the user or hiden from the user depending on whether the associated experimetnal feature is on or off.
Allow discover experimental features using cmdlet Get-ExperimentalFeature
2018-07-12 15:52:04 -07:00
James Truher [MSFT] d61ea03694 Make pwsh able to start in a directory with wildcards in the name (#7240) 2018-07-12 15:10:31 -07:00
Steve Lee e5e1c53084 Add test to verify filesystem provider isn't used when accessing root path in psdrive (#7173)
* add test to verify filesystem isn't used when not in filesystem drive
2018-07-11 14:10:29 -07:00
Paul Higinbotham 040c494f94 Fixes to address ThreadJob tests reliability and speed (#7270)
This change merges Jim's fixes with some more I identified that will make the tests more reliable and faster to run.

The changes add functions to wait for the desired state instead of simply waiting a specified period of time, and also speeds up running job script execution time.
2018-07-11 13:00:08 -07:00
Dongbo Wang 0ac878f72c [Feature] Address Feedback: Fix style and xml doc issues. Update tests 2018-07-10 12:46:48 -07:00
Dongbo Wang 2c9519ba3b [Feature] Address Feedback: Use better error message and add more tests 2018-07-10 02:14:59 -07:00
Dongbo Wang c7c35bdcf3 [Feature] Address Feedback: make value tuple element types explicit 2018-07-09 17:51:19 -07:00
Dongbo Wang b616cf578a [Feature] Address Feedback: style changes and fixing typo 2018-07-09 17:17:12 -07:00
Dongbo Wang 2fce1bfe56 [Feature] Root caused test failure issue and fix it 2018-07-09 10:51:57 -07:00
PRASOON KARUNAN V 9dcfddde9e Adding -AllStats Switch parameter for Measure-Object cmdlet (#7220) 2018-07-09 08:45:32 +05:00
Dongbo Wang bc8abf8efa [Feature] Fix two tests 2018-07-06 13:28:20 -07:00
Dongbo Wang d2e9151fff [Feature] Add tests for experimental feature work 2018-07-06 13:28:20 -07:00
Paul Higinbotham a57fafedc6 Add ThreadJob module package and tests (#7169) 2018-07-05 17:38:12 -07:00
Christoph Bergmeister 56e50ce632 Update 'Start-PSPester' to make it more user friendly (#7210)
- Make `Start-PSPester` call `Restore-Pester` automatically when needed,
- Make `-Path` a positional parameter for `Start-PSPester`.
2018-07-03 11:16:37 -07:00
Alex Jordan 55bbc3fcd1 Fix the name of a 'Register-EngineEvent' test (#7222) 2018-07-03 10:41:15 -07:00
Staffan Gustafsson 3c079b9d42 Add type inference for Select-Object command (#7171)
Add type inference for Select-Object command

Fixes #7170
2018-07-02 13:23:30 -07:00
Bruce Payette dbaa1add3a Methods with return type [object] should return null for an empty result (#7138) 2018-07-02 12:58:42 -07:00
Dongbo Wang 0d9a3ac832
Refactor module code related to 'Get-Module -ListAvailable' (#7145)
* The major refactoring changes are:
- In `ModuleIntrisic.cs`, remove unneeded Windows-PowerShell-only code.
- In `ModuleUtils.cs`
   - use the new API `Directory.GetDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions)` and `Directory.GetFiles(string path, string searchPattern, EnumerationOptions enumerationOptions)` to enumerate files and sub-directories within a directory path.
   - remove the unused parameter `bool force` from `GetDefaultAvailableModuleFiles(bool force, bool isForAutoDiscovery, ExecutionContext context)`
   - refactor the method `GetModuleVersionsFromAbsolutePath`. Add more comments and rename the method name.
- In `ModuleCmdletBase.cs`, refactor the method `GetModuleForNonRootedPaths` to `GetModuleForNames` to simply its implementation.
- In `PSModuleInfo.cs`
   - group the declarations of `Declared*Exports` fields together
   - rename `_detected*Exports` fields to `Detected*Exports` to group them together. They are internal fields and used outside `PSModuleInfo`.

* There is some perf improvement after this refactoring change:
- For `Get-Module -ListAvailable`, there is about 36% speed improvement for 94 default modules.
- For `Get-Module -ListAvailable -All`, there is about 14% speed improvement for totally 600 module files.
- For `Get-Module <name> -ListAvailable -List`, there is over 17x speed improvement for finding 13 modules from 600 modules. This is because we now filter names using the module file before creating a `PSMdouleInfo` object.
2018-07-02 11:00:27 -07:00
Ilya 0a3555064a Use .Net Core File.Delete() method to remove symbolic links and alternate streams (#7017)
.Net Core support processing symbolic links and alternate streams, and thus we can remove our P/Invoke code.
2018-07-01 00:08:28 -07:00
Steve Lee 3cc9d26bc2 Fix class searcher to ignore hidden properties (#7188) 2018-06-28 23:29:12 -07:00
Ilya 839ecb866f Move to dotnet core 2.1.1 (#7161) 2018-06-28 23:10:10 -07:00
Aditya Patwardhan 15f6abe944 Added functionality to retry in Invoke-RestMethod and Invoke-WebRequest. (#5760)
Added two parameters, RetryCount and RetryIntervalSec to enable retry functionality. When retrying a verbose message is sent out to inform the user.
2018-06-29 09:06:53 +05:00
Bruce Payette 1d549497cf Modified the -AsHashTable code to get the base object from the PSObject when (#7123) 2018-06-28 12:29:04 +05:00
Sergey Vasin adf267eb5f Fix second test in Send-MailMessage.Tests.ps1. (#7195) 2018-06-28 10:02:10 +05:00
Dan Travison 5e8b23e127 Allow Basic Auth over HTTPS (#6890)
* [FEATURE] Allow Basic Auth over HTTPS

* WSManTransportManager.cs: Simplify HTTPS check
Update comment in test to refer to the right exception type.

* Disable test until limi crash fo selected connection error paths is fixed

* Use Hex format for defining the expected HRESULT
2018-06-27 15:27:41 -07:00
Steve Lee 5f47fc0e8c Fix tab expansion for Get-Process on macOS (#7176)
* fix tab exapnsion for get-process on macOS

* add comment to address PR feedback
2018-06-27 12:48:42 -07:00
Robert Holt dfa1a31515 Add tests for module specifications (#7140)
* Add simple tests for module specifications

* Add comparison tests

* Add using namespace to shorten type names
2018-06-27 12:11:32 -07:00
Steve Lee 8829c01fa2 [feature] (#7101)
Revert "Set-Location should use path with wildcard characters if it exists instead of globbing (#5839)"

This reverts commit 7459b54639.
2018-06-27 10:26:37 +05:00
Steve Lee b1fbcee6d2 Fix trimming of whitespace when table is wrapped (#7184) 2018-06-27 10:24:03 +05:00
Sergey Vasin 7628f8819d Send-MailMessage: Update all parameters to support 'ValueFromPipelineByPropertyName'. (#6911) 2018-06-26 12:30:07 -07:00
Dongbo Wang 13e925e13e
Revert "Make switch statement report correct error position when it fails to evaluate the condition" (#7182)
The fix causes a problem in debugging. When stepping over the scripts in debugging mode, the debugger will stop at the switch statement condition expression twice at the very beginning -- one for evaluating the condition, and one for iterating the condition.
2018-06-26 12:24:11 -07:00
Steve Lee e8d2a6b278 Fix adding padding when right justified (#7136)
Table formatter was overly aggressive in removing padding so even right justified output (default of numbers) gets incorrectly stripped of padding. Fix is when right justified, always add padding (because it's right justified, there's never trailing whitespace).
2018-06-26 12:35:22 +05:00
Christoph Bergmeister bbd48f60e0 Add location history for Set-Location to enable 'cd -' scenario (issue #2188) (#5051)
* Implement location history feature for Set-Location.
This makes it possible to go back to the last directory using 'cd -',
which is exactly the same syntax as on Linux shells.

* Use an existing stack implementation instead of relying on an environment variable and move logic for 'cd -' into the internal class of SessionState.Path.SetLocation
Keep the (additional) setting of an environment for Unix system in case of mixed usage of cd and Set-Location to provide consistency.

* Use a bounded stack with a limit of 1000 and adapt tests.
Remove setting environment variable on Linux as discussed in PR.

* Fix test: use get-location explicitly to avoid subtle difference in the path string (e.g. an additional slash at the end)
Make syntax to .net call of environment consistent with surrounding code

* Move initialization of _workingLocationHistoryStack into constructor of SessionStateInternal and set the limit to 20 as discussed in PR 5051.

* Make new BoundedStack class in engine utils internal
2018-06-26 12:21:38 +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
Dongbo Wang c77d0ceff2
Make switch statement report correct error position when it fails to evaluate the condition (#7151) 2018-06-25 14:07:42 -07:00
Sergey Vasin ffca008726 Fix error when using Get-ChildItem c: (#7033)
* Fix error when using Get-ChildItem c:

* Fix New-Item test issue.

* Add tests for Get-ChildItem cmdlet.

* Add tests for New-Item cmdlet.

* Fix tests for New-Item cmdlet.
2018-06-25 10:15:57 -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
Steve Lee 6c9eea6390 Add back ADSI and WMI type accelerators (#7085) 2018-06-21 09:57:14 -07:00
Aditya Patwardhan d76cdc3c5c Fix New-TemporaryFile online help URI (#6608) 2018-06-20 12:15:50 -07:00
Bruce Payette 3a4c410499 Fix for #6855 - Measure-Object should handle scriptblock properties. (#6934)
Measure-Object should handle `ScriptBlock` properties. Fixed by renaming `MshExpression` to `PSPropertyExpression` and making it public. Then in `MeasureObjectCommand`, lifting it up to the parameter level. Previously the implementation exposed the Property as a string and
wrapped it internally as a `PSPropertyExpression`. Now the parameter type is `PSPropertyExpression` directly allowing for both wildcard strings and `ScriptBlock`.

`PSPropertyExpression` now lives in a public namespace where it can be used by cmdlet and script authors to easily add the same type of functionality to their commands. I also modified `PSPropertyExpression` to handle hashtables properly as objects so
         @{prop = 3} | measure-object prop
and
         @{prop = 3} | measure-object {$_.prop}
will work the same. (Previously the example using just the property name would fail.)
2018-06-20 00:23:11 -07:00
Hubert Bukowski 9ac701dbee Fix conditions for transcription of Write-Information command. (#6917)
Makes a transcription of Write-Information command consistent with $InfomrationPreference variable.
2018-06-16 21:11:21 +05:00
Dongbo Wang 9804ae5f97
Merge the v6.1.0-preview.3 release branch to master (#7060) 2018-06-13 15:59:27 -07:00
Dan Thompson ce3cb68551 Make Select-Object/ForEach-Object/Where-Object see dynamic properties (#6898)
Dynamic (DLR) objects work in some places today, but not others.  This change expands that support to ForEach-Object, Where-Object and the family of cmdlets that use 'MshExpression' (Select-Object, etc.).

This change addresses both wildcard and non-wildcard cases. In wildcard cases, it uses the existing support of generating PSDynamicMember objects for names returned by GetDynamicMemberNames.

In non-wildcard cases, a dynamic property access is attempted whether or not the name shows up in GetDynamicMemberNames, but a truly "blind" access is only attempted if we see that the base object is an IDMOP. If the dynamic access fails, you'll get the same or a similar error experience as before ("The property 'Blarg' cannot be found", or no error at all, depending on the cmdlet and the strict mode setting).

The included test coverage includes a stub for the.ForEach operator--once people are happy with this change, I can continue by adding support there.

This change should allegedly also have positive perf impact, though in actual perf testing, although it does seem ever-so-slightly faster, I found it difficult to measure much difference at all.
2018-06-12 23:48:34 -07:00
Steve Lee c2bbc2291a add additional checks for test that passes inconsistently (#7051) 2018-06-12 14:35:19 -07:00
Ilya e177fcaef6 CodeFactor code style cleanup: replace literal empty strings with 'string.Empty' (#6950) 2018-06-12 12:30:10 -07:00
Aditya Patwardhan 0d67d4dc3a Merged PR 3115: Use Directory.CreateDirectory instead of DirectoryInfo.CreateSubDirectory
Change to use Directory.CreateDirectory because of regression introduced by https://github.com/dotnet/corefx/pull/27810 in creating a subdirectory under root path.
2018-06-11 23:06:08 +00:00
Steve Lee 50d061148d Remove 'SemanticVersion' from 'knowntypes' list in serialization code to enable interop between WinPS and PSCore (#7016)
PowerShell serialization has a list of known PowerShell types. When an object is deserialized containing a known type it tries to deserialize the object to that specific type and throws an exception if it can't succeed. SemanticVersion only exists in PSCore6 so when remoting from Windows PowerShell or importing clixml generated from PSCore6 that contains SemanticVersion, it fails.

With this fix, it will be rehydrated as a "PSObject" with "Deseriealized.System.Management.Automation.SemanticVersion" in the 'TypeNames' in both Windows PowerShell and PowerShell Core.
2018-06-08 11:38:14 -07:00
Christoph Bergmeister fa544c33db Update links that contain 'en-us' culture (#7013)
Update links that contain 'en-us' culture to remove 'en-us' culture (if possible) and in some cases update to newer re-directed link to docs.microsoft.com
2018-06-08 10:49:03 +05:00
Steve Lee 92cb949cac Use PSReadLine 2.0.0-beta2 from PSGallery (#6998)
Removed building PSReadLine from the repository. Instead, change to downloading from PSGallery.
2018-06-06 09:42:19 -07:00
Dongbo Wang b20dd31398
Fix parser to continue parsing key-value pairs after an If-Statement value in a HashExpression (#7002)
After parsing `if () { }`, new lines are skipped in order to see if either `elseif` or `else` is present. When neither is present, we should resync back to the pointer before skipping those possibly available new lines, so that the new line tokens can be utilized by the subsequent parsing.
2018-06-06 09:38:05 -07:00
Christoph Bergmeister faf832401f Fix broken links due to PR 6899 that removed GitHub docs on installation docs, known issues and breaking changes due to complete migration to docs.microsoft.com (#6981)
* Fix broken installation links in README.md

* fix remaining broken links due to removal of breakingchanges and knownissues docs

* Remove en-us culture from docs links in readme

* Remove last en-us culture link from issue template
2018-06-05 19:37:14 -07:00
Klaudia Algiz cda6ef175c Remove not initialized variable $IsElevated from test in New-Item.Tests.ps1 (#6746)
* Remove not initialized variable  from PowerShell tests

* Separate the tests that requires no elevation from the others.
2018-06-05 10:26:04 -07:00
Steve Lee 5dc7a6cb07 Add Windows Compatibility Pack 2.0.0 to PS Core and adopt the official .NET Core 2.1 (#6958)
To support PowerShell modules built with .NET Windows Compatibility Pack, we decided that it was best to ship the WCP assemblies with PS Core. This also adds many new .NET APIs be default while only adding ~3.5 MB additional disk footprint (to a ~137 MB install currently).
Also update the build to adopt the official .NET Core 2.1.
2018-06-03 22:06:26 -07:00
Ilya 57b3d3380b
Cleanup FileSystem provider (#6909)
The cleanup is coming from a code review to cleanup psl. Here we clean up the side branch of the code that will allow later to clean up a branch which uses psl.
- IO.FileInfo does not make system calls in constructor. So we can create the object and then use the required attributes without direct call IO.FileInfo.GetAttributes() ( SafeGetFileAttributes() ). This allow us to exclude some p/invoke calls in our code in later cleanups. Also we get unified code for both Windows and Unix.
- Remove SafeGetFileAttributes() and WinSafeGetFileAttributes(). Currently .Net Core support file attributes on all platforms in fastest way and we can remove our workaround. We get a regression in rare case (for files like pagefile.sys). Fix is ready in CoreFX, we get it in 2.1.1. I suggest ignore the regression because this is a very-very rare situation (Get-ChildItem c:\pagefile.sys -Hidden). The .Net Core team was not even able to create an artificial test for such files and uses a real pagefile.sys file for the test. Also the enumeration is still working (dir c:\ -hidden).
- Re-add test which we lost in #4050. The test is pending because of the regression.
2018-06-04 10:00:56 +05:00
Ilya a5f77955e8
Fix xUnit test GetTempFileName (#6943)
Use Path.GetTempFileName() to get a temporary file.
2018-05-31 11:03:14 +05:00
Ilya c297eac50e
Cleanup NonWindowsGetDomainName() (#6948)
Add an optional extended description…
2018-05-31 10:18:33 +05:00
Klaudia Algiz facb228451 Remove ShouldBeErrorId custom function. (#6891) 2018-05-23 07:57:03 +05:00
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
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
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
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
Mark Kraus 0f036d9939 Enable Web Cmdlets Tests for Greater Platform Support (#6836) 2018-05-09 16:35:52 +05:00
Ilya 4737ebae20
Remove web cmdlet tests using proxy env variables (#6808) 2018-05-08 09:15:49 +05: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
Sergey Vasin 0b414f67a0 Change -Quiet parameter of Invoke-Pester to -Show None. (#6798) 2018-05-04 09:54:00 -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
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
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
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
Robert Holt 0c3f429780 Add tests for PowerShell classes inheriting from abstract .NET classes (#6752) 2018-04-30 10:17:20 -07:00
Sergey Vasin 24069241bc Fix CimCmdlets tests. (#6755) 2018-04-28 09:48:13 +05:00
Aditya Patwardhan 2c3177a08d Add tests for PowerShell hosting API to verify MyGet packages (#6737) 2018-04-27 13:25:33 -07:00
Ilya ffa7e4bac0 Enhance and refactor Add-Type cmdlet (#6141)
- Can compile a source from strings (TypeDefinition and MemberDefinition).
- Can compile from files.
- Can compile only to a file (without loading the produced assembly).
- Do not recompile and don't reload if the sources have not changed.
- Implement `-IgnoreWarnings` to not treat warnings as errors. By default, the cmdlet considers warnings as errors.
- Add VisualBasic support.
- Add new `-CompilerOptions` parameter to allow setting Roslyn command line parameters including:
    - Parser options.
    - Compile options.
    - Emit options.

**ATTENTION:** The `CompilerOptions` can be specified along with other options like `-OutputAssembly`, `-Language` and `-IgnoreWarnings`. The explicit setting parameters will take precedence over the same settings specified in `-CompileOptions`.

See docs about the compiler options:
https://github.com/dotnet/roslyn/blob/master/docs/compilers/CSharp/CommandLine.md
https://github.com/dotnet/roslyn/blob/master/docs/compilers/Visual%20Basic/CommandLine.md

**ATTENTION:** `-OutputType` default is `Library`. If `-OutputType` is absent the `-OutputType` default overlaps a value in `CompileOptions`. In other words output type ("target" ot "t" in command line) is always ignored in `CompileOptions`. We have to use `-OutputType` to set an output type.
2018-04-25 22:40:26 -07:00
Robert Holt 63c0d8d783 Add error handling for interactive #requires (#6469) 2018-04-25 18:04:04 -07:00
Klaudia Algiz 4b149e4191 Use new Pester syntax for Pester tests in module PSDesiredStateConfiguration (#6622) 2018-04-25 17:29:40 -07:00
Matthew Bobke 35d8de927b Fix New-Item to work correctly when given path is drive root and $PWD is a sub folder of the drive root. (#6600) 2018-04-25 14:32:57 -07:00
Steve Lee a9d10dda42 Fix two tests that are failing on nightly run (#6723)
- For ConsoleHosts tests, the test is validating error condition, but did not redirect stderr to stdout so the output isn't captured and thus an empty string failing the assertion.
- For SSHConnectionInfo API tests, it's calling a constructor that got overwritten with a new parameter. Fix is to put back that public API and overload it with a new one.
2018-04-24 16:25:55 -07:00
Ilya 313a8596bb
Pretty print Export-FormatData XML output (#6691)
Pretty print Export-FormatData XML output by default.
Refactor Export-FormatData tests, remove test duplications.
2018-04-24 10:04:42 +05:00
Steve Lee 942c68e796 Add '-WorkingDirectory' parameter to pwsh (#6612)
Add `-WorkingDirectory` parameter to `pwsh` to allow starting in right working directory.
2018-04-23 14:27:47 -07:00
Ilya 2da7576736
Add tests for Format-Table -Wrap (#6670) 2018-04-23 12:45:14 +05:00
Ilya 5a326135ec
Add new reliable tests for Get-Date -UFormat (#6614) 2018-04-19 13:58:29 +05:00
Paul Higinbotham 80951777cf Port Windows PowerShell AppLocker and DeviceGuard UMCI application white listing support (#6133)
These changes port Windows PowerShell support for Applocker and DeviceGuard User Mode Code Integrity (UMCI) to PSCore6. Windows PowerShell uses public APIs to determine if a system is in locked down mode via AppLocker or DeviceGuard, and automatically runs in constrained language mode. For more information about PowerShell constrained language, see: https://blogs.msdn.microsoft.com/powershell/2017/11/02/powershell-constrained-language-mode/

This support for application whitelisting has mostly existed in PSCore6, but the primary APIs were stubbed out in CorePSStub.cs because they relied on Windows only DeviceGuard (wldp.dll) and AppLocker (Safer APIs) public APIs. These changes re-implement PowerShell lock down APIs on PSCore6 for Windows platforms only. The AppLocker and DeviceGuard public APIs are currently only implemented in Windows OSes and are not supported on Linux or MacOS platforms.

Tests have also been ported to PSCore6 and run only for Windows platforms.
2018-04-17 13:09:17 -07:00
Ilya 62bb0899ac
Reformat Format-Table tests (#6657)
* Convert identations to spaces
* Remove alias tests and extra lines
* Remane extra Describe
* Remove extra parentheses and add spaces
2018-04-17 10:06:39 +05:00
Joey Aiello feb38cff70 Remove extraneous SSH and install docs from the 'demos' folder (#6628) 2018-04-13 15:50:54 -07:00
Steve Lee c2accff785 Support importing module paths that end in trailing directory separator (#6602) 2018-04-13 08:07:50 +04:00
Sergey Vasin 25dbc68b8e Fix formatting in Add-Content.Tests.ps1 file. (#6591)
* Fix formatting.
* Capitalize TestDrive and add empty strings.
2018-04-11 07:23:30 +04:00
Klaudia Algiz 3cd2308af9 Create the default PSSession configuration, not tied to a specific PowerShell version. (#6519)
Create the default PSSession configuration, not tied to a specific PowerShell version.

When Enable-PSRemoting command is run, it creates 2 sessions configurations:

first, the same as it was before with the name containing the current version expressed as: 'PowerShell.$PSVersionTable.GitCommitId'
second with the default name 'PowerShell.6' so that administrators wouldn't have to guess which specific version is installed on the target.
PR addresses the issue: #6470
2018-04-10 12:21:44 -07:00
Mark Kraus 18e6a5c654 Add Missing Start-WebListener to Web Cmdlet Tests (#6604) 2018-04-10 10:12:45 +04:00
Ilya 6bd70bc2d0
Some fixes in Get-Date -UFormat (#6542)
* Use UTC datetime in Get-Date -UFormat %s
Fix %l output from 0..11 to 1..12
Fix %V using Gregorian calendar

* Use a workaround for ISO 8601 week of year (uformat %V)
2018-04-10 08:13:19 +04:00
Sergey Vasin 3ec98bbbe8 Fix typos and formatting in Clear-Content.Tests.ps1 (#6592)
* Fix typos and formatting.
* Capitalize function parameters.
2018-04-10 07:47:39 +04:00
Sergey Vasin a3e8929d6a Fix formatting Clear-EventLog.Tests.ps1 (#6594) 2018-04-10 07:17:52 +04:00
Sergey Vasin ca5aacca16 Fix formatting in Clear-Item.Tests.ps1. (#6593) 2018-04-09 16:24:01 +04:00
Sergey Vasin 9d3c2633e7 Fix formatting in Convert-Path.Tests.ps1. (#6595) 2018-04-09 16:22:45 +04:00
Sergey Vasin 1f7b3a65d3 Fix Copy.Item.Tests.ps1 (#6596)
Fix formatting, absent parameter names and use -Throw and -ErrorID parameters with Should function.
2018-04-09 16:21:47 +04:00
Florian Feldhaus 94c8ce007d Added check for existence of Location HTTP header before using it (#6560)
The HTTP RFC (https://tools.ietf.org/html/rfc7231#section-6.4) does not require a Location header to be present for redirects, thus it is required to check if the Location header is returned before using it.
2018-04-08 16:51:17 +04:00
Sergey Vasin 4554679a08 Use -Throw and -ErrorId native Pester parameters. (#6574) 2018-04-06 16:15:37 +04:00
Dongbo Wang e0b1f1f3af
Fix line ending in 'DefaultCommands.Tests.ps1' from CRLF to LF (#6553) 2018-04-03 13:32:16 -07:00
Ilya 24cf020442 Add ported Test-Connection cmdlet (#5328)
The Test-Connection cmdlet works on Windows and Unix.

Implemented:
Ping
Continues Ping
Traceroute
Detect MTU size (seems don't work on Unix because of .Net Core issue)
Connect to TCP port
Not jet implemented:
I'm putting this off for the future.

Detect blackhole routers
PingPath
Additional considerations
As you can see in the tests .Net Core has issues in API implementation. As a result, some tests are skipped on Unix. There is also one issue on Windows. Related comments added to tests.
I'm going to open an issue(s) in CoreFX repo.

I think we should break the feedback into two parts:

scripting functionality
interactive functionality (display output)
Now I have implemented the output to the screen as the progress bar and as text (without ETS) - we have to decide what is best to use.
2018-04-03 11:59:26 -07:00
Takuya Shibata cd1d2d2063 Fix error when 'Format-Wide -AutoSize | Out-String' is called. (#6491)
* Add checking if an output width is specified.

* change _failedToReadConsoleWidth variable to _noConsole bool value. 
This variable is to cache the default console width when failed to get 'Console.WindowWidth' value.
2018-04-03 11:17:05 -07:00