Skip to content

[Analyzer] Fix Source Generator Connection type collision#9734

Merged
tobias-tengler merged 1 commit into
mainfrom
tte/fix-source-generator-connection-type-collision
May 18, 2026
Merged

[Analyzer] Fix Source Generator Connection type collision#9734
tobias-tengler merged 1 commit into
mainfrom
tte/fix-source-generator-connection-type-collision

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 18, 2026 19:18
Copy link
Copy Markdown
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

Fixes a Source Generator–introduced connection type collision by aligning FactoryTypeReference.GetHashCode with its Equals implementation. Previously Equals used SyntaxComparer.BySyntax for TypeStructure but GetHashCode relied on the default reference-based hash of ITypeNode, so semantically equal type references hashed differently and connection type deduplication failed.

Changes:

  • Use SyntaxComparer.BySyntax.GetHashCode(TypeStructure) in FactoryTypeReference.GetHashCode to match Equals.
  • Add integration test fixtures (GetBooks, GetFavoriteBooks) exercising two paginated fields over the same element type.
  • Add new schema snapshot test Schema_Snapshot_Without_ConnectionName_Inference and update existing snapshot to cover both inferred and non-inferred connection naming.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/HotChocolate/Core/src/Types/Types/Descriptors/TypeReferences/FactoryTypeReference.cs Make GetHashCode consistent with Equals via SyntaxComparer.BySyntax.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/Product.cs Add two [UsePaging] queries over IEnumerable<Book> to reproduce the collision.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/IntegrationTests.cs Add snapshot test with InferConnectionNameFromField = false.
.../snapshots/IntegrationTests.Schema_Snapshot.snap Updated snapshot now includes distinct BooksConnection/FavoriteBooksConnection.
.../snapshots/IntegrationTests.Schema_Snapshot_Without_ConnectionName_Inference.snap New snapshot showing both fields share a single BookConnection when inference is off.

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

@tobias-tengler tobias-tengler merged commit 67cf306 into main May 18, 2026
141 of 143 checks passed
@tobias-tengler tobias-tengler deleted the tte/fix-source-generator-connection-type-collision branch May 18, 2026 19: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