Skip to content

SA1202 wrongly treats explicit interface implementations as private #1179

Closed

Description

@oatkins

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.

Activity

  1. sharwell commented on Aug 10, 2015

    @sharwell
    Member

    Ugh. 🐛

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

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

  2. Noryoko commented on Aug 10, 2015

    @Noryoko
    Contributor

    You would be correct in that assumption.

  3. added this to the 1.0.0 Beta 6 milestone on Aug 10, 2015
  4. marcospgp commented on Aug 2, 2024

    @marcospgp
    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

  5. bjornhellander commented on Aug 2, 2024

    @bjornhellander
    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions