Skip to content

Commit

Permalink
Formatting: handle "calculated properties" in Format-AltTable, -AltList
Browse files Browse the repository at this point in the history
Also allow multi-line property values in Format-List, though wrapping a la
the built-in Format-List is not done.
  • Loading branch information
jazzdelightsme committed Apr 13, 2019
1 parent d97f796 commit f651cf1
Show file tree
Hide file tree
Showing 17 changed files with 1,026 additions and 165 deletions.
2 changes: 2 additions & 0 deletions DbgProvider/AfeProxies/FormatProxy.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function PROXY_NAME
{
$useSuppliedView = $true
}
VIEW_FROM_PROPERTY_STUFF_BEGIN
}
catch
{
Expand Down Expand Up @@ -160,6 +161,7 @@ function PROXY_NAME
{
${_formatInfo} = $FormatInfo
}
VIEW_FROM_PROPERTY_STUFF_PROCESS
else
{
${_formatInfo} = Get-AltFormatViewDef -ForObject $objToDealWith `
Expand Down
76 changes: 73 additions & 3 deletions DbgProvider/AfeProxies/generateProxies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,59 @@ function DoReplacements( [string] $inputFile, [string] $outputFile, [hashtable]
{
try
{
$viewFromPropertySupported_BeginStuff = @'
elseif( $Property )
{
# If there are no wildcards, we can just create the view now and not have
# to reevaluate for every object.
[bool] $hasWildcards = $false
foreach( $propThing in $Property )
{
if( ($propThing -is [string]) -and
[System.Management.Automation.WildcardPattern]::ContainsWildcardCharacters( $propThing ) )
{
$hasWildcards = $true
break
}
}
if( !$hasWildcards )
{
$FormatInfo = VIEW_FROM_PROPERTY_COMMAND -FromProperty $Property
$useSuppliedView = $true
}
}
'@

$viewFromPropertySupported_ProcessStuff = @'
elseif( $Property -and !$__UseBuiltinFormattingForPropertyViews )
{
$maybeNewView = VIEW_FROM_PROPERTY_COMMAND `
-FromProperty $Property `
-InputObject $objToDealWith
if( ($null -eq CURRENT_VIEW_DEF) -or
!CURRENT_VIEW_DEF.LooksLikeExistingFromPropertyDefinition( $maybeNewView) )
{
${_formatInfo} = $maybeNewView
}
else
{
${_formatInfo} = CURRENT_VIEW_DEF
}
}
'@

$viewFromPropertyNotSupported_ProcessStuff = @'
elseif( $Property )
{
# The corresponding alternate formatting engine command does not
# [currently] support generating a view from -Property. We'll leave
# $_formatInfo null so that the built-in formatting command will be
# used.
}
'@

Write-Host "Creating $($outputFile)..." -Fore Cyan
if( Test-Path $outputFile )
{
Expand All @@ -39,6 +92,23 @@ function DoReplacements( [string] $inputFile, [string] $outputFile, [hashtable]
$repl[ 'OUT_WRAPPED_COMMAND' ] = "`$private:out$($baseInfo[ 'PROXY_SHAPE' ])WrappedCmd"
$repl[ 'OUT_SCRIPT_COMMAND' ] = "`$private:out$($baseInfo[ 'PROXY_SHAPE' ])ScriptCmd"

if( $baseInfo[ 'ViewFromPropertyCmd' ] )
{
$repl[ 'VIEW_FROM_PROPERTY_STUFF_BEGIN' ] =
$viewFromPropertySupported_BeginStuff.Replace( 'VIEW_FROM_PROPERTY_COMMAND',
$baseInfo[ 'ViewFromPropertyCmd' ] )

$repl[ 'VIEW_FROM_PROPERTY_STUFF_PROCESS' ] =
$viewFromPropertySupported_ProcessStuff.Replace( 'VIEW_FROM_PROPERTY_COMMAND',
$baseInfo[ 'ViewFromPropertyCmd' ] )
}
else
{
$repl[ 'VIEW_FROM_PROPERTY_STUFF_BEGIN' ] = ''

$repl[ 'VIEW_FROM_PROPERTY_STUFF_PROCESS' ] = $viewFromPropertyNotSupported_ProcessStuff
}

gc $inputFile | %{
$line = $_

Expand Down Expand Up @@ -68,9 +138,9 @@ try
# Format-* proxies
#
$proxyBaseInfos = @{
'Custom' = @{ 'SPEW_PREFIX' = 'FcProxy'; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113301' }
'List' = @{ 'SPEW_PREFIX' = 'FlProxy'; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113302' }
'Table' = @{ 'SPEW_PREFIX' = 'FtProxy'; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113303' }
'Custom' = @{ 'SPEW_PREFIX' = 'FcProxy'; 'ViewFromPropertyCmd' = '' ; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113301' }
'List' = @{ 'SPEW_PREFIX' = 'FlProxy'; 'ViewFromPropertyCmd' = 'New-AltListViewDefinition' ; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113302' }
'Table' = @{ 'SPEW_PREFIX' = 'FtProxy'; 'ViewFromPropertyCmd' = 'New-AltTableViewDefinition'; 'HELP_URI' = 'http://go.microsoft.com/fwlink/?LinkID=113303' }
}

foreach( $key in $proxyBaseInfos.Keys )
Expand Down
Loading

0 comments on commit f651cf1

Please sign in to comment.