chore: runtime/timing classes moved to unity.netcode.gameobjects.timing namespace - #4150
Draft
NoelStephensUnity wants to merge 4 commits into
Draft
chore: runtime/timing classes moved to unity.netcode.gameobjects.timing namespace#4150NoelStephensUnity wants to merge 4 commits into
NoelStephensUnity wants to merge 4 commits into
Conversation
Adds the input and the assertions for moving NetworkTime, NetworkTimeSystem and NetworkTickSystem out of Unity.Netcode, ahead of the move itself. Assets/Runtime/DeprecatedTimingUsage.cs names all three in every reference form the editor project already covers, plus a constructor call, and names each one fully qualified at least once so a blocked run can tell "was not rewritten" from "was never referenced". EXPECTED_TYPES becomes EXPECTED_MOVES, grouped by relocation. The old list derived the 3.x name by substituting the namespace prefix, which only works while every move shares one destination; stating the namespace pair once per move keeps a type's two names from drifting and admits a second destination. Both match counts now take a trailing-token boundary, without which Unity.Netcode.NetworkTime also counts every Unity.Netcode.NetworkTimeSystem. --collision-stub is the regression test for why the move exists. It installs an assembly occupying the two names Netcode for Entities would take, and inverts the expectation for exactly those two: a reference that still resolves never reaches the MovedFrom data, so it cannot be migrated. NetworkTickSystem is deliberately absent from the stub and must still migrate, so a pass proves both halves rather than merely failing. The stub lives in a folder ending in '~' and is inert until the flag copies it in. Not run locally: there is no Python on the development machine, so this is verified by /ci apiupdater. The namespace-only form of MovedFrom is also unmeasured until then - every case in the AGENTS.md table moved the assembly too - and AGENTS.md now records that gap along with the one reference form the assertions deliberately do not depend on.
Runtime/Timing moves out of the Unity.Netcode root so that correcting the casing of Netcode for Entities' Unity.NetCode namespace does not collide with it. Two of the names are the collision: NetworkTime and NetworkTimeSystem exist in both SDKs as unrelated types - a time value here, an IComponentData carrying prediction-loop state there - and two assemblies exporting one fully qualified name is CS0433, which no user can work around in source. The three public types carry [MovedFrom(true, "Unity.Netcode", null, null)], so existing scripts are rewritten on upgrade. sourceAssembly is null because Unity.Netcode.Runtime keeps its name and a null argument is read as "unchanged"; the editor relocation passed an assembly name because that one genuinely moved assemblies. The three internal types in the folder carry nothing - the attribute only matters for API the updater has to migrate. Consumers take an import rather than a qualified name at each site. Qualification was the first approach and it is wrong here: .editorconfig sets IDE0001 to error, so a fully qualified name that the simplifier can shorten fails the Standards job. That leaves NGO's own references reading the bare name, which is correct as long as nothing else occupies Unity.Netcode.NetworkTime - if Netcode for Entities takes those names without vacating them, this assembly stops compiling wherever both packages are installed. That is deliberate: it fails early and loudly in our own CI rather than silently in user projects, and the recommendation both halves of this work rest on is that neither SDK keeps those names in the shared root. Files whose declared namespace is exactly Unity.Netcode cannot use an import for the two colliding names at all - the enclosing namespace's members beat both using directives and using aliases (CS0576) - so if the one-sided case ever has to be supported, those five files need qualified names and the rest do not. Sub-namespaces such as Unity.Netcode.Components never walk that far up and are fine either way. NetworkTimeSystem and AnticipationSystem now import Unity.Netcode themselves, and the five Components.NetworkTransform doc references in NetworkTimeSystem are spelled in full, since that prefix was only reachable from inside the root namespace. Compile-checked: runtime (with and without UNITY_EDITOR), editor, runtime tests and editor tests all clean, the last except the known environmental CS0656 on BytePackerTests. The UNIFIED_NETCODE path is not covered - the harness has no Entities or NetCode references - so UnifiedNetcodeTransport was checked by reading it: IRealTimeProvider at line 207 is a type position, so its import is needed.
…mespace xref targets are fully qualified UIDs, so the one in networktime-ticks.md stopped resolving when the type moved. DocFX renders an unresolved xref as its raw text, which reads as a broken link on the published page rather than failing anything in this repo - there is no docfx job here. Nothing else in Documentation~ needs changing. Every code sample that touches these types reaches them through NetworkManager (LocalTime.TimeAsFloat, NetworkTickSystem.Tick), which never names the type and is unaffected; the remaining mentions are prose or links to this same page. The old names in apiupdaterproject/README.md and the CHANGELOG are the 2.x side of before/after tables and are correct as they stand. No upgrade note added. The samples on that page do not need the new import, so a note about it would be advice for a reader the page does not have, and the landed editor relocation set the precedent of updating the affected sample without prose. The CHANGELOG entry covers the move.
The --collision-stub mode was added with the timing relocation but never wired into the job, so /ci apiupdater only ever exercised the default path and the regression test for the reason the move exists could not actually run in CI. Two sequential commands rather than one invocation: each needs its own cold import, since the assertion is meaningless against a Library that already holds rewritten sources. The script removes the stub and restores the 2.x sources on every exit path, so the second run starts from the state the first one did. The on-demand trigger is `pull_request.comment eq "apiupdater"` with no draft exclusion, so this runs on #4150 while it sits in draft. Neither mode needs Netcode for Entities present - the default mode tests NGO's own 2.x to 3.x migration, and the stub mode uses the local stub rather than the real package - so the run does not have to wait on the N4E namespace work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE:
N4E migration of NetworkTime and NetworkTimeSystem must be merged before taking this project out of draft!
Purpose of this PR
Since NGO will be dependent upon N4E and N4E is going to be updating their root namespace from
Unity.NetCodetoUnity.Netcode, there is a conflict withNetworkTimeandNetworkTimeSystem.This PR migrates NGO's time related classes into
Unity.Netcode.GameObjects.Timing.Jira ticket
MTT-15570
Changelog
Unity.Netcode.GameObjects.Timingnamespace.Documentation
Testing & QA (How your changes can be verified during release Playtest)
Manual testing can be performed by migrating an existing NGO v2.x.x project to NGO v3.x.x.
(Once N4E has made the namespace change)
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by modified APIUpdater automated testCovered by new automated testsDoes 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
N/A
Backports
N/A