Skip to content

Fix source generator edge type for connections in referenced assemblies - #10298

Merged
glen-84 merged 1 commit into
mainfrom
gai/cross-assembly-connection-edge-type
Aug 26, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/cross-assembly-connection-edge-type

Conversation

@glen-84

@glen-84 glen-84 commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • The source generator now binds a connection's Edges field to the generated edge type (for example AuthorEdgeType) when the connection class is declared in a referenced assembly. Previously it emitted the bare runtime symbol name (PageEdge, or a custom PageEdge<T> subclass), which produced generated code that did not compile (CS0234 / CS0311).
  • TestHelper gains CreateReference and a GetGeneratedSourceSnapshot overload that accepts additional metadata references, so analyzer tests can place types in a separate assembly.

Test plan

  • New PagingTests snapshot tests for a PageConnection<T> subclass and for a ConnectionBase connection with a PageEdge<T> subclass, both declared in a referenced assembly
  • Both snapshots captured emit diagnostics before the fix and are clean after it; verified on net8.0, net9.0, net10.0, and net11.0
  • Full HotChocolate.Types.Analyzers.Tests project passes (339 tests, net10.0)

Closes #10141

Copilot AI lite review requested due to automatic review settings August 26, 2026 13:35

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

This pull request fixes a HotChocolate Types source generator edge-case where connection Edges fields were bound to an invalid edge CLR type when the connection/edge runtime types come from a referenced assembly, causing generated code to fail compilation. It also extends the analyzer test infrastructure to compile and reference an additional in-memory assembly, allowing coverage of cross-assembly symbol-binding scenarios.

Changes:

  • Fix connection type transformation to use the generated edge GraphQL type wrapper name (e.g., AuthorEdgeType) instead of the runtime edge symbol name when building ConnectionTypeInfo.
  • Add TestHelper.CreateReference and a GetGeneratedSourceSnapshot overload that accepts additional MetadataReferences.
  • Add new paging snapshot tests covering PageConnection<T> and ConnectionBase<...> cases where the connection/edge types live in a referenced assembly.

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/test/Types.Analyzers.Tests/TestHelper.cs Centralizes baseline Roslyn references, adds in-memory referenced-assembly compilation, and allows passing extra metadata references into snapshot generation.
src/HotChocolate/Core/test/Types.Analyzers.Tests/PagingTests.cs Adds new snapshot tests that reproduce and validate the cross-assembly paging/edge binding scenario.
src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/PagingTests.GenerateSource_Inherit_From_PageConnection_In_Referenced_Assembly.md New snapshot validating correct edge wrapper binding for a PageConnection<T> subclass in a referenced assembly.
src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/PagingTests.GenerateSource_Inherit_From_ConnectionBase_PageEdge_In_Referenced_Assembly.md New snapshot validating correct edge wrapper binding for ConnectionBase<...> with a PageEdge<T> subclass in a referenced assembly.
src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ConnectionTypeTransformer.cs Corrects edge type name propagation by using edgeTypeInfo.Name when creating ConnectionTypeInfo in the non-generic connection branch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (1/1)

File Covered Changed Patch %
…/src/Types.Analyzers/Inspectors/ConnectionTypeTransformer.cs 1 1 100.0% 🟢

Project coverage: 56.3% (265116/470693 lines)

@glen-84
glen-84 merged commit 63362b1 into main Aug 26, 2026
152 checks passed
@glen-84
glen-84 deleted the gai/cross-assembly-connection-edge-type branch August 26, 2026 13:45
This was referenced Aug 29, 2026
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.

[Source Generator] Cross-assembly pagination types lose generic arguments in ConnectionTypeFileBuilder

2 participants