Skip to content

Comments

fix: document and test PublicMethodMissingTestAttributeAnalyzer property/event handling#4912

Merged
thomhurst merged 1 commit intomainfrom
fix/public-method-analyzer
Feb 19, 2026
Merged

fix: document and test PublicMethodMissingTestAttributeAnalyzer property/event handling#4912
thomhurst merged 1 commit intomainfrom
fix/public-method-analyzer

Conversation

@thomhurst
Copy link
Owner

Summary

Closes #4863

  • Investigated whether PublicMethodMissingTestAttributeAnalyzer produces false positives on property getters/setters and event handlers
  • Finding: The existing MethodKind.Ordinary filter already correctly excludes these cases. In Roslyn's MethodKind enum, property accessors have MethodKind.PropertyGet/PropertySet and event accessors have MethodKind.EventAdd/EventRemove — all distinct from MethodKind.Ordinary
  • Added a clarifying comment to the analyzer documenting this behavior
  • Added 4 new test cases to explicitly verify no false positives for: properties (auto and explicit), events with custom accessors, override methods, and static methods

Test plan

  • All new tests pass on net8.0 and net9.0
  • Existing tests continue to pass
  • dotnet build TUnit.Analyzers/TUnit.Analyzers.csproj succeeds

@claude
Copy link
Contributor

claude bot commented Feb 19, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

The changes look clean and well-targeted:

  • The clarifying comment added to PublicMethodMissingTestAttributeAnalyzer.cs accurately describes the semantics of MethodKind.Ordinary — property accessors (PropertyGet/PropertySet), event accessors (EventAdd/EventRemove), constructors, destructors, and operators all have distinct MethodKind values and are correctly excluded by the existing filter.
  • All 4 new test cases (Property_Getter_Setter_No_Error, Event_Accessors_No_Error, Override_Method_No_Error, Static_Method_No_Error) align with the actual analyzer filter chain and correctly assert zero diagnostics.
  • No CLAUDE.md rule violations (snapshot testing, dual-mode, AOT, no blocking async — none apply to this analyzer/test-only change).

…ibuteAnalyzer (#4863)

The MethodKind.Ordinary filter already correctly excludes property
accessors (PropertyGet/PropertySet), event accessors (EventAdd/EventRemove),
constructors, destructors, and operators. Added a clarifying comment to
document this behavior and new test cases for properties, events, overrides,
and static methods to prevent future regressions.
@thomhurst thomhurst force-pushed the fix/public-method-analyzer branch from 6847e5f to 7cec0a4 Compare February 19, 2026 11:47
@thomhurst thomhurst merged commit c6baeef into main Feb 19, 2026
13 of 14 checks passed
@thomhurst thomhurst deleted the fix/public-method-analyzer branch February 19, 2026 13:57
This was referenced Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: PublicMethodMissingTestAttributeAnalyzer may flag property accessors

1 participant