Fork me on GitHub
TypeName ReadonlyFieldAnalyzer
Check Id CC0052
Category Usage
Severity Info

Cause

A field that is only assigned when declared or in the constructor can be made reaonly. A readonly field cannot be assigned anywhere else after the object is created, making it immutable.

Example

class Foo
{
    private int i = 0;
}

Code fix

A code fix will be presented to you that will transform the code:

class Foo
{
    private readonly int i = 0;
}

Code fix

Related rules

None

See also

TBD