Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCGV: Out-ConsoleGridView does not accept XML data #97

Open
jasper-zanjani opened this issue May 5, 2020 · 10 comments
Open

OCGV: Out-ConsoleGridView does not accept XML data #97

jasper-zanjani opened this issue May 5, 2020 · 10 comments
Labels
bug Something isn't working Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools Needs-Repro-Info OCGV
Milestone

Comments

@jasper-zanjani
Copy link

jasper-zanjani commented May 5, 2020

While manipulating XML data and testing Out-ConsoleGridView (Powershell 7.0.0 on Windows 10.0.19603), I noticed that the cmdlet appears to demand data of a certain datatype. For testing, a sample XML file can be found here.

[xml]$xml = Get-Content '.\sample.xml'

Tabular output from $xml can be viewed in the terminal

$xml.catalog.book

Output

id           : bk101
author       : Gambardella, Matthew
title        : XML Developer's Guide
genre        : Computer
price        : 44.95
publish_date : 2000-10-01
description  : An in-depth look at creating applications 
                     with XML.

id           : bk102
...

Piping to Out-GridView produces expected output

$xml.catalog.book | Out-GridView

out-gridview

However, piping to Out-ConsoleGridView produces an error

$xml.catalog.book | Out-ConsoleGridView

out-consolegridview
The BaseType of $xml.catalog.book is System.Array

@TylerLeonhardt
Copy link
Member

hmm I can't seem to repro this...

image

I had it repro'ing once but that PowerShell instance seemed to be corrupted in some way...

It might be that the next version of gui.cs that we depend on will have more stability here.

@jasper-zanjani
Copy link
Author

I just updated to 7.0.1 and I am getting the same error, any new ideas?

@TylerLeonhardt
Copy link
Member

Can you paste the output of Get-Error?

@TylerLeonhardt
Copy link
Member

gentle ping on this

@TylerLeonhardt TylerLeonhardt added Needs-Repro-Info Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools labels Aug 28, 2020
@jasper-zanjani
Copy link
Author

jasper-zanjani commented Aug 28, 2020

I just went through the same steps, creating an XML object from the same test file above.

jaspe PS> $data.catalog.book | Out-ConsoleGridView
Out-ConsoleGridView: Length cannot be less than zero. (Parameter 'length')
Exception             :
    Type       : System.ArgumentOutOfRangeException
    Message    : Length cannot be less than zero. (Parameter 'length')
    ParamName  : length
    TargetSite :
        Name          : Substring
        DeclaringType : string
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    StackTrace :
   at System.String.Substring(Int32 startIndex, Int32 length)
   at OutGridView.Cmdlet.ConsoleGui.GetPaddedString(List`1 strings, Int32 offset) in
D:\a\1\s\src\Microsoft.PowerShell.ConsoleGuiTools\ConsoleGui.cs:line 320
   at OutGridView.Cmdlet.ConsoleGui.Start(ApplicationData applicationData) in
D:\a\1\s\src\Microsoft.PowerShell.ConsoleGuiTools\ConsoleGui.cs:line 152
   at OutGridView.Cmdlet.OutConsoleGridViewCmdletCommand.EndProcessing() in
D:\a\1\s\src\Microsoft.PowerShell.ConsoleGuiTools\OutConsoleGridviewCmdletCommand.cs:line 143
   at System.Management.Automation.CommandProcessorBase.Complete()
    Source     : System.Private.CoreLib
    HResult    : -2146233086
CategoryInfo          : NotSpecified: (:) [Out-ConsoleGridView], ArgumentOutOfRangeException
FullyQualifiedErrorId : System.ArgumentOutOfRangeException,OutGridView.Cmdlet.OutConsoleGridViewCmdletCommand
InvocationInfo        :
    MyCommand        : Out-ConsoleGridView
    ScriptLineNumber : 1
    OffsetInLine     : 22
    HistoryId        : 15
    Line             : $data.catalog.book | Out-ConsoleGridView
    PositionMessage  : At line:1 char:22
                       + $data.catalog.book | Out-ConsoleGridView
                       +                      ~~~~~~~~~~~~~~~~~~~
    InvocationName   : Out-ConsoleGridView
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

For the record:

jaspe PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
OS                             Microsoft Windows 10.0.20201
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

And the data object certainly has data (truncated):

jaspe PS> $data.catalog.book

id           : bk101
author       : Gambardella, Matthew
title        : XML Developer's Guide
genre        : Computer
price        : 44.95
publish_date : 2000-10-01
description  : An in-depth look at creating applications
                     with XML.

id           : bk102
author       : Ralls, Kim
title        : Midnight Rain
genre        : Fantasy
price        : 5.95
publish_date : 2000-12-16
description  : A former architect battles corporate zombies,
                     an evil sorceress, and her own childhood to become queen
                     of the world.
...

I tried this in both Windows Terminal running PowerShell Core as well as pwsh.exe, which I guess uses the trusty conhost. Both produced the same error.

Piping to Out-GridView and Out-GridHTML produces expected output

Update

I just updated PowerShell to 7.0.3 and got the exact same error.
I also updated PowerShell on my MacBook to 7.0.3 and got the exact same error using the exact same method.
I also ran PowerShell on my Linux system (not WSL) running 7.0.3 and got the same error using the same method.

@TylerLeonhardt TylerLeonhardt added the bug Something isn't working label Aug 28, 2020
@tig
Copy link
Collaborator

tig commented Sep 28, 2020

I can repro. I'll take a look.

@tig
Copy link
Collaborator

tig commented Sep 28, 2020

Ok, this is beyond my knowledge of PS. What I've found is the cmdlet's ProcessRecord method gets called but InputObject is null.

@TylerLeonhardt
Copy link
Member

@tig were your repro steps the same?

@tig
Copy link
Collaborator

tig commented Sep 30, 2020

Yes. I grabbed his XML file and tested as he showed.

@tig
Copy link
Collaborator

tig commented Aug 24, 2022

@andschwa please prefix title with "OCGV: ".

@andyleejordan andyleejordan changed the title Out-ConsoleGridView does not accept XML data OCGV: Out-ConsoleGridView does not accept XML data Aug 24, 2022
@SteveL-MSFT SteveL-MSFT added this to the Future milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools Needs-Repro-Info OCGV
Projects
None yet
Development

No branches or pull requests

5 participants