Fork me on GitHub
TypeName ReplaceWithGetterOnlyAutoPropertyAnalyzer
Check Id CC0125
Category Refactoring
Severity Hidden

Cause

Getter only properties with backing read-only field can be converted to getter-only auto-properties.

Example

class AwesomeService
{
    private readonly ILogger _Logger;
    public AwesomeService(ILogger logger)
    {
        _Logger = logger;
    }

    protected ILogger Logger
    {
        get
        {
            return _Logger;
        }
    }
}

Code fix

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

class AwesomeService
{
    public AwesomeService(ILogger logger)
    {
        Logger = logger;
    }

    protected ILogger Logger { get; }
}

Code fix

Related rules

TBD

See also

TBD