Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AG0034: Check if method parameters are being mutated by reference #107

Open
matmalkowski opened this issue Sep 27, 2018 · 0 comments
Open

Comments

@matmalkowski
Copy link
Member

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.

@mikechamberlain mikechamberlain changed the title Check if method parameters are being mutated by reference AG0034: Check if method parameters are being mutated by reference Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants