dotnet/roslyn

Add analyzer that catches properties that can be made readonly

開放

#53,227 建立於 2020年4月2日

 (3 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-IDEIDE-CodeStylehelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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

貢獻者指南