Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: CC0017 Autoproperty should not trigger with ref and out uses #928

@KristianWedberg

Description

@KristianWedberg

Enhancement

The code below triggers CC0017 AutoPropertyAnalyzer on MyThing, even though the explicit implementation is needed since _myThing is used as a ref and an out variable.

Since this is a quite common occurrence, it would be great if CC0017 didn't trigger when the field is used as a ref or an out anywhere.

class CC0017
{
    public int MyThing
    {
        get { return _myThing; }
        set { _myThing = value; }
    }
    private int _myThing;

    public void IncrementRef()
    {
        Interlocked.Increment(ref _myThing);
    }

    public static void SetOut(out int field)
    {
        field = 42;
    }
        
    public CC0017()
    {
        SetOut(out _myThing);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions