-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix ConciseView to handle custom ParserError ErrorRecords
#19239
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
Conversation
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Show resolved
Hide resolved
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Show resolved
Hide resolved
…ters/PowerShellCore_format_ps1xml.cs Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
…ters/PowerShellCore_format_ps1xml.cs Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
daxian-dbw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a minor suggestion to reduce a pair of parentheses.
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
…ters/PowerShellCore_format_ps1xml.cs Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
🎉 Handy links: |
|
🎉 Handy links: |
PR Summary
The fundamental issue is that
ConciseViewhas code to handle PowerShellParserErrorcategory, but the cmdlet in the issue was returning an ErrorRecord with that category (which is allowed), but theConciseViewscript was only expecting an object that looked like what PowerShell would return. See the comment thread #19239 (comment) for some more details.During execution of this script during formatting, what you get an a
ParseExceptionis actually anErrorRecordwhere theExceptionis aParentContainsErrorRecordException. So the way to check it's a parse error from PowerShell is to check that theCategoryisParseErrorand theExceptiontype isParentContainsErrorRecordException. Not ideal, but theParseExceptionseems to be created somewhere else that gets put onto$Errorbut not available to the script during formatting.Also added a trap at the start of that script in case there are other unknown issues so that users will get an error message that can be reported to us rather than no error.
Note that the actual issue, however, only repros over remoting which does it's own wrapping of remote errors so a PS Job is used for the test to cover this case.
PR Context
Fix #19223
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).