fix: Add unit tests and improve analyzers for handling generated code and diagnostics#399
Open
BenjaminMichaelis wants to merge 3 commits intomainfrom
Open
fix: Add unit tests and improve analyzers for handling generated code and diagnostics#399BenjaminMichaelis wants to merge 3 commits intomainfrom
BenjaminMichaelis wants to merge 3 commits intomainfrom
Conversation
IntelliTect.Analyzer/IntelliTect.Analyzer/Analyzers/FavorDirectoryEnumerationCalls.cs
Fixed
Show fixed
Hide fixed
Contributor
There was a problem hiding this comment.
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.
IntelliTect.Analyzer/IntelliTect.Analyzer.Test/DiagnosticUriBuilderTests.cs
Outdated
Show resolved
Hide resolved
IntelliTect.Analyzer/IntelliTect.Analyzer/DiagnosticUrlBuilder.cs
Outdated
Show resolved
Hide resolved
IntelliTect.Analyzer/IntelliTect.Analyzer.Test/DateTimeConversionTests.cs
Outdated
Show resolved
Hide resolved
5dd93f5 to
1a54f21
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.