Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected SA1513 before init accessor #3658

Closed
bjornhellander opened this issue May 23, 2023 · 0 comments · Fixed by #3666
Closed

Unexpected SA1513 before init accessor #3658

bjornhellander opened this issue May 23, 2023 · 0 comments · Fixed by #3666

Comments

@bjornhellander
Copy link
Contributor

The following code illustrates a difference between how SA1513 treats set accessors and init accessors:

class MyClass
{
    public int X
    {
        get
        {
            return 0;
        } // <-- Does NOT trigger SA1513
        set
        {
        }
    }

    public int Y
    {
        get
        {
            return 0;
        } // <-- Triggers SA1513
        init
        {
        }
    }
}

I expect SA1513 to not trigger before init accessors, just like it does not trigger before set accessors.
Note: SA1516 triggers in both cases, like it should.

Tested with 1.2.0-beta.435

bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Jun 8, 2023
… test to verify that it already handles init accessors correctly.

DotNetAnalyzers#3658
@sharwell sharwell added this to the 1.2-beta.next milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants