Fix NRE when custom rules omit optional properties in diagnostics by rjmholt · Pull Request #1715 · PowerShell/PSScriptAnalyzer
PR Summary
Fixes #1714.
These changes allow custom rules to emit diagnostics (or PSObjects that turn into diagnostics) with optional properties unset.
PR Checklist
- PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- Summarized changes
- Change is not breaking
- Make sure all
.cs,.ps1and.psm1files have the correct copyright header - Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
- This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP:to the beginning of the title and remove the prefix when the PR is ready.
- If the PR is work in progress, please add the prefix
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only suggestion is to replace hard-coded property names with code references using things like e.g. nameof. Also, should we try to make the property query case insensitive for the property name itself as I think at the moment it'd be case sensitive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters