From 92f802b87f34703f5c3a2c52d0476dd75c40f9d7 Mon Sep 17 00:00:00 2001 From: "Dan Thompson (SBS)" Date: Tue, 17 Sep 2019 04:44:03 -0700 Subject: [PATCH] Tweak help formatting script to be more StrictMode tolerant StrictMode is disabled in at least one other script block in the help formatting. This change just adds another. Addresses #10562 Turns out that just this one little addition of `Set-StrictMode -Off` fixed the errors for my particular case. (It is possible there are other ways to underspecify MAML, that would require more, similar changes, but this looks like enough for me for now.) --- .../FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs index bf3205a8372..0dcf30c4ccc 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs @@ -139,7 +139,8 @@ internal static IEnumerable GetFormatData() var MamlParameterControl = CustomControl.Create() .StartEntry() .AddScriptBlockExpressionBinding( -@"$optional = $_.required -ne 'true' +@"Set-StrictMode -Off +$optional = $_.required -ne 'true' $positional = (($_.position -ne $()) -and ($_.position -ne '') -and ($_.position -notmatch 'named') -and ([int]$_.position -ne $())) $parameterValue = if ($null -ne $_.psobject.Members['ParameterValueGroup']) { "" {$($_.ParameterValueGroup.ParameterValue -join ' | ')}""