diff --git a/.pipelines/store/PDPs/PDP/fr/PDP.xml b/.pipelines/store/PDPs/PDP/fr/PDP.xml index 3074bf897ea..c3015b3965c 100644 --- a/.pipelines/store/PDPs/PDP/fr/PDP.xml +++ b/.pipelines/store/PDPs/PDP/fr/PDP.xml @@ -44,9 +44,9 @@ PowerShell est open source. Voir https://github.com/powershell/powershell - Version: ___VERSION___ + Version : ___VERSION___ -Changelog: ___CHANGELOGLINK___ +Journal des modifications : ___CHANGELOGLINK___ diff --git a/.pipelines/store/PDPs/PDP/ko/PDP.xml b/.pipelines/store/PDPs/PDP/ko/PDP.xml index ab355ca6368..b5be262bd92 100644 --- a/.pipelines/store/PDPs/PDP/ko/PDP.xml +++ b/.pipelines/store/PDPs/PDP/ko/PDP.xml @@ -44,9 +44,9 @@ PowerShell이 오픈 소스로 제공됨. See https://github.com/powershell/pow - Version: ___VERSION___ + 버전: ___VERSION___ -Changelog: ___CHANGELOGLINK___ +변경 로그: ___CHANGELOGLINK___ diff --git a/build.psm1 b/build.psm1 index 774ea66ee97..1c9a602e5c1 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2778,65 +2778,30 @@ function Install-Dotnet { Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet $installScript = "dotnet-install.ps1" Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript - if (-not $environment.IsCoreCLR) { - $installArgs = @{} - if ($Version) { - $installArgs += @{ Version = $Version } - } elseif ($Channel) { - $installArgs += @{ Quality = $Quality } - $installArgs += @{ Channel = $Channel } - } - - if ($InstallDir) { - $installArgs += @{ InstallDir = $InstallDir } - } - - if ($AzureFeed) { - $installArgs += @{AzureFeed = $AzureFeed} - } - - if ($FeedCredential) { - $installArgs += @{FeedCredential = $FeedCredential} - } - - $installArgs += @{ SkipNonVersionedFiles = $true } - - $installArgs | Out-String | Write-Verbose -Verbose - & ./$installScript @installArgs + $installArgs = @{} + if ($Version) { + $installArgs.Version = $Version + } + elseif ($Channel) { + $installArgs.Channel = $Channel + $installArgs.Quality = $Quality } - else { - # dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell - $fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe" - $fullDotnetInstallPath = Join-Path -Path (Convert-Path -Path $PWD.Path) -ChildPath $installScript - - if ($Version) { - $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version) - } - elseif ($Channel) { - $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality) - } - - if ($InstallDir) { - $psArgs += @('-InstallDir', $InstallDir) - } - if ($AzureFeed) { - $psArgs += @('-AzureFeed', $AzureFeed) - } + if ($InstallDir) { + $installArgs.InstallDir = $InstallDir + } - if ($FeedCredential) { - $psArgs += @('-FeedCredential', $FeedCredential) - } + if ($AzureFeed) { + $installArgs.AzureFeed = $AzureFeed + } - $psArgs += @('-SkipNonVersionedFiles') + if ($FeedCredential) { + $installArgs.FeedCredential = $FeedCredential + } - # Removing the verbose message to not expose the secret - # $psArgs -join ' ' | Write-Verbose -Verbose + $installArgs.SkipNonVersionedFiles = $true - Start-NativeExecution { - & $fullPSPath @psArgs - } - } + & ./$installScript @installArgs } Write-LogGroupEnd -Title "Install .NET SDK $Version" } diff --git a/src/Microsoft.Management.UI.Internal/resources/public.InvariantResources.resx b/src/Microsoft.Management.UI.Internal/resources/public.InvariantResources.resx index 64c8e33ccde..088b1667c72 100644 --- a/src/Microsoft.Management.UI.Internal/resources/public.InvariantResources.resx +++ b/src/Microsoft.Management.UI.Internal/resources/public.InvariantResources.resx @@ -122,6 +122,7 @@ Columns + {StrContains="Columns"} {0:G} @@ -141,8 +142,10 @@ {0} does not support adding to the Items collection, use {1} instead. + {StrContains="Items"} If View is set to a {0}, it should have the type {1}. + {StrContains="View"} diff --git a/src/Microsoft.Management.UI.Internal/resources/public.UICultureResources.resx b/src/Microsoft.Management.UI.Internal/resources/public.UICultureResources.resx index de8b07134e2..8e390bba946 100644 --- a/src/Microsoft.Management.UI.Internal/resources/public.UICultureResources.resx +++ b/src/Microsoft.Management.UI.Internal/resources/public.UICultureResources.resx @@ -205,26 +205,34 @@ Ctrl+Add + {StrContains="Ctrl+Add"} Ctrl+Shift+Add + {StrContains="Ctrl+Shift+Add"} Ctrl+Plus + {StrContains="Ctrl+Plus"} Ctrl+Shift+Plus + {StrContains="Ctrl+Shift+Plus"} Ctrl+Subtract + {StrContains="Ctrl+Subtract"} Ctrl+Shift+Subtract + {StrContains="Ctrl+Shift+Subtract"} Ctrl+Minus + {StrContains="Ctrl+Minus"} Ctrl+Shift+Minus + {StrContains="Ctrl+Shift+Minus"} diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs index 24d99d4dd4b..9feb5cbbf73 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -2157,6 +2157,7 @@ private static IEnumerable ViewsOf_System_Management_Autom .AddItemScriptBlock(@"""$($_.StrikethroughOff)$($_.StrikethroughOff.Replace(""""`e"""",'`e'))$($_.Reset)""", label: "StrikethroughOff") .AddItemScriptBlock(@"""$($_.Strikethrough)$($_.Strikethrough.Replace(""""`e"""",'`e'))$($_.Reset)""", label: "Strikethrough") .AddItemProperty(@"OutputRendering") + .AddItemProperty(@"AutoSizeDefaultFormatting") .AddItemScriptBlock(@"""$($_.Formatting.FormatAccent)$($_.Formatting.FormatAccent.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Formatting.FormatAccent") .AddItemScriptBlock(@"""$($_.Formatting.ErrorAccent)$($_.Formatting.ErrorAccent.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Formatting.ErrorAccent") .AddItemScriptBlock(@"""$($_.Formatting.Error)$($_.Formatting.Error.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Formatting.Error") diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs index 963b5a0f88b..38daef9cb6d 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs @@ -135,6 +135,12 @@ private void InitializeGroupBy() private void InitializeAutoSize() { + // Only Table and Wide views support autosize. + if (this is not (TableViewGenerator or WideViewGenerator)) + { + return; + } + // check the autosize flag first if (parameters != null && parameters.autosize.HasValue) { diff --git a/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs b/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs index 534f9541195..0c3f88040bf 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs @@ -641,6 +641,11 @@ public FileInfoFormatting() /// public OutputRendering OutputRendering { get; set; } = OutputRendering.Host; + /// + /// Gets or sets whether to force the default implicit formatting to use 'AutoSize'. + /// + public bool AutoSizeDefaultFormatting { get; set; } + /// /// Gets value to turn off all attributes. /// diff --git a/src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs b/src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs index 7d7a993d539..a33272a3a26 100644 --- a/src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs +++ b/src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs @@ -20,5 +20,20 @@ public FormatDefaultCommand() { this.implementation = new InnerFormatShapeCommand(FormatShape.Undefined); } + + /// + /// Hook up the AutoSize override, if requested, before handing off to the + /// implementation. + /// + protected override void BeginProcessing() + { + if (PSStyle.Instance.AutoSizeDefaultFormatting) + { + var parameters = new FormattingCommandLineParameters { autosize = true }; + ((InnerFormatShapeCommand)this.implementation).SetCommandLineParameters(parameters); + } + + base.BeginProcessing(); + } } } diff --git a/src/System.Management.Automation/resources/fr/FileSystemProviderStrings.fr.resx b/src/System.Management.Automation/resources/fr/FileSystemProviderStrings.fr.resx index 2460d1ad58f..c06a3429fb4 100644 --- a/src/System.Management.Automation/resources/fr/FileSystemProviderStrings.fr.resx +++ b/src/System.Management.Automation/resources/fr/FileSystemProviderStrings.fr.resx @@ -241,13 +241,13 @@ Impossible de traiter le chemin d’accès « {0} », car la cible représente un nom d’appareil réservé. - Cannot process the remote directory name '{0}' because it may result in path traversal. + Impossible de traiter le nom de répertoire distant «{0}», car cela peut entraîner une traversée de chemin d’accès. - Cannot process the remote file name '{0}' because it may result in path traversal. + Impossible de traiter le nom de fichier distant «{0}», car cela peut entraîner une traversée de chemin d’accès. - Cannot process the remote Alternate Data Stream name '{0}' because it may result in path traversal. + Impossible de traiter le nom de flux de données alternatif distant « {0} » car cela pourrait entraîner un parcours de chemin d'accès (path traversal). L’encodage n’est pas utilisé quand « -AsByteStream » est spécifié. diff --git a/src/System.Management.Automation/resources/ko/FileSystemProviderStrings.ko.resx b/src/System.Management.Automation/resources/ko/FileSystemProviderStrings.ko.resx index 01252724b58..353cfe26366 100644 --- a/src/System.Management.Automation/resources/ko/FileSystemProviderStrings.ko.resx +++ b/src/System.Management.Automation/resources/ko/FileSystemProviderStrings.ko.resx @@ -241,13 +241,13 @@ 대상이 예약된 디바이스 이름을 나타내므로 경로 '{0}'을(를) 처리할 수 없습니다. - Cannot process the remote directory name '{0}' because it may result in path traversal. + 경로 통과가 발생할 수 있으므로 원격 디렉터리 이름 '{0}'을(를) 처리할 수 없습니다. - Cannot process the remote file name '{0}' because it may result in path traversal. + 경로 통과가 발생할 수 있으므로 원격 파일 이름 '{0}'을(를) 처리할 수 없습니다. - Cannot process the remote Alternate Data Stream name '{0}' because it may result in path traversal. + 경로 통과가 발생할 수 있으므로 원격 대체 데이터 스트림 이름 '{0}'을(를) 처리할 수 없습니다. '-AsByteStream'이 지정되면 인코딩은 사용되지 않습니다. diff --git a/test/powershell/engine/Formatting/PSStyle.Tests.ps1 b/test/powershell/engine/Formatting/PSStyle.Tests.ps1 index 18baed17dd2..fd91e3f4146 100644 --- a/test/powershell/engine/Formatting/PSStyle.Tests.ps1 +++ b/test/powershell/engine/Formatting/PSStyle.Tests.ps1 @@ -89,6 +89,10 @@ Describe 'Tests for $PSStyle automatic variable' -Tag 'CI' { $PSStyle.OutputRendering | Should -BeExactly 'Host' } + It '$PSStyle default view includes AutoSizeDefaultFormatting' { + $PSStyle | Out-String | Should -Match 'AutoSizeDefaultFormatting' + } + It '$PSStyle has correct defaults for style ' -TestCases (Get-TestCases $styleDefaults) { param($key, $value) @@ -603,3 +607,166 @@ Billy Bob… Senior DevOps … 13 $text.Trim().Replace("`r", "") | Should -BeExactly $expected.Replace("`r", "") } } + +Describe 'Default formatting AutoSize override' -Tag 'CI' { + BeforeAll { + $formatFile = Join-Path $TestDrive 'AutoSizeDefaultFormatting.format.ps1xml' + @' + + + + AutoSizeWide + + Test.AutoSizeWide + + + + + + Name + + + + + + + AutoSizeComplex + + Test.AutoSizeComplex + + + + + + Item + + + + + + + + +'@ | Set-Content -Path $formatFile + } + + It "Forces default table formatting to use 'AutoSize'" { + $oldOutputRendering = $PSStyle.OutputRendering + $oldAutoSizeDefaultFormatting = $PSStyle.AutoSizeDefaultFormatting + + try { + $PSStyle.OutputRendering = 'PlainText' + $PSStyle.AutoSizeDefaultFormatting = $false + $defaultOutput = Get-Command Import-Module | Out-String + $PSStyle.AutoSizeDefaultFormatting = $true + $autoSizedOutput = Get-Command Import-Module | Out-String + + $defaultOutput = $defaultOutput.Trim().Split("`n") + $autoSizedOutput = $autoSizedOutput.Trim().Split("`n") + + $defaultOutput.Count | Should -BeExactly $autoSizedOutput.Count + for ($i = 0; $i -lt $defaultOutput.Count; $i++) { + $defaultOutput[$i].Length | Should -BeGreaterThan $autoSizedOutput[$i].Length + $elements_1 = $defaultOutput[$i].Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + $elements_2 = $autoSizedOutput[$i].Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + $elements_1 -join ' ' | Should -BeExactly ($elements_2 -join ' ') + } + } + finally { + $PSStyle.AutoSizeDefaultFormatting = $oldAutoSizeDefaultFormatting + $PSStyle.OutputRendering = $oldOutputRendering + } + } + + It "Forces default wide formatting to use 'AutoSize'" { + $powerShell = [PowerShell]::Create() + + try { + $result = $powerShell.AddScript({ + param($Path) + + Update-FormatData -PrependPath $Path + $oldOutputRendering = $PSStyle.OutputRendering + $oldAutoSizeDefaultFormatting = $PSStyle.AutoSizeDefaultFormatting + + try { + $PSStyle.OutputRendering = 'PlainText' + $items = 1..6 | ForEach-Object { + [pscustomobject]@{ PSTypeName = 'Test.AutoSizeWide'; Name = "Item$_" } + } + + $PSStyle.AutoSizeDefaultFormatting = $false + $defaultOutput = $items | Out-String -Width 40 + $PSStyle.AutoSizeDefaultFormatting = $true + $autoSizedOutput = $items | Out-String -Width 40 + + [pscustomobject]@{ + DefaultOutput = $defaultOutput + AutoSizedOutput = $autoSizedOutput + } + } + finally { + $PSStyle.AutoSizeDefaultFormatting = $oldAutoSizeDefaultFormatting + $PSStyle.OutputRendering = $oldOutputRendering + } + }).AddArgument($formatFile).Invoke() + + $powerShell.HadErrors | Should -BeFalse + $defaultLines = $result.DefaultOutput.Trim().Split("`n") + $autoSizedLines = $result.AutoSizedOutput.Trim().Split("`n") + $defaultLines | Should -HaveCount 3 + $autoSizedLines | Should -HaveCount 1 + $autoSizedLines[0].Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) | Should -HaveCount 6 + } + finally { + $powerShell.Dispose() + } + } + + It 'Does not buffer default formatting until pipeline completion' -TestCases @( + @{ ViewType = 'List' } + @{ ViewType = 'Complex' } + ) { + param($ViewType) + + $powerShell = [PowerShell]::Create() + + try { + $producerFinished = $powerShell.AddScript({ + param($Path, $ViewType) + + Update-FormatData -PrependPath $Path + $oldAutoSizeDefaultFormatting = $PSStyle.AutoSizeDefaultFormatting + + try { + $PSStyle.AutoSizeDefaultFormatting = $true + $inputObject = $ViewType -eq 'List' ? $PSStyle : [pscustomobject]@{ PSTypeName = 'Test.AutoSizeComplex'; Name = 'Item' } + + $script:producerFinished = $false + & { + $inputObject + $script:producerFinished = $true + } | + Out-String -Stream | + Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ## Ignore the newline written out by 'Out-String' + Select-Object -First 1 | + Out-Null + + $script:producerFinished + } + finally { + $PSStyle.AutoSizeDefaultFormatting = $oldAutoSizeDefaultFormatting + } + }).AddArgument($formatFile).AddArgument($ViewType).Invoke() + + $powerShell.HadErrors | Should -BeFalse + # When rendering streams, the first non-whitespace string reaches 'Select-Object' before '$script:producerFinished = $true' runs. 'Select-Object -First 1' then stops + # the upstream script, so that assignment is never evaluated and '$producerFinished' remains false. + # If rendering is buffered, 'Out-String' emits no non-whitespace payload until the upstream script finishes and the assignment runs, making '$producerFinished' true. + $producerFinished | Should -BeFalse + } + finally { + $powerShell.Dispose() + } + } +}