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
Fix S1905 FP: Nullability context and array of anonymous types #6438
Labels
Projects
Milestone
Comments
Hello, again @paulhickman-a365, and thanks for opening this issue. Your feedback helps us improve our products. We will look at it as soon as possible. After we confirm the issue, we will add labels and put it in our backlog |
Thank you for reporting this, I confirm it as FP. It also reproduces with |
pavel-mikula-sonarsource
added
Type: False Positive
Rule IS triggered when it shouldn't be.
Area: C#
C# rules related issues.
labels
Jan 24, 2023
pavel-mikula-sonarsource
changed the title
S1905 erronously suggests removing cast when constructing anonymous type array
Fix S1905 FP: Nullability context and array of anonymous types
Jan 24, 2023
Tim-Pohlmann
assigned Tim-Pohlmann and martin-strecker-sonarsource and unassigned martin-strecker-sonarsource and Tim-Pohlmann
Feb 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description
In a .net 6 project where nullable reference types is enabled, in the example below the casts to string? are necessary, otherwise the nullability of x in the two array elements doesn't match and this produces a CS8206 error
Repro steps
Expected behavior
No S1905 warning is produced
Actual behavior
S1905 warning is produced
Known workarounds
Don't use anonymous types and create a class with a property x of type string? and declare the array of that type
Related information
The text was updated successfully, but these errors were encountered: