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

CC0071 Introduce a field for parameter ignores parameters consumed by base() and this() #1026

Open
r-pankevicius opened this issue May 16, 2019 · 0 comments

Comments

@r-pankevicius
Copy link

There are CC0071 warnings for constructor parameters that are passed to base() or this() constructors. See "OK", "NOT OK" in comments for what's expected.

public class Base
{
	public Base(int x) // CC0071 - OK
	{
	}
}

After fix applied - OK:

public class Base
{
	private readonly int x;

	public Base(int x)
	{
		this.x = x;
	}
}

Let's create a derived class:

public class Derived :Base
{
	public Derived(int x) : base(x) // CC0071 - NOT OK, because x is passed to base ctor
	{
	}
}

Another false flag for this(x):

public class Base
{
	private readonly int x;

	public Base(int x)
	{
		this.x = x;
	}

	public Base(int x, string s) : this(x) // // CC0071 for x - NOT OK, for s - OK
	{
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant