Closed danwalmsley closed 5 years ago
Contract.Requires<TException>
needs a [DoesNotReturnIf(false)]
on the condition. See how Debug.Assert
does it. If that still doesn't fix it, I'd suggest opening an issue on dotnet/roslyn, as this isn't the right venue.
Also, yes, the warning is intended behavior. != null
is a pure null test: https://github.com/dotnet/csharplang/blob/c229cae634/meetings/2019/LDM-2019-02-20.md#deliberate-tests-for-nullability
@333fred many thanks for feedback, I will test your suggestions.
See screenshot here: Iv enabled NRT im on .net core 3.0 release and latest visual studio.
then if I add in a call with a condition on a value being not null...
It seems to suggest to the compiler that after this line, x might be null, because the programmer checked for it being null.
Is this intended behavior?