Currently when testing a parameter for the immutability we consider the following attributes:
- Parameter attribute flags
IsReadOnly attribute presence.
As it has been discussed here with @stakx we should additionally test for the required modifier presence to make the logic more robust. The parameter should be considered read-only if either:
- parameter attributes has
ParameterAttributes.In flag and In required modifier is present
- parameter attributes has
ParameterAttributes.In flag and IsReadOnly attribute is defined
We should tests the performance and add the quicker check first.
I'd suggest to postpone the improvement till the correct modifier type is clarified here: dotnet/csharplang#1655.