[Analyzer] Add analyzer for conflicting [ID] attribute usage#9828
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Roslyn analyzer to detect conflicting [ID] attribute value-type bindings (same effective ID type name mapped to different runtime value types) within a single declaring type, along with extensive snapshot-based tests and diagnostic resource wiring.
Changes:
- Introduces
ConflictingIdAttributeAnalyzer(HC0115) and registers the diagnostic descriptor/resource string. - Updates analyzer test harness to run the new analyzer and adds comprehensive snapshot tests covering scalars, nullability, collections, and task-like wrappers.
- Extends
WellKnownAttributeswith metadata names for[ID]/[ID<T>].
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs | Adds the new analyzer to the test harness analyzer list. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/ConflictingIdAttributeAnalyzerTests.cs | Adds new snapshot tests covering conflicting/non-conflicting [ID] scenarios. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/ConflictingIdAttributeAnalyzerTests.*.md | Snapshot outputs asserting emitted diagnostics and generated sources per test. |
| src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs | Adds metadata name constants for [ID] attributes. |
| src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx | Adds localized message format for the new diagnostic. |
| src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs | Adds strongly-typed accessor for the new resource string. |
| src/HotChocolate/Core/src/Types.Analyzers/Errors.cs | Registers diagnostic descriptor HC0115. |
| src/HotChocolate/Core/src/Types.Analyzers/ConflictingIdAttributeAnalyzer.cs | Implements the new analyzer logic for detecting conflicting [ID] value types. |
Files not reviewed (1)
- src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 3, 2026
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.