From a field create a property with getter or setter and optionally change all the references to that field to use the property. There is a refactoring already in Visual Studio for a full encapsulation.
class Foo
{
private int i;
void Bar()
{
i = 1;
}
void Baz()
{
var j = i;
}
}
If changed to read-only:
class Foo
{
private int i;
public int I => i;
void Bar()
{
i = 1;
}
void Baz()
{
var j = I;
}
}
If changed to write-only:
class Foo
{
private int i;
public int I
{
i = value;
}
void Bar()
{
I = 1;
}
void Baz()
{
var j = i;
}
}
If the field is not private and has references outside the class, change those as well.
This is essentially a refactoring, so we are classifying it as a Hidden diagnostic.
Diagnostic id: CC0058
Category: Refactoring
From a field create a property with getter or setter and optionally change all the references to that field to use the property. There is a refactoring already in Visual Studio for a full encapsulation.
If changed to read-only:
If changed to write-only:
If the field is not private and has references outside the class, change those as well.
This is essentially a refactoring, so we are classifying it as a
Hiddendiagnostic.Diagnostic id:
CC0058Category:
Refactoring