Skip to content

Commit e47f27e

Browse files
Merge develop-3.x.x into fix/server-not-tracking-scene-handles-for-pre-loaded-scenes-up-port
2 parents b4710a1 + 4cc1694 commit e47f27e

54 files changed

Lines changed: 2606 additions & 57 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.yamato/_run-all.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,14 @@ run_all_project_tests_cmb_service_default:
444444
{% endfor -%}
445445
{% endfor -%}
446446
{% endfor -%}
447+
448+
449+
# Runs the NGO 2.x -> 3.x editor script upgrade validation (see api-updater-test.yml)
450+
run_all_api_updater_tests:
451+
name: Run All API Updater Tests
452+
dependencies:
453+
{% for platform in test_platforms.default -%}
454+
{% for editor in validation_editors.default -%}
455+
- .yamato/api-updater-test.yml#api_updater_test_{{ platform.name }}_{{ editor }}
456+
{% endfor -%}
457+
{% endfor -%}

.yamato/_triggers.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ pr_code_changes_checks:
116116
cancel_old_ci: true
117117

118118

119-
120-
121-
122-
123-
124119
# Unified (NGO + N4E) validation, on demand.
125120
# This job allows the Unified tests to be kicked off by commenting "/ci unified".
126121
# This is useful for PRs where pr_code_changes_checks doesn't trigger.
@@ -134,6 +129,18 @@ unified_pr_checks:
134129
cancel_old_ci: true
135130

136131

132+
# NGO 2.x -> 3.x on demand editor script upgrade validation.
133+
# This job allows the API updater test to be kicked off by commenting "/ci apiupdater".
134+
api_updater_pr_checks:
135+
name: API Updater checks [on demand]
136+
dependencies:
137+
- .yamato/_run-all.yml#run_all_api_updater_tests
138+
triggers:
139+
expression: |-
140+
pull_request.comment eq "apiupdater"
141+
cancel_old_ci: true
142+
143+
137144
# Run all tests on nightly basis.
138145
# Same subset as pull_request_trigger with addition of mobile/desktop/console tests and webgl builds
139146
# Those tests are all running on trunk and the default editor (since it's daily and running all of them would add a lot of overhead)

.yamato/api-updater-test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
4+
# DESCRIPTION--------------------------------------------------------------------------
5+
# This job validates the NGO 2.x -> 3.x upgrade path for editor scripts.
6+
# NGO 3.0 renamed the editor assembly and its namespaces (Unity.Netcode.Editor ->
7+
# Unity.Netcode.GameObjects.Editor), and every relocated public type carries a [MovedFrom] so that
8+
# Unity's API updater rewrites a 2.x project's editor scripts automatically on upgrade.
9+
# apiupdaterproject holds editor code written against the 2.x API; the job imports it with
10+
# -accept-apiupdate and asserts that every 2.x type reference was rewritten and none survived.
11+
# See apiupdaterproject/README.md.
12+
13+
14+
# TECHNICAL CONSIDERATIONS---------------------------------------------------------------
15+
# apiupdaterproject/Packages/manifest.json references the package by relative path
16+
# (file:../../com.unity.netcode.gameobjects), so the job tests the package as it sits in the repo
17+
# and needs no package-pack dependency.
18+
# The script restores the 2.x sources when it finishes, so the checkout is left unmodified and the
19+
# job is safe to re-run on the same agent.
20+
# --clean purges Library first: the assertion is meaningless against a warm Library that already
21+
# holds rewritten sources from a previous run.
22+
23+
{% for platform in test_platforms.default -%}
24+
{% for editor in validation_editors.default -%}
25+
api_updater_test_{{ platform.name }}_{{ editor }}:
26+
name : API Updater Test - NGO 2.x editor scripts upgrade [{{ platform.name }}, {{ editor }}]
27+
agent:
28+
type: {{ platform.type }}
29+
image: {{ platform.image }}
30+
flavor: {{ platform.flavor }}
31+
commands:
32+
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor # Installing basic editor for the import
33+
- python apiupdaterproject/run_upgrade_test.py --unity .Editor --clean
34+
artifacts:
35+
logs:
36+
paths:
37+
- "apiupdaterproject/upgrade-test.log"
38+
dependencies:
39+
- .yamato/_run-all.yml#run_quick_checks # initial checks to perform fast validation of common errors
40+
{% endfor -%}
41+
{% endfor -%}

apiupdaterproject/.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Asset meta data should only be ignored when the corresponding asset is also ignored
18+
!/[Aa]ssets/**/*.meta
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
29+
# Gradle cache directory
30+
.gradle/
31+
32+
# Autogenerated VS/MD/Consulo solution and project files
33+
ExportedObj/
34+
.consulo/
35+
*.csproj
36+
*.unityproj
37+
*.sln
38+
*.suo
39+
*.tmp
40+
*.user
41+
*.userprefs
42+
*.pidb
43+
*.booproj
44+
*.svd
45+
*.pdb
46+
*.mdb
47+
*.opendb
48+
*.VC.db
49+
50+
# Unity3D generated meta files
51+
*.pidb.meta
52+
*.pdb.meta
53+
*.mdb.meta
54+
55+
# Unity3D generated file on crash reports
56+
sysinfo.txt
57+
58+
# Builds
59+
*.apk
60+
*.aab
61+
*.unitypackage
62+
63+
# Crashlytics generated file
64+
crashlytics-build.properties
65+
66+
# Packed Addressables
67+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
68+
69+
# Temporary auto-generated Android Assets
70+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
71+
/[Aa]ssets/[Ss]treamingAssets/aa/*
72+
/[Aa]ssets/[Ss]treamingAssets/BuildInfo.json
73+
/[Aa]ssets/[Ss]treamingAssets/BuildInfo.json.meta
74+
75+
InitTestScene*
76+
77+
# API updater test run log
78+
upgrade-test.log

apiupdaterproject/AGENTS.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# apiupdaterproject — agent notes
2+
3+
Background for anyone changing this project or the relocation metadata it tests. `README.md` covers
4+
what it is and how to run it; this file covers why it is built this way and what will bite you.
5+
6+
## Orientation
7+
8+
* This is a standalone Unity project at the repo root. It is not part of `testproject` or
9+
`minimalproject`, and the package does not reference it.
10+
* It validates one thing end to end: that a project written against the **NGO 2.x** editor API is
11+
migrated automatically by Unity's API updater when the package is upgraded to **3.x**.
12+
* **The mechanism it tests does not live here.** The `[MovedFrom]` attributes are on the real types in
13+
`com.unity.netcode.gameobjects/Editor/**`. This project only consumes them.
14+
* **Do not "fix" the sources under `Assets/Editor`.** They are deliberately written against the 2.x
15+
API and are the input to the test. A helpful cleanup there silently guts it.
16+
* The expected-type list in `run_upgrade_test.py` is frozen: it enumerates the public editor API of
17+
`develop-2.0.0`, which is released and cannot change. It only needs extending if a public editor
18+
type is relocated again within 3.x.
19+
* CI runs it on demand only — comment `/ci apiupdater` on a PR. See `.yamato/api-updater-test.yml`.
20+
* **Opening this project locally mutates it.** Unity rewrites `ProjectVersion.txt` to whatever editor
21+
opened it, and the package manager can add builtin modules to `Packages/manifest.json` that only
22+
exist in that editor — `com.unity.modules.smartstrings` from a 6000.7 alpha broke the 6000.6 CI job
23+
exactly this way. Check `git diff` on those two files before committing, and keep the manifest to
24+
modules that exist in the editor the job downloads (`validation_editors.default`).
25+
* Verified beyond this project: a real sample project upgraded 7 of its own scripts automatically,
26+
including a `NetcodeEditorBase<T>` subclass.
27+
28+
## Why not `[Obsolete(... (UnityUpgradable))]` skeletons
29+
30+
That is the other mechanism for this, and it was measured first: a second assembly declaring an empty
31+
skeleton of each 2.x type under the old namespace, each carrying
32+
`[Obsolete("... (UnityUpgradable) -> [asm] ns.Type", true)]`. It works for every non-generic type, but
33+
34+
* it **cannot** relocate a generic type — a target carrying a type argument list is treated as a
35+
same-namespace *rename*, so the namespace and assembly are dropped (see the table below), which
36+
left `NetcodeEditorBase<TT>` needing `MovedFrom` anyway;
37+
* it costs a second assembly and a hand-maintained parallel API surface that has to track the real
38+
one's `#if` guards and eventually be deleted;
39+
* it leaves the stale `using` directives and expands namespace aliases at the reference site, where
40+
`MovedFrom` removes the dead usings and rewrites aliases in place.
41+
42+
What it buys, and `MovedFrom` does not, is a better error when the user *declines* the update:
43+
`'NetworkManagerEditor' is obsolete: ... Use Unity.Netcode.GameObjects.Editor.NetworkManagerEditor
44+
instead` rather than a bare CS0246. It is also the only route for member-level redirects (a renamed
45+
method, a changed signature) and for type *renames*, which `MovedFrom` explicitly does not support.
46+
Neither applies to this change — it is a pure relocation.
47+
48+
## Measured behaviour
49+
50+
Probed against 6000.7.0a5 with throwaway types, for a namespace + assembly move:
51+
52+
| Mechanism / `(UnityUpgradable)` target form | Non-generic type | Generic type |
53+
| --- | --- | --- |
54+
| `[Asm] Ns.Type` | rewritten, fully qualified | name replaced, namespace dropped |
55+
| `[Asm] Ns.Type<TT>` | n/a | name replaced, namespace dropped (a no-op when the name is unchanged) |
56+
| ``[Asm] Ns.Type`1`` | n/a | backtick emitted into the source verbatim |
57+
| `* [Asm] Ns.Type<TT>` | n/a | not rewritten |
58+
| `[MovedFrom(true, oldNs, oldAsm, null)]` | rewritten, fully qualified | rewritten, fully qualified |
59+
60+
Reference forms `MovedFrom` was confirmed to handle, via `Assets/Editor/DeprecatedApiUsage.cs` and
61+
`Assets/Editor/DeprecatedApiUsageQualified.cs`: `using` + simple name, fully qualified name, namespace
62+
alias, type alias, base type, `typeof`, and generic type argument. The dead
63+
`using Unity.Netcode.Editor;` directives are removed and namespace aliases are rewritten in place
64+
rather than expanded at each use.
65+
66+
## Known gap: assembly definition references
67+
68+
The updater rewrites C# source only; it does not touch `.asmdef` files.
69+
70+
References made **by GUID** — the Unity default — keep working untouched. A GUID reference resolves
71+
to whichever `.asmdef` *asset* carries that GUID, independent of the `name` field inside it, and
72+
`Editor/Unity.Netcode.Editor.asmdef` kept both its path and its GUID through the rename. So a 2.x
73+
project referencing it by GUID silently ends up referencing `Unity.Netcode.GameObjects.Editor`.
74+
75+
References made **by name** (`"Unity.Netcode.Editor"`) no longer resolve and have to be repointed at
76+
`Unity.Netcode.GameObjects.Editor` by hand. The same applies to the other renamed assemblies:
77+
`Unity.Netcode.Editor.CodeGen` and `Unity.Netcode.PackageChecker.Editor`. Nothing can be done about
78+
this from the package side — reviving the old assembly name is not an option, because
79+
`Unity.Netcode.Editor` differs from N4E's `Unity.NetCode.Editor` only by the case of one letter and
80+
the two `Library/ScriptAssemblies/*.dll` filenames collide when both packages are installed. Removing
81+
that collision is what the 3.0 rename is for.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: e651dbb3fbac04af2b8f5abf007ddc23, type: 3}
13+
m_Name: DefaultNetworkPrefabs
14+
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkPrefabsList
15+
IsDefault: 1
16+
List: []

apiupdaterproject/Assets/DefaultNetworkPrefabs.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apiupdaterproject/Assets/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Update only if new public editor API is added to NGO v2.x.x.
2+
// It is used to validate the upgrade test. See ../../README.md.
3+
#pragma warning disable 169 // Ignore field is never used warnings
4+
5+
using ApiUpdaterProject;
6+
using Unity.Netcode.Editor;
7+
using Unity.Netcode.Editor.Configuration;
8+
9+
namespace ApiUpdaterProject.Editor
10+
{
11+
internal class DeprecatedApiUsage
12+
{
13+
// Unity.Netcode.Editor -> Unity.Netcode.GameObjects.Editor
14+
private NetworkPrefabsEditor m_NetworkPrefabsEditor;
15+
private HiddenScriptEditor m_HiddenScriptEditor;
16+
private UnityTransportEditor m_UnityTransportEditor;
17+
private NetworkAnimatorEditor m_NetworkAnimatorEditor;
18+
private NetworkRigidbodyEditor m_NetworkRigidbodyEditor;
19+
private NetworkRigidbody2DEditor m_NetworkRigidbody2DEditor;
20+
private NetcodeEditorBase<UpgradeProbeBehaviour> m_NetcodeEditorBase;
21+
private NetworkBehaviourEditor m_NetworkBehaviourEditor;
22+
private NetworkManagerEditor m_NetworkManagerEditor;
23+
private NetworkManagerHelper m_NetworkManagerHelper;
24+
private NetworkObjectEditor m_NetworkObjectEditor;
25+
private NetworkRigidbodyBaseEditor m_NetworkRigidbodyBaseEditor;
26+
private NetworkTransformEditor m_NetworkTransformEditor;
27+
28+
// Unity.Netcode.Editor.Configuration -> Unity.Netcode.GameObjects.Editor.Configuration
29+
private NetcodeForGameObjectsProjectSettings m_ProjectSettings;
30+
private NetworkPrefabProcessor m_NetworkPrefabProcessor;
31+
}
32+
}

apiupdaterproject/Assets/Editor/DeprecatedApiUsage.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)