Skip to content

[Analyzer] Add analyzer for conflicting [ID] attribute usage#9828

Merged
tobias-tengler merged 2 commits into
mainfrom
tte/conflicting-id-attribute-analyzer
Jun 3, 2026
Merged

[Analyzer] Add analyzer for conflicting [ID] attribute usage#9828
tobias-tengler merged 2 commits into
mainfrom
tte/conflicting-id-attribute-analyzer

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 3, 2026 08:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 WellKnownAttributes with 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.

@tobias-tengler tobias-tengler merged commit f9e257a into main Jun 3, 2026
279 of 282 checks passed
@tobias-tengler tobias-tengler deleted the tte/conflicting-id-attribute-analyzer branch June 3, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants