◐ Shell
clean mode source ↗

Fix NRE when custom rules omit optional properties in diagnostics by rjmholt · Pull Request #1715 · PowerShell/PSScriptAnalyzer

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@rjmholt

@rjmholt rjmholt commented

Sep 16, 2021

Copy link Copy Markdown

Contributor

PR Summary

Fixes #1714.

These changes allow custom rules to emit diagnostics (or PSObjects that turn into diagnostics) with optional properties unset.

PR Checklist

@bergmeister bergmeister left a comment

Copy link Copy Markdown

Collaborator

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

rjmholt reacted with thumbs up emoji

@JamesWTruher JamesWTruher merged commit a42ab5f into PowerShell:master

Sep 28, 2021

@rjmholt rjmholt deleted the customrule-fix-nre branch

November 20, 2021 00:52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bergmeister bergmeister bergmeister approved these changes

+1 more reviewer

@JamesWTruher JamesWTruher JamesWTruher approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Custom rules that don't supply optional properties cause null dereference

3 participants

@rjmholt @bergmeister @JamesWTruher