Skip to content

[Analyzer] Fix FactoryTypeReference cache collision for shared CLR types#9747

Merged
tobias-tengler merged 1 commit into
mainfrom
tte/fix-factory-type-reference-cache-collision
May 20, 2026
Merged

[Analyzer] Fix FactoryTypeReference cache collision for shared CLR types#9747
tobias-tengler merged 1 commit into
mainfrom
tte/fix-factory-type-reference-cache-collision

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 20, 2026 09:36
@tobias-tengler tobias-tengler force-pushed the tte/fix-factory-type-reference-cache-collision branch from 41ce99e to a2bcad2 Compare May 20, 2026 09:38
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 type resolution bug in HotChocolate’s source-generator type handling where FactoryTypeReference could incorrectly reuse a cached wrapper type across input vs output contexts for the same CLR type, leading to invalid schema/type resolution.

Changes:

  • Update FactoryTypeReference.Key to incorporate TypeContext (Input/Output) to prevent factory-cache collisions.
  • Add an analyzer integration regression case using a POCO (Shape) in both output (query result) and input (mutation argument) positions.
  • Update integration test schema snapshots to include the new query field, mutation root, and generated ShapeInput.

Reviewed changes

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

File Description
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/Types.cs Adds regression scenario: same CLR type used in query return and mutation argument to validate distinct input/output GraphQL types.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/snapshots/IntegrationTests.Schema_Snapshot.snap Updates expected schema snapshot to include Mutation, Shape, and ShapeInput.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/snapshots/IntegrationTests.Schema_Snapshot_Without_ConnectionName_Inference.snap Updates expected schema snapshot (variant) with Mutation, Shape, and ShapeInput.
src/HotChocolate/Core/src/Types/Types/Descriptors/TypeReferences/FactoryTypeReference.cs Disambiguates the factory cache key by appending TypeContext for non-None contexts.

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

@tobias-tengler tobias-tengler merged commit efdef06 into main May 20, 2026
141 checks passed
@tobias-tengler tobias-tengler deleted the tte/fix-factory-type-reference-cache-collision branch May 20, 2026 09:51
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