-
Notifications
You must be signed in to change notification settings - Fork 763
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-safe-access
linter rule: Expand to check for nullable properties
#15838
Conversation
Test this change out locally with the following install scripts (Action run 12305146501) VSCode
Azure CLI
|
Dotnet Test Results 77 files - 40 77 suites - 40 32m 28s ⏱️ - 14m 9s Results for commit 34f1f10. ± Comparison against base commit c404992. This pull request removes 1846 and adds 637 tests. Note that renamed tests count towards both.
|
public void Rule_ignores_array_access_on_array() => AssertNoDiagnostics(""" | ||
param foo (string | null)[] | ||
|
||
output bar string? = foo[0] |
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.
Not for this PR, but in an ideal world, should we be suggesting foo[?0]
? Out of bounds array accesses will throw, but we don't always have min/max length metadata on arrays (and we don't in this case).
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.
Good question. Might be worth creating an issue foi it?
Some examples where a replacement will be suggested:
Example 1
Input
Replacement
Example 2
module.bicep
has declared thebar
output as a nullable string.Input
Replacement
Closes #15823