Branch master (19 Dec 2020)
Latest commit 80e9227 by msftbot[bot]:
Merge pull request #50073 from dotnet/merges/release/dev16.9-to-master
Merge release/dev16.9 to master
Steps to Reproduce:
#nullable enable
class C
{
void Test(C? c)
{
c = new C();
c++;
}
public static C? operator ++(C? c) => c;
}
Expected Behavior:
No warnings. The variable c allows null values, the operator's parameter allows null values. There's nothing to warn about.
Actual Behavior:
warning CS8601: Possible null reference assignment. is repoted for c++
Notes
Note that if you remove the assignment c = new C() the warning disappears.
It looks like Roslyn uses the actual nullability state of the variable c to determine allowed nullability instead of its annotation
Version Used:
Steps to Reproduce:
Expected Behavior: No warnings. The variable
c
allows null values, the operator's parameter allows null values. There's nothing to warn about.Actual Behavior:
warning CS8601: Possible null reference assignment.
is repoted forc++
Notes Note that if you remove the assignment
c = new C()
the warning disappears. It looks like Roslyn uses the actual nullability state of the variablec
to determine allowed nullability instead of its annotation