Skip to content

[Fusion] Resolve abstract types from raw UTF-8 type names for small implementer sets - #10084

Merged
michaelstaib merged 5 commits into
mainfrom
mst/typename-utf8
Jul 11, 2026
Merged

michaelstaib merged 5 commits into
mainfrom
mst/typename-utf8

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 10, 2026 12:15
@michaelstaib michaelstaib changed the title [Fusion] Resolve abstract types from raw UTF-8 type names for small i… [Fusion] Resolve abstract types from raw UTF-8 type names for small implementer sets Jul 10, 2026

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 PR optimizes abstract type resolution during value completion by avoiding string allocations when resolving __typename for small possible-type sets, using raw UTF-8 comparisons.

Changes:

  • Added SourceResultElement.TryGetRawStringValue(...) to expose raw UTF-8 bytes for non-escaped JSON strings.
  • Cached UTF-8 encoded type names on FusionObjectTypeDefinition (Utf8Name) for allocation-free comparisons.
  • Updated ValueCompletion.GetType(...) to resolve abstract types via raw UTF-8 __typename matching for up to 8 candidates, with a fallback to the existing string-based lookup.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs Adds an API to retrieve raw UTF-8 bytes for simple JSON string values.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Uses raw UTF-8 __typename to resolve abstract types for small implementer sets; narrows schema usage to fusion schema.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionObjectTypeDefinition.cs Stores a pre-encoded UTF-8 name to enable allocation-free type-name matching.

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

michaelstaib and others added 3 commits July 10, 2026 15:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Conflicts:
#	src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

94.0% of changed lines covered (94/100)

File Covered Changed Patch %
…/src/Fusion.Execution/Text/Json/SourceResultDocument.Text.cs 22 27 81.5% 🟡
…/src/Fusion.Execution/Execution/Results/ValueCompletion.cs 53 54 98.1% 🟡
…/src/Fusion.Execution.Types/FusionInterfaceTypeDefinition.cs 9 9 100.0% 🟢
…/src/Fusion.Execution/Execution/Nodes/OperationCompiler.cs 6 6 100.0% 🟢
…/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs 4 4 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "38e2c436121fa9c6484549603740375bd78c7b8d",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.Text.cs", "ranges": [[53, 57]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs", "ranges": [[1128, 1128]] }
  ]
}

Project coverage: 53.4% (227570/426362 lines)

@michaelstaib
michaelstaib merged commit 72261de into main Jul 11, 2026
147 checks passed
@michaelstaib
michaelstaib deleted the mst/typename-utf8 branch July 11, 2026 05:46
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