From 297e5a0d2361a4626655bbb26806012fd9d1a685 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 7 Aug 2019 09:23:02 -0700 Subject: [PATCH 1/2] Expose PreRelease label in PSModuleInfo and ModuleInfoGrouping formatter --- .../PowerShellCore_format_ps1xml.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 38d4fe125ce..aa0260eadaa 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -355,7 +355,7 @@ private static IEnumerable ViewsOf_Microsoft_PowerShell_Co } elseif ($_.Duration.TotalMinutes -ge 1) { $formatString = ""m\:ss\.fff"" - } + } else { $formatString = ""s\.fff"" } @@ -1224,12 +1224,18 @@ private static IEnumerable ViewsOf_ModuleInfoGrouping(Cust .GroupByScriptBlock("Split-Path -Parent $_.Path | ForEach-Object { if([Version]::TryParse((Split-Path $_ -Leaf), [ref]$null)) { Split-Path -Parent $_} else {$_} } | Split-Path -Parent", customControl: sharedControls[0]) .AddHeader(Alignment.Left, width: 10) .AddHeader(Alignment.Left, width: 10) + .AddHeader(Alignment.Left, label: "PreRelease", width: 10) .AddHeader(Alignment.Left, width: 35) .AddHeader(Alignment.Left, width: 9, label: "PSEdition") .AddHeader(Alignment.Left, label: "ExportedCommands") .StartRowDefinition() .AddPropertyColumn("ModuleType") .AddPropertyColumn("Version") + .AddScriptBlockColumn(@" + if ($_.PrivateData -and $_.PrivateData.PSData) + { + $_.PrivateData.PSData.PreRelease + }") .AddPropertyColumn("Name") .AddScriptBlockColumn(@" $result = [System.Collections.ArrayList]::new() @@ -1256,11 +1262,17 @@ private static IEnumerable ViewsOf_System_Management_Autom TableControl.Create() .AddHeader(Alignment.Left, width: 10) .AddHeader(Alignment.Left, width: 10) + .AddHeader(Alignment.Left, label: "PreRelease", width: 10) .AddHeader(Alignment.Left, width: 35) .AddHeader(Alignment.Left, label: "ExportedCommands") .StartRowDefinition() .AddPropertyColumn("ModuleType") .AddPropertyColumn("Version") + .AddScriptBlockColumn(@" + if ($_.PrivateData -and $_.PrivateData.PSData) + { + $_.PrivateData.PSData.PreRelease + }") .AddPropertyColumn("Name") .AddScriptBlockColumn("$_.ExportedCommands.Keys") .EndRowDefinition() @@ -1279,6 +1291,11 @@ private static IEnumerable ViewsOf_System_Management_Autom .AddItemProperty(@"Description") .AddItemProperty(@"ModuleType") .AddItemProperty(@"Version") + .AddItemScriptBlock(@" + if ($_.PrivateData -and $_.PrivateData.PSData) + { + $_.PrivateData.PSData.PreRelease + }", label: "PreRelease") .AddItemProperty(@"NestedModules") .AddItemScriptBlock(@"$_.ExportedFunctions.Keys", label: "ExportedFunctions") .AddItemScriptBlock(@"$_.ExportedCmdlets.Keys", label: "ExportedCmdlets") From f2fbd3cb8328009d4cd909b3b505f094b113294a Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 7 Aug 2019 09:33:14 -0700 Subject: [PATCH 2/2] address CodeFactor issues --- .../DefaultFormatters/PowerShellCore_format_ps1xml.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 aa0260eadaa..35d34c60670 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -1291,11 +1291,13 @@ private static IEnumerable ViewsOf_System_Management_Autom .AddItemProperty(@"Description") .AddItemProperty(@"ModuleType") .AddItemProperty(@"Version") - .AddItemScriptBlock(@" + .AddItemScriptBlock( + @" if ($_.PrivateData -and $_.PrivateData.PSData) { $_.PrivateData.PSData.PreRelease - }", label: "PreRelease") + }", + label: "PreRelease") .AddItemProperty(@"NestedModules") .AddItemScriptBlock(@"$_.ExportedFunctions.Keys", label: "ExportedFunctions") .AddItemScriptBlock(@"$_.ExportedCmdlets.Keys", label: "ExportedCmdlets")