dotnet/roslyn
View on GitHubAdd analyzer that catches properties that can be made readonly
Open
#53,227 opened on Apr 2, 2020
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);
}
}