This is a refactoring.
The idea is that on a constructor parameter you CTRL DOT and get a "Introduce field" dialog, that will create a field and assign the value from the parameter to the field.
So this:
class Foo
{
public Foo(string bar)
{
}
}
Becomes:
class Foo
{
private readonly string bar;
public Foo(string bar)
{
this.bar = bar;
}
}
If the field is already assigned then no diagnostic is offered.
If the field is already present, it is just assigned to.
If the type does not match (e.g. parameter is string, existing field is int, a new field with 1 postfixed is added, like that:
class Foo
{
private int bar;
public Foo(string bar)
{
}
}
Becomes:
class Foo
{
private int bar;
private readonly string bar1;
public Foo(string bar)
{
this.bar1 = bar;
}
}
Diagnostic Id: CC0071
Severity: Hidden (refactoring)
Category: Refactoring
This is a refactoring.
The idea is that on a constructor parameter you CTRL DOT and get a "Introduce field" dialog, that will create a field and assign the value from the parameter to the field.
So this:
Becomes:
If the field is already assigned then no diagnostic is offered.
If the field is already present, it is just assigned to.
If the type does not match (e.g. parameter is
string, existing field isint, a new field with1postfixed is added, like that:Becomes:
Diagnostic Id:
CC0071Severity:
Hidden(refactoring)Category:
Refactoring