AgodaAnalyzers
AgodaAnalyzers copied to clipboard
AG0034: Check if method parameters are being mutated by reference
I would like to prevent people from misusing the parameters as a way to return some value from a method. For example, for following code:
public static void Method(A a){
a.B = new B();
a.B.C = new C();
}
both assignments are mutating the input parameter and treating it like a return value. The rule would not be applied for ref and out type params, as they imply explicitly that the parameter is / might be mutated.