Skip to content

fix: resolve core library types in IL post-processing under .NET reference assemblies - #4188

Open
BrianUnity wants to merge 1 commit into
develop-3.x.xfrom
fix/codegen-corlib-import-net10
Open

BrianUnity wants to merge 1 commit into
develop-3.x.xfrom
fix/codegen-corlib-import-net10

Conversation

@BrianUnity

@BrianUnity BrianUnity commented Oct 9, 2026 •

Copy link
Copy Markdown

Purpose of this PR

We're attempting to get packages compiling under MS Build and targeting .NET 10. When NGO's assemblies are compiled against .NET reference assemblies (for example when targeting .NET 10), the CodeGen post-processor cannot resolve core library types it imports through typeof().

PostProcessorReflectionImporter maps System.Private.CoreLib types to the module's mscorlib or netstandard reference. A module compiled against the .NET reference pack has neither: the pack splits the core library across System.Runtime, System.Collections and other assemblies. The imported type stays scoped to System.Private.CoreLib, and Resolve() returns null.

The fix: when the module references neither mscorlib nor netstandard, scope a System.Private.CoreLib type to the referenced assembly that defines or forwards it, with a per-type cache. Mapping everything to System.Runtime is not enough, because List<T>, for example, lives in System.Collections. Modules that reference mscorlib or netstandard take the old path, so existing builds are unchanged.

Entities and Multiplayer Tools have the same importer and get the same fix.

Jira ticket

None.

Changelog

com.unity.netcode.gameobjects

  • Fixed: Issue where the IL post-processor could not resolve core library types, such as Guid and List<T>, in assemblies compiled against .NET reference assemblies, for example when targeting .NET 10.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Tested with a Unity editor that compiles packages for .NET 10, on a project with NGO's EditMode tests, Entities and Multiplayer Tools (all three with this fix):

  • Before: compilation fails in IL post-processing.
  • After: no compile errors, and NGO EditMode tests pass (1370 pass; 1 failure in BasicBuildTest, which is unrelated).

Builds that target netstandard take the unchanged code path.

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Up-port

Not needed: this PR targets develop-3.x.x.

Backports

Not planned. .NET 10 targeting only applies to the newest editors, which use NGO 3.x. The importer on develop-2.0.0 differs only in its namespace, so the same change can go there if NGO 2.x needs it.

…rence assemblies

PostProcessorReflectionImporter mapped System.Private.CoreLib types only to a
referenced mscorlib or netstandard. Assemblies compiled against .NET reference
assemblies (net10) reference neither, so imported types such as Guid stayed
scoped to System.Private.CoreLib and Resolve() returned null.

When the module references neither, scope the type to the referenced assembly
that defines or forwards it.
@BrianUnity
BrianUnity marked this pull request as ready for review October 13, 2026 08:46
@BrianUnity
BrianUnity requested a review from a team as a code owner October 13, 2026 08:46
@u-pr

u-pr Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

⚠️ Some settings were ignored in '.pr_agent.toml (repository root)' repo settings

Check the configuration's TOML syntax, permitted settings, and size limit. See the error below.


Error message:
Ignored prohibited settings: github_app.handle_pr_actions. Permitted settings were applied.

Configuration content:
# This is the configuration for the u-pr bot
# https://github.cds.internal.unity3d.com/unity/u-pr
# For configuration of this file:
# https://developer.portal.internal.unity.com/catalog/default/component/u-pr/docs/configuration/automatic_runs/

[github_app]
handle_pr_actions = ['opened', 'ready_for_review']  # PR events that auto-run pr_commands
pr_commands       = ["/harness-review"]             # what runs on those events
reviewer_commands = ["/harness-review"]             # what runs when @u-pr is added as reviewer

@u-pr u-pr Bot 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.

💡 Harness Review

Ship it

The change adds per-type core-library scope resolution while preserving the existing corlib mapping. I examined the lookup, assembly resolver, CodeGen import order, and changelog and found no actionable issues.

Reviewed commit 0f62376

🤖 Helpful? 👍/👎

@michalChrobot

Copy link
Copy Markdown
Member

Is this related (solves) https://jira.unity3d.com/browse/UUM-155996?

@codecov-github-com

codecov-github-com Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@              Coverage Diff               @@
##           develop-3.x.x    #4188   +/-   ##
==============================================
  Coverage          78.26%   78.26%           
==============================================
  Files                153      153           
  Lines              26359    26359           
==============================================
  Hits               20631    20631           
  Misses              5728     5728           
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 77.28% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
com.unity.netcode.gameobjects 78.26% <ø> (ø)

ℹ️ Need help interpreting these results?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants