Allow dynamic parameter to be returned even if path matches nothing (#7957)
This commit is contained in:
parent
f1e2136a2b
commit
4e5e3900f6
|
@ -275,13 +275,7 @@ namespace System.Management.Automation
|
|||
out provider,
|
||||
out providerInstance);
|
||||
|
||||
if (providerPaths.Count > 0)
|
||||
{
|
||||
// Get the dynamic parameters for the first resolved path
|
||||
|
||||
return GetContentReaderDynamicParameters(providerInstance, providerPaths[0], newContext);
|
||||
}
|
||||
return null;
|
||||
return GetContentReaderDynamicParameters(providerInstance, path, newContext);
|
||||
} // GetContentReaderDynamicParameters
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -278,6 +278,15 @@ baz
|
|||
} | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.GetContentCommand"
|
||||
}
|
||||
|
||||
It "Should throw ItemNotFound when path matches no files with <variation>" -TestCases @(
|
||||
@{ variation = "no additional parameters"; params = @{} },
|
||||
@{ variation = "dynamic parameter" ; params = @{ Raw = $true }}
|
||||
) {
|
||||
param($params)
|
||||
|
||||
{ Get-Content -Path "/DoesNotExist*.txt" @params -ErrorAction Stop } | Should -Throw -ErrorId "ItemNotFound,Microsoft.PowerShell.Commands.GetContentCommand"
|
||||
}
|
||||
|
||||
Context "Check Get-Content containing multi-byte chars" {
|
||||
BeforeAll {
|
||||
$firstLine = "Hello,World"
|
||||
|
|
Loading…
Reference in a new issue