dotnet/roslyn

Add analyzer that catches properties that can be made readonly

Aperta

#53.227 aperta il 2 apr 2020

 (3 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEIDE-CodeStylehelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Version Used:

Steps to Reproduce:

It would be nice to have an analyzer that catches that the following property can be made readonly. Hit this on a PR just recently.


    public class Foo
    {
        public Foo(string property)
        {
            Property = property;
        }
        
        private string Property
        {
            get;
            set;  // <!-- Can remove
        }

        public void Method()
        {
            Console.WriteLine(Property);
        }
    }

Guida contributor