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

贡献者指南