AgodaAnalyzers icon indicating copy to clipboard operation
AgodaAnalyzers copied to clipboard

AG0034: Check if method parameters are being mutated by reference

Open m-malkowski opened this issue 7 years ago • 0 comments

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.

m-malkowski avatar Sep 27 '18 10:09 m-malkowski