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

Code triggers SA1202 instead of SA1400 #1778

Closed
GregReddick opened this issue Nov 16, 2015 · 2 comments
Closed

Code triggers SA1202 instead of SA1400 #1778

GregReddick opened this issue Nov 16, 2015 · 2 comments
Assignees
Milestone

Comments

@GregReddick
Copy link

First reported in #1766, Issue D9, with some refinements here.

This is a difference with classic StyleCop. In classic StyleCop the code below would trigger SA1400 and SA1205. In the current analyzer it triggers SA1202 and SA1205. It boils down to the fact that the partial classes without an access modifier may appear before or after the public class, depending on the access modifier assigned. Classic StyleCop suppressed the SA1202 and just reported SA1205 (and SA1400). The current analyzer suppresses SA1400 in favor of SA1205, but classic StyleCop reported both.

I'd be okay with just documenting this functionality difference with classic StyleCop. This is not a problem that will come up frequently, and I think it was really a bug in classic StyleCop that they reported both SA1400 and SA1205. The current functionality is actually more correct than standard StyleCop.

namespace RuleViolations
{
    /// <summary>A rule SA1205 fail.</summary>
    public class RuleSA1205Fail
    {
        /// <content>A part 1 class.</content>
        partial class Part1
        {
        }

        /// <summary>A part 2 class.</summary>
        public class Part2
        {
        }
    }
}
@sharwell
Copy link
Member

I believe the current StyleCop Analyzers behavior is correct. We should probably just document this.

@sharwell sharwell self-assigned this Nov 27, 2015
@sharwell sharwell added this to the 1.0.0 RC 1 milestone Nov 27, 2015
@sharwell
Copy link
Member

I looked at the documentation, and believe this was just a bug fix relative to StyleCop Classic.

  • SA1400 makes no sense here
  • StyleCop didn't report SA1202 because it didn't have the power of Roslyn to tell it was the accessibility of Part1 is

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

2 participants