Skip to content

Suggestion for simplifying field access in non-partial properties #78156

Open
@thinker227

Description

@thinker227

Brief description:

An analyzer for suggesting simplifying get => field; in non-partial properties to just get; as there is no semantic difference.

Languages applicable: C#

Code example that the analyzer should report:

public class Person
{
    public int Age
    {
        get => field;
//          ^^^^^^^^
// Field access can be simplified.
        set => field = int.Clamp(0, 100);
    }
}

Additional information:

As far as I'm aware there is no semantic difference between get => field; and get;. I might not have the full context though, in which case this suggestion might not be applicable.

Documentation requirements:

When this analyzer is implemented, it must be documented by following the steps at Documentation for IDE CodeStyle analyzers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEFeature Requesthelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions