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

SA1202 wrongly treats explicit interface implementations as private #1179

Closed
oatkins opened this issue Aug 10, 2015 · 4 comments
Closed

SA1202 wrongly treats explicit interface implementations as private #1179

oatkins opened this issue Aug 10, 2015 · 4 comments
Assignees
Milestone

Comments

@oatkins
Copy link
Contributor

oatkins commented Aug 10, 2015

Legacy StyleCop correctly treats members that explicitly implement an interface member as public. The new analyzers, however, treat these as private.

internal interface IA
{
    string T { get; }

    int U { get; }
}

class Test : IA
{
    public int Q { get; set; }

    string IA.T
    {
        get { return null; }
    }

    // SA1202 (All public properties must come before all private properties) wrongly reported here.
    public int W { get; set; }

    protected string S { get; set; }

    // SA1202 should be reported here (according to legacy StyleCop), but is not.
    int IA.U
    {
        get { return 0; }
    }
}

Interestingly, explicit implementations are treated as public by legacy StyleCop even when they implement an internal interface. (I used an internal interface in my example; the results are the same if you make it public.)

Sorry I missed this subtlety before.

@sharwell
Copy link
Member

Ugh. 🐛

I'm glad you are so persistent with checking these. 😄

Marking up for grabs although I expect @Noryoko will jump on it.

@Noryoko
Copy link
Contributor

Noryoko commented Aug 10, 2015

You would be correct in that assumption.

@marcospgp
Copy link
Contributor

I see this issue has been closed, but has this been resolved? I just ran into this today using stylecop.analyzers.1.1.118:

image

@bjornhellander
Copy link
Contributor

@marcospgp, this issue was marked as fixed in 2015, so it was definitely resolved. Please create a new issue with a small but complete example that it misbehaves on if you are seeing unwanted behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants