Closed Zhentar closed 6 years ago
Thank you for the report!
Could you give some more detail? I was not able to repro with a trivial case, both with and without a table view. I wonder if your object is being formatted with some other existing AltViewTableDefinition. Please include the TypeNames on your object (if your object is in a variable $obj
, run $obj.PSObject.TypeNames
). And also the result of Get-AltFormatViewDef -ForObject $obj
to see the default view definition that is chosen, and Get-AltFormatViewDef -ForObject $obj -FormatInfoType ([MS.Dbg.Formatting.AltTableViewDefinition])
to specifically ask for a table view.
Here's my repro attempt:
Add-Type -TypeDefinition @'
using System;
namespace NS {
public class Thing {
public String Str;
public int I1;
public int? MaybeI2;
public Thing( String s, int i ) { Str = s; I1 = i; }
public Thing( String s, int i, int i2 ) { Str = s; I1 = i; MaybeI2 = i2; }
}
}
'@
$t1 = [NS.Thing]::new("Hi", 123)
$t2 = [NS.Thing]::new("Ha", 124)
$t3 = [NS.Thing]::new("Ho", 224)
$t4 = [NS.Thing]::new("He", 66, 999)
@( $t1, $t2, $t3, $t4 ) | ft
@( $t1, $t2, $t3, $t4 ) | fat
Register-AltTypeFormatEntries {
New-AltTypeFormatEntry -TypeName 'NS.Thing' {
New-AltTableViewDefinition -ShowIndex {
New-AltColumns {
New-AltPropertyColumn -Property 'Str' -Width 7 -Alignment Right
New-AltPropertyColumn -Property 'I1' -Alignment Right
New-AltPropertyColumn -Property 'MaybeI2' -Alignment Right
} # End Columns
} # end Table view
}
}
@( $t1, $t2, $t3, $t4 ) | fat
Hmm, I also had a format string, -FormatString "{0:N0}"
it looks like it only happens with that present.
My object has an
int?
property that isnull
when it doesn't apply/can't be calculated. The standardFormat-Table
doesn't print anything when it's null. The alternate table formatting displays it as "$null" which has the unfortunate effect of making the least important information the most visible, so I have to do a ScriptColumn with a null check to handle it.