Fix default formatting for deserialized MatchInfo (#11728)

MatchInfo class has ToEmphasizedString() member method to color output line.
In remote scenario MatchInfo class is deserialized as Deserialized.Microsoft.PowerShell.Commands.MatchInfo without the method. As result default formating in remote scenario show nothing.

The fix is to directly output Line property.
This commit is contained in:
Ilya 2020-03-18 18:43:01 +05:00 committed by GitHub
parent 8ebff6a2a4
commit 43e0e1a1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,10 @@ namespace System.Management.Automation.Runspaces
"Microsoft.PowerShell.Commands.MatchInfo",
ViewsOf_Microsoft_PowerShell_Commands_MatchInfo());
yield return new ExtendedTypeDefinition(
"Deserialized.Microsoft.PowerShell.Commands.MatchInfo",
ViewsOf_Deserialized_Microsoft_PowerShell_Commands_MatchInfo());
yield return new ExtendedTypeDefinition(
"System.Management.Automation.PSVariable",
ViewsOf_System_Management_Automation_PSVariable());
@ -382,6 +386,16 @@ namespace System.Management.Automation.Runspaces
.EndControl());
}
private static IEnumerable<FormatViewDefinition> ViewsOf_Deserialized_Microsoft_PowerShell_Commands_MatchInfo()
{
yield return new FormatViewDefinition("MatchInfo",
CustomControl.Create()
.StartEntry()
.AddScriptBlockExpressionBinding(@"$_.Line")
.EndEntry()
.EndControl());
}
private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Automation_PSVariable()
{
yield return new FormatViewDefinition("Variable",