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

Use AST to determine SupportsShouldProcess when an error is thrown #1397

Merged

Conversation

rjmholt
Copy link
Contributor

@rjmholt rjmholt commented Jan 16, 2020

PR Summary

Fixes #1217.

When PowerShell throws an error due to not being able to resolve an attribute type, we sift through the AST to determine whether SupportsShouldProcess has been set on a function.

Also cleans up some of the logic so it's not all nested ass.

PR Checklist

@bergmeister
Copy link
Collaborator

Code change looks ok but the build says it has a problem when targeting psv3, looks like we need a pragma using the PSV3 variable

UseShouldProcessCorrectly.cs(382,99): error CS1061: 'ExpressionAst' does not contain a definition for 'SafeGetValue' and no accessible extension method 'SafeGetValue' accepting a first argument of type 'ExpressionAst' could be found (are you missing a using directive or an assembly reference?)

rjmholt and others added 3 commits January 16, 2020 14:30
@rjmholt
Copy link
Contributor Author

rjmholt commented Feb 7, 2020

Ok I've repurposed the SafeGetValue substitute method I wrote to handle that. It's now available as a Helper method.

Copy link
Collaborator

@bergmeister bergmeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I verified that the diff in Helper.cs/Settings.cs is mainly just the move to make the method publicly accessible.
Only an optional style suggestion.

Rules/UseShouldProcessCorrectly.cs Outdated Show resolved Hide resolved
Rules/UseShouldProcessCorrectly.cs Outdated Show resolved Hide resolved
rjmholt and others added 2 commits February 8, 2020 09:54
Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>
Co-Authored-By: Christoph Bergmeister [MVP] <c.bergmeister@gmail.com>
@bergmeister bergmeister merged commit 8ba2d97 into PowerShell:master Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UseShouldProcessCorrectly Unable to find type
2 participants