Skip to content

fix: NGO CoreCLR compatibility - #4171

Open
NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/coreclr-compatibility
Open

NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/coreclr-compatibility

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Purpose of this PR

Resolves the NGO CoreCLR test failures and re-enables every test that was disabled for CoreCLR.

Jira ticket

UUM-149592 - NetworkVariable serialization codegen not generated for some types

  • CoreCLR enforces generic constraints on method instantiations and Mono does not. The ILPP-generated NetworkVariableSerializationHelper.InitializeSerialization emitted InitializeEqualityChecker_HashSet<HashSet>, which violates T : IEquatable, so CoreCLR rejected the whole method and every type registered by that assembly fell back to FallbackSerializer.
  • Removed the IEquatable constraint from InitializeEqualityChecker_HashSet and EqualityEqualsHashSet.
  • NetworkBehaviourILPP now validates every emitted serializer and equality checker call against its generic constraints, and reports a compile error instead of emitting IL that CoreCLR rejects.

UUM-149591 - integration tests fail to start server and client instances

  • Mostly a consequence of UUM-149592: player prefabs with NetworkVariables threw during synchronization, so connections never completed.
  • PeerDisconnectCallbackTests assumed client ids follow creation order. It now finds the target client by id.

UUM-149595 - DAHost player-prefab fetch throws "An item with the same key has already been added"

  • NetworkClientAndPlayerObjectTests never cleared m_ChangedPlayerPrefabs between tests and keyed each fetched prefab on the last client's id. It now clears the dictionary on teardown and keys on the fetching client.

UUM-149597 - unexpected owner write-permission error

  • OwnerPermissionHideTests assumed client ids follow creation order. Each object's owner is now chosen by client id.

UUM-150429 - Re-enable com.unity.netcode tests disabled for CoreCLR

  • Removed all ENABLE_CORECLR [Explicit] and [UnityCoreClrExplicitDisabled] attributes. Every previously disabled test passes on CoreCLR (833/833), and the full PlayMode (5423 passed, 0 failed) and EditMode (1371 passed) suites pass on a trunk CoreCLR editor.

Changelog

NA

Documentation

  • No documentation changes or additions were necessary.

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

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

No up-port needed.

Backports

No back-port needed.

Resolves the NGO CoreCLR test failures and re-enables every test that was disabled for CoreCLR.

UUM-149592 - NetworkVariable serialization codegen not generated for some types
- CoreCLR enforces generic constraints on method instantiations and Mono does not. The ILPP-generated
  NetworkVariableSerializationHelper.InitializeSerialization emitted
  InitializeEqualityChecker_HashSet<HashSet<int>>, which violates T : IEquatable<T>, so CoreCLR rejected
  the whole method and every type registered by that assembly fell back to FallbackSerializer.
- Removed the IEquatable<T> constraint from InitializeEqualityChecker_HashSet<T> and
  EqualityEqualsHashSet<T>. Neither uses it, and #3891 already removed it from the rest of the HashSet
  serialization path to support nested HashSets.
- NetworkBehaviourILPP now validates every emitted serializer and equality checker call against its
  generic constraints, and reports a compile error instead of emitting IL that CoreCLR rejects.

UUM-149591 - integration tests fail to start server and client instances
- Mostly a consequence of UUM-149592: player prefabs with NetworkVariables threw during synchronization,
  so connections never completed.
- PeerDisconnectCallbackTests assumed client ids follow creation order. It now finds the target client
  by id.

UUM-149595 - DAHost player-prefab fetch throws "An item with the same key has already been added"
- NetworkClientAndPlayerObjectTests never cleared m_ChangedPlayerPrefabs between tests and keyed each
  fetched prefab on the last client's id. It now clears the dictionary on teardown and keys on the
  fetching client.

UUM-149597 - unexpected owner write-permission error
- OwnerPermissionHideTests assumed client ids follow creation order. Each object's owner is now chosen
  by client id.

Removed all ENABLE_CORECLR [Explicit] and [UnityCoreClrExplicitDisabled] attributes. Every previously
disabled test passes on CoreCLR (833/833), and the full PlayMode (5423 passed, 0 failed) and EditMode
(1371 passed) suites pass on a trunk CoreCLR editor.
@NoelStephensUnity
NoelStephensUnity marked this pull request as ready for review September 25, 2026 19:38
@NoelStephensUnity
NoelStephensUnity requested a review from a team as a code owner September 25, 2026 19:38
@u-pr

u-pr Bot commented Sep 25, 2026

Copy link
Copy Markdown

⚠️ 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

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 removes the unused HashSet equality constraint, validates generated serializer and equality calls, and re-enables CoreCLR tests. I examined the codegen paths, runtime equality behavior, client ID fixes, and test edits and found no actionable issues.

Reviewed commit 1892ab2

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@              Coverage Diff               @@
##           develop-3.x.x    #4171   +/-   ##
==============================================
  Coverage          78.19%   78.19%           
==============================================
  Files                153      153           
  Lines              26272    26272           
==============================================
  Hits               20544    20544           
  Misses              5728     5728           
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 76.65% <ø> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...kVariable/Serialization/NetworkVariableEquality.cs 90.86% <ø> (ø)
...orkVariable/Serialization/TypedILPPInitializers.cs 0.00% <ø> (ø)
Components Coverage Δ
com.unity.netcode.gameobjects 78.19% <ø> (ø)

ℹ️ Need help interpreting these results?

BuildPlayer in BasicBuildTest hangs past the job timeout on the ubuntu CI agents, for both 6000.7 and
trunk, while Windows and macOS pass. The same timeouts happen on the develop-3.x.x nightly. Ignored on
Linux editors only, as a temporary measure until the ubuntu CI issue is resolved.

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.

1 participant