dotnet/roslyn

Add analyzer that catches properties that can be made readonly

Open

#53,227 opened on Apr 2, 2020

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-IDEIDE-CodeStylehelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

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