dotnet/roslyn

Add analyzer that catches properties that can be made readonly

Offen

#53.227 geöffnet am 02.04.2020

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-IDEIDE-CodeStylehelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

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);
        }
    }

Contributor Guide