Open csharper2010 opened 10 months ago
I just stumbled over this issue. As a workaround, putting #nullable disable
around the overloaded operators works fine in our case.
I just stumbled over this issue. As a workaround, putting
#nullable disable
around the overloaded operators works fine in our case.
Yep, but "works fine" is quite a relative rating.
It means that nullable annotations don't work on those operators. See
Possible workarounds?
Is there a workaround besides disabling nullable context on the operator definitions? Disable is not a good solution as I would like to have the nullable annotations also there.
Version:
net8.0 or any other version with Nullable Reference Typ support
Steps to Reproduce:
Expected Behavior:
As there is no real null check but a custom operator that generates an expression tree for convenience, flow control should not assume that v1 is null in second branch as it is already not null in the method signature. I am not sure under what conditions the compiler should decide that but as a developer I would say, it's obvious in my case that I don't want that warning.
Actual Behavior:
Compiler shows error
"CS8604"
) on second branch because it seems to assume that the first branch performs a real null check.Possible workarounds?
Is there a workaround besides disabling nullable context on the operator definitions? Disable is not a good solution as I would like to have the nullable annotations also there.
Complete example also in place