Open controlflow opened 1 year ago
FWIW, this behavior also existed in the native compiler.
We could:
This pattern is roughly equivalent to the following
struct S {
int _field;
void G() => M(ref _field);
void M(ref int i) { }
}
There is an implicit &
in the fixed
case. Given we don't warn here I would say not warning on the fixed
case is reasonable.
I'd also say it's not terribly high priority given the behavior's been this way since C# 1.0.
Version Used:
main branch
Steps to Reproduce:
Compile the following code:
Diagnostic Id:
CS0169
Expected Behavior:
No
CS0169
produced, since struct can be is used for both read and write if it's fixed buffer field is used.Actual Behavior:
False positive compiler warning
CS0169
produced.