-
Notifications
You must be signed in to change notification settings - Fork 231
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
Investigate why S2259 does not always trigger on C# 8 code #2601
Comments
While digging into the reasons the issues are not raised for C#8, I found 2 causes:
|
We need to add test cases and then we'll see what the behavior of the new engine is |
Our team is seeing this issue. I am unable to view the sources referenced in this thread. This hides many potential issues in our codebase. Any update on this? See the following example.
|
A single null coalescing will suppress all S2259 warnings in a method too. |
We are dotnet 6.0 / C# 10. |
We're in process of rewriting our Symbolic Execution engine. We'll revisit this once the effort is done. That should happen later this year. |
Related issue #4250 for the new engine. |
@andrei-epure-sonarsource Do you think this issue can be closed? |
Description
C#8 introduces the concept of non-nullable reference types. By default, the reference types are considered non-nullable. See details in Nullable reference types.
I analyzed andrei-epure-sonarsource/CSharp8Demo on SonarCloud. Note that the csproj has the
NullableContextOptions
enabled.Rule S2259 doesn't behave normally with easy-to-find cases.
Repro steps
Look at this line on sonarcloud. It is clearly a NRE (and it does thrown at runtime).
Expected behavior
The analyzer should raise S2259 at line 17, 20, 25 and 42.
Actual behavior
Only line 42 has a raised issue.
Known workarounds
None.
Related information
The text was updated successfully, but these errors were encountered: