Skip to content

Comments

fix: Add unit tests and improve analyzers for handling generated code and diagnostics#399

Open
BenjaminMichaelis wants to merge 3 commits intomainfrom
bmichaelis/Updates
Open

fix: Add unit tests and improve analyzers for handling generated code and diagnostics#399
BenjaminMichaelis wants to merge 3 commits intomainfrom
bmichaelis/Updates

Conversation

@BenjaminMichaelis
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 07:41
@BenjaminMichaelis BenjaminMichaelis self-assigned this Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves analyzer robustness and test coverage by addressing issues with generated code detection, diagnostic URL generation, and analyzer behavior. The changes fix several bugs where analyzers would incorrectly report diagnostics on generated code or fail to handle edge cases properly.

Changes:

  • Improved generated code detection in naming analyzers using proper type comparison instead of name-only checks
  • Updated UnusedLocalVariable and AttributesOnSeparateLines analyzers to skip generated code
  • Refactored FavorDirectoryEnumerationCalls to fix InvalidCastException with generic methods and handle fully-qualified Directory references
  • Attempted performance optimization in DiagnosticUrlBuilder using GeneratedRegex (but incompatible with target framework)
  • Added comprehensive unit tests documenting and verifying fixes for edge cases

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DiagnosticUrlBuilder.cs Attempts to optimize regex usage with GeneratedRegex, but incompatible with netstandard2.0 target
UnusedLocalVariable.cs Changed to skip generated code and use DiagnosticUrlBuilder for HelpLinkUri
NamingPropertyPascal.cs Improved GeneratedCodeAttribute detection using proper type comparison
NamingMethodPascal.cs Improved GeneratedCodeAttribute detection using proper type comparison
NamingFieldPascalUnderscore.cs Improved GeneratedCodeAttribute detection using proper type comparison
FavorDirectoryEnumerationCalls.cs Refactored to fix InvalidCastException and handle fully-qualified names
AttributesOnSeparateLines.cs Changed to skip generated code
UnusedLocalVariableTests.cs Added tests for generated code skipping and HelpLinkUri correctness
NamingFieldPascalUnderscoreTests.cs Added tests verifying proper GeneratedCodeAttribute detection
FavorEnumeratorDirectoryCallsTests.cs Added regression tests for generic methods, unresolved symbols, and fully-qualified names
DiagnosticUriBuilderTests.cs Added performance and whitespace handling tests
DateTimeConversionTests.cs Added test documenting analyzer crash with unresolvable types (test will fail)
AttributesOnSeparateLinesTests.cs Added test for generated code skipping
AsyncVoidTests.cs Added test documenting null safety (existing behavior)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant