Add CA1812 suppressor for internal classes used as type parameters#116
Draft
Add CA1812 suppressor for internal classes used as type parameters#116
Conversation
Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Suppress CA1812 warning for referenced type parameters
Add CA1812 suppressor for internal classes used as type parameters
Nov 30, 2025
ronnygunawan
requested changes
Nov 30, 2025
Owner
ronnygunawan
left a comment
There was a problem hiding this comment.
Add test cases where this suppressor suppresses an actual warning
…nostics Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Contributor
Author
Added integration tests using a mock CA1812 analyzer that verifies actual suppression behavior. The new tests cover:
Commit: a0a3f09 |
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.
CA1812 ("Avoid uninstantiated internal classes") produces false positives when internal classes are instantiated via reflection or external code (e.g., JSON deserializers, DI containers). This adds a
DiagnosticSuppressorto suppress CA1812 when the class is referenced as a type argument.Changes
CA1812Suppressor.cs: New suppressor (RGS001) that scans for type argument usage in generic invocations, generic types, andtypeofexpressionsCA1812SuppressorTests.cs: Unit tests for suppressor descriptor properties and integration tests that verify actual CA1812 suppression behavior using a mock analyzerREADME.md: Documentation under new "Suppressions" sectionExample
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.