You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SA1202: Order explicit interface events as public - #4281
Explicit interface events were omitted from MemberOrderHelper.GetAccessLevelForOrdering, while explicit methods, properties, and indexers are treated as public. This caused SA1202 to report an already correctly ordered explicit event before a public event, and accessibility-first SA1201 configurations to skip event ordering.
The shared helper now treats only explicit event declarations as public. Tests cover the issue's exact false positive, reordering and the SA1202 code fix, a non-explicit event near miss, and an accessibility-first SA1201 configuration. All three new regression cases fail on master: the issue case reports SA1202 at the public event, while the explicit-event code-fix and SA1201 cases produce no diagnostic. documentation/SA1202.md now states the behavior.
⚑ StyleCop Classic treated explicit interface events as private. This intentionally deviates from Classic and aligns events with the other explicit interface members, as agreed in the issue discussion.
Performance: the change adds one SyntaxKind check to shared access classification; it adds no callbacks, allocations, or semantic-model work. In a no-event edit simulation (StyleCopTester.exe /id:SA1202 /editperf:MemberOrderHelper.cs /edititer:100 /force StyleCopAnalyzers.slnx, three runs on master and three after the change), median throughput was 8.79 vs. 7.50 edits/sec, with overlapping run ranges of 7.48–10.29 and 7.49–8.28 edits/sec. The variation is larger than the measured difference; no regression was measurable.
Cover SA1204's use of explicit event accessibility when ordering static members.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Update Russian and Czech SA1202 documentation with behavior note
documentation/SA1202.md:39
The Russian and Czech SA1202.md editions were not updated with this clarification, so those published editions omit the newly documented StyleCop Classic deviation. CONTRIBUTING.md:114-116 requires all editions to stay current because localized Markdown has no English fallback; please update both localized pages with the same behavior note.
Keep the Czech and Russian rule descriptions aligned with the explicit-event ordering behavior.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.63%. Comparing base (dfaef0c) to head (e841a9a). ⚠️ Report is 10 commits behind head on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1823
Explicit interface events were omitted from
MemberOrderHelper.GetAccessLevelForOrdering, while explicit methods, properties, and indexers are treated as public. This caused SA1202 to report an already correctly ordered explicit event before a public event, and accessibility-first SA1201 configurations to skip event ordering.The shared helper now treats only explicit event declarations as public. Tests cover the issue's exact false positive, reordering and the SA1202 code fix, a non-explicit event near miss, and an accessibility-first SA1201 configuration. All three new regression cases fail on master: the issue case reports SA1202 at the public event, while the explicit-event code-fix and SA1201 cases produce no diagnostic.
documentation/SA1202.mdnow states the behavior.⚑ StyleCop Classic treated explicit interface events as private. This intentionally deviates from Classic and aligns events with the other explicit interface members, as agreed in the issue discussion.
Performance: the change adds one
SyntaxKindcheck to shared access classification; it adds no callbacks, allocations, or semantic-model work. In a no-event edit simulation (StyleCopTester.exe /id:SA1202 /editperf:MemberOrderHelper.cs /edititer:100 /force StyleCopAnalyzers.slnx, three runs on master and three after the change), median throughput was 8.79 vs. 7.50 edits/sec, with overlapping run ranges of 7.48–10.29 and 7.49–8.28 edits/sec. The variation is larger than the measured difference; no regression was measurable.Validation:
dotnet build StyleCopAnalyzers.slnx -c Debug— 0 warnings, 0 errors.dotnet test test/StyleCop.Analyzers.Test.CSharp15 --no-build -f net10.0 --filter "FullyQualifiedName~OrderingRules"— 742 passed.