Nullable reference types: Analysis of null checks on fields #9978
Labels
Area-Compilers
Bug
Language-C#
New Language Feature - Nullable Reference Types
Nullable Reference Types
Milestone
I have been playing with nullable reference types, which is already working remarkably great! To try it out, I have patched up my analyzer to convert Resharper's
(Item)NotNull/CanBeNullAttribute
annotations to nullable reference types. Then ran that on an actual annotated codebase.During that process I discovered some oddities, which I'll create issues for here.
Version Used: Built from source, branch NullableReferenceTypes (commit 8553cda)
Steps to Reproduce:
The next block of code raises warning 8202: Possible dereference of a null reference:
This can be worked around using:
Expected Behavior: The behavior is technically correct. Another thread could change the field value in-between. I cannot think of a better way, just wanted to mention this scenario, which gets somewhat annoying, as it occurs very often (in non-multithreaded code).
Actual Behavior:
CS8202 warning on the line with
value.Length
inside the if statement.@AlekseyTs
The text was updated successfully, but these errors were encountered: