| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
@microsoft-github-policy-service agree |
Sorry, something went wrong.
| /* ConfirmPreference */ typeof(ConfirmImpact), | ||
| /* ProgressPreference */ typeof(Enum), | ||
| /* InformationPreference */ typeof(ActionPreference), | ||
| /* ErrorView */ typeof(Enum), //ErrorView type not available on PS3 |
There was a problem hiding this comment.
There is PSV3 variable defined as we do conditional compilation for each version of PS (3, 4, 5 and 'Core'). You could use this to use Enum only for the v3 compiled version but the correct types for others.
Sorry, something went wrong.
There was a problem hiding this comment.
Okay I can do that, however I'm still not sure why this type array is here since nobody seems to reference it, should it be expanded despite this?
Sorry, something went wrong.
There was a problem hiding this comment.
Christoph Bergmeister (@bergmeister) James Truher (@JamesWTruher) what is the point of this enum? Can we just delete the whole thing, and merge this PR already?
Sorry, something went wrong.
There was a problem hiding this comment.
Joel Bennett (@Jaykul) Whilst it's not directly referenced, it is still needed as it clearly solves the issue of not flagging false positive for ErrorView. I presume the rule is using reflection. The PSV3 variable is a pragma, i.e. a build time variable as we use different PowerShell version SDKs when we build against the different versions.
Sorry, something went wrong.
There was a problem hiding this comment.
Honestly, maybe we should probably just type this as string.
The ErrorView enum is new in PS7 and it's not enforced. The variable can be overwritten, and now that it's an Enum in PS7, it has to be overwritten by anyone who wants to improve the error view (such as my ErrorView module, which actually works on old versions of PowerShell)...
Sorry, something went wrong.
There was a problem hiding this comment.
Overall looks good, thanks. Just one idea around the type problem you mentioned
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Fixes #1749
No warning is issued for Errorview by rule PSUseDeclaredVarsMoreThanAssignment
Additional Notes
I could not use the correct type for ErrorView as the type ErrorView is not available in PS3 and instead declared it's type as an Enum.
However I found that inside SpecialVars.cs the array of types : Type[] PreferenceVariableTypes , is not used anywhere, so is there a reason for it to exist?
PSScriptAnalyzer/Engine/SpecialVars.cs
Line 107 in 77f6500
PR Context
When we try to assign a new state to a Preference Variable like ErrorView it should not be flagged as a warning by the rule PSUseDeclaredVarsMoreThanAssignment. In order to prevent the rule from showing this warning there is a check for built in variables:
PSScriptAnalyzer/Rules/UseDeclaredVarsMoreThanAssignments.cs
Line 203 in 77f6500
This checks for the presence of the Preference Variable's declaration inside the SpecialVars.cs file. If it's in that file PSUseDeclaredVarsMoreThanAssignment stops throwing the warning.
PR Checklist