diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2022-09-13 08:03:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 08:03:24 +0300 |
commit | ac95793f95094c2c7729db3d6b21450c9a2d26fe (patch) | |
tree | 815283fbd437c59c57dd8cc2bae4bb4d018e3652 | |
parent | 7627e999a7908d98bebb95ef72170b61293b8d7a (diff) |
[release/v7.3.0-rc.1] Make experimental feature `PSAnsiRenderingFileInfo` stable (#18078)
5 files changed, 22 insertions, 51 deletions
diff --git a/experimental-feature-linux.json b/experimental-feature-linux.json index 561e7b46c4..5484450a76 100644 --- a/experimental-feature-linux.json +++ b/experimental-feature-linux.json @@ -1,6 +1,5 @@ [ "PSAMSIMethodInvocationLogging", - "PSAnsiRenderingFileInfo", "PSCleanBlock", "PSCommandNotFoundSuggestion", "PSExec", diff --git a/experimental-feature-windows.json b/experimental-feature-windows.json index 561e7b46c4..5484450a76 100644 --- a/experimental-feature-windows.json +++ b/experimental-feature-windows.json @@ -1,6 +1,5 @@ [ "PSAMSIMethodInvocationLogging", - "PSAnsiRenderingFileInfo", "PSCleanBlock", "PSCommandNotFoundSuggestion", "PSExec", diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index 524d21d896..d656d577d9 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -122,9 +122,6 @@ namespace System.Management.Automation name: "PSLoadAssemblyFromNativeCode", description: "Expose an API to allow assembly loading from native code"), new ExperimentalFeature( - name: "PSAnsiRenderingFileInfo", - description: "Enable coloring for FileInfo objects"), - new ExperimentalFeature( name: PSNativeCommandErrorActionPreferenceFeatureName, description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"), new ExperimentalFeature( diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 3c0aeaddc7..07625fc2ab 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -2068,43 +2068,32 @@ namespace Microsoft.PowerShell.Commands /// <returns>Name if a file or directory, Name -> Target if symlink.</returns> public static string NameString(PSObject instance) { - if (ExperimentalFeature.IsEnabled("PSAnsiRenderingFileInfo")) + if (instance?.BaseObject is FileSystemInfo fileInfo) { - if (instance?.BaseObject is FileSystemInfo fileInfo) + if (InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo)) { - if (InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo)) - { - return $"{PSStyle.Instance.FileInfo.SymbolicLink}{fileInfo.Name}{PSStyle.Instance.Reset} -> {fileInfo.LinkTarget}"; - } - else if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) - { - return $"{PSStyle.Instance.FileInfo.Directory}{fileInfo.Name}{PSStyle.Instance.Reset}"; - } - else if (PSStyle.Instance.FileInfo.Extension.ContainsKey(fileInfo.Extension)) - { - return $"{PSStyle.Instance.FileInfo.Extension[fileInfo.Extension]}{fileInfo.Name}{PSStyle.Instance.Reset}"; - } - else if ((Platform.IsWindows && CommandDiscovery.PathExtensions.Contains(fileInfo.Extension.ToLower())) || - (!Platform.IsWindows && Platform.NonWindowsIsExecutable(fileInfo.FullName))) - { - return $"{PSStyle.Instance.FileInfo.Executable}{fileInfo.Name}{PSStyle.Instance.Reset}"; - } - else - { - return fileInfo.Name; - } + return $"{PSStyle.Instance.FileInfo.SymbolicLink}{fileInfo.Name}{PSStyle.Instance.Reset} -> {fileInfo.LinkTarget}"; + } + else if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) + { + return $"{PSStyle.Instance.FileInfo.Directory}{fileInfo.Name}{PSStyle.Instance.Reset}"; + } + else if (PSStyle.Instance.FileInfo.Extension.ContainsKey(fileInfo.Extension)) + { + return $"{PSStyle.Instance.FileInfo.Extension[fileInfo.Extension]}{fileInfo.Name}{PSStyle.Instance.Reset}"; + } + else if ((Platform.IsWindows && CommandDiscovery.PathExtensions.Contains(fileInfo.Extension.ToLower())) || + (!Platform.IsWindows && Platform.NonWindowsIsExecutable(fileInfo.FullName))) + { + return $"{PSStyle.Instance.FileInfo.Executable}{fileInfo.Name}{PSStyle.Instance.Reset}"; + } + else + { + return fileInfo.Name; } - - return string.Empty; - } - else - { - return instance?.BaseObject is FileSystemInfo fileInfo - ? InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo) - ? $"{fileInfo.Name} -> {fileInfo.LinkTarget}" - : fileInfo.Name - : string.Empty; } + + return string.Empty; } /// <summary> diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Item.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Item.Tests.ps1 index 35c05b1bb1..4efc250e0d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Item.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Item.Tests.ps1 @@ -208,17 +208,12 @@ Describe "Get-Item environment provider on Windows with accidental case-variant Describe 'Formatting for FileInfo objects' -Tags 'CI' { BeforeAll { - $PSDefaultParameterValues.Add('It:Skip', (-not $EnabledExperimentalFeatures.Contains('PSAnsiRenderingFileInfo'))) $extensionTests = [System.Collections.Generic.List[HashTable]]::new() foreach ($extension in @('.zip', '.tgz', '.tar', '.gz', '.nupkg', '.cab', '.7z', '.ps1', '.psd1', '.psm1', '.ps1xml')) { $extensionTests.Add(@{extension = $extension}) } } - AfterAll { - $PSDefaultParameterValues.Remove('It:Skip') - } - It 'File type <extension> should have correct color' -TestCases $extensionTests { param($extension) @@ -250,14 +245,6 @@ Describe 'Formatting for FileInfo objects' -Tags 'CI' { } Describe 'Formatting for FileInfo requiring admin' -Tags 'CI','RequireAdminOnWindows' { - BeforeAll { - $PSDefaultParameterValues.Add('It:Skip', (-not $EnabledExperimentalFeatures.Contains('PSAnsiRenderingFileInfo'))) - } - - AfterAll { - $PSDefaultParameterValues.Remove('It:Skip') - } - It 'Symlink should have correct color' { $linkPath = Join-Path -Path $TestDrive -ChildPath 'link' $link = New-Item -ItemType SymbolicLink -Name 'link' -Value $TestDrive -Path $TestDrive |