Closed ninmonkey closed 2 years ago
After importing ugit you are unable to call Get-FormatData without errors.
ugit
Get-FormatData
Remove-Module 'ugit'
[InvalidCastException]
Pwsh7> pwsh -Nop Pwsh7> $mod = 'bitstransfer' Remove-Module $mod $A1 = Get-FormatData Import-Module $mod -Force $B1 = Get-FormatData $diff1 = Compare-Object $A1 $B1 $mod = 'ugit' Remove-Module $mod $A1 = Get-FormatData Import-Module $mod -Force $B1 = Get-FormatData $diff1 = Compare-Object $A1 $B1 $mod = 'bitstransfer' Remove-Module $mod $A1 = Get-FormatData Import-Module $mod -Force $B1 = Get-FormatData $diff1 = Compare-Object $A1 $B1
Top
While I would love to be able to fix this issue, it is in fact an issue with Get-FormatData's inability to properly handle complex formatting (and thus is out of my control)
About
After importing
ugit
you are unable to callGet-FormatData
without errors.Remove-Module 'ugit'
, but not alwaysTo Reproduce
[InvalidCastException]
Short Version Top[InvalidCastException]
Full Version TopSummary (Click to Expand) +70 Lines ```ps1 Import-Module $mod -Force $B = Get-FormatData $diff1 = Compare-Object $A $B ... 🠯 Click to Expand +70 lines 🠯 ... ```
Click to Expand 🠯 ```ps1 ... 🠯 Continued From Above 🠯 ... Pwsh7> pwsh -Nop ## ---- Pwsh7> $mod = 'ugit' $mod = 'bitstransfer' "Module: $mod" if (Get-Module -ea Ignore -Name $Mod) { Remove-Module $mod } $A = Get-FormatData Import-Module $mod -Force $B = Get-FormatData $diff1 = Compare-Object $A $B ## ---- Pwsh7> $mod = 'ugit' $mod = 'bitstransfer' "Module: $mod" if (Get-Module -ea Ignore -Name $Mod) { Remove-Module $mod } $A = Get-FormatData Import-Module $mod -Force $B = Get-FormatData $diff1 = Compare-Object $A $B ## ---- Pwsh7> $mod = 'ugit' #$mod = 'bitstransfer' "Module: $mod" if (Get-Module -ea Ignore -Name $Mod) { Remove-Module $mod } $A = Get-FormatData Import-Module $mod -Force $B = Get-FormatData $diff1 = Compare-Object $A $B ## ---- Pwsh7> $mod = 'ugit' $mod = 'bitstransfer' "Module: $mod" if (Get-Module -ea Ignore -Name $Mod) { Remove-Module $mod } $A = Get-FormatData Import-Module $mod -Force $B = Get-FormatData $diff1 = Compare-Object $A $B ```Log
[InvalidCastException]
TopTop
Error Log (Click to Expand +90 Lines) ```ps1 $Regex = @{ StripColor = '\u001B.*?m' StripAll = '\u001B.*?\p{L}' } $error | Get-Error | out-string -w 180 | %{ $_ -replace $Regex.StripAll, '' } | Set-Clipboard ``` ```yml PositionMessage : At line:12 char:6 + $B = Get-FormatData + ~~~~~~~~~~~~~~ InvocationName : Get-FormatData CommandOrigin : Internal ... ``` Click to Expand 🠯
```yml Exception : Type : System.InvalidCastException TargetSite : Name : ChkCast_Helper DeclaringType : System.Runtime.CompilerServices.CastHelpers, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e MemberType : Method Module : System.Private.CoreLib.dll Message : Unable to cast object of type 'Microsoft.PowerShell.Commands.Internal.Format.ControlReference' to type 'Microsoft.PowerShell.Commands.Internal.Format.ComplexControlBody'. Source : System.Private.CoreLib HResult : -2147467262 StackTrace : at System.Management.Automation.CustomItemBase.Create(FormatToken token) at System.Management.Automation.CustomControlEntry..ctor(ComplexControlEntryDefinition entry) at System.Management.Automation.CustomControl..ctor(ComplexControlBody body, ViewDefinition viewDefinition) at Microsoft.PowerShell.Commands.GetFormatDataCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() CategoryInfo : NotSpecified: (:) [Get-FormatData], InvalidCastException FullyQualifiedErrorId : System.InvalidCastException,Microsoft.PowerShell.Commands.GetFormatDataCommand InvocationInfo : MyCommand : Get-FormatData ScriptLineNumber : 12 OffsetInLine : 6 HistoryId : 17 Line : $B = Get-FormatData PositionMessage : At line:12 char:6 + $B = Get-FormatData + ~~~~~~~~~~~~~~ InvocationName : Get-FormatData CommandOrigin : Internal ScriptStackTrace : atTop