Skip to content

Commit 509902f

Browse files
test: record that the updater does not follow namespace aliases
The assertion added in 9022abd failed on CI, which is the informative outcome rather than a broken assertion: 'TimeNs.NetworkTickSystem' survived the update, so Unity's API updater does not rewrite a reference reached through a namespace alias. The mechanism looks to be that the alias itself still resolves - Unity.Netcode is very much alive - so only the member lookup inside it fails, and that is not a trigger. The same run shows the other two NetworkTickSystem sites migrating, the plain simple name among them, so this is specific to the alias form and not a general gap in what the updater covers. The expectation is therefore inverted to 'blocked', recording the limitation the way --collision-stub already records the resolution-failure one, and UNQUALIFIED_FORMS becomes a map so a form can be declared either way. Documented in the README and noted in the CHANGELOG, since a user who writes references this way has to fix them by hand - loudly, as a compile error naming the type, rather than silently.
1 parent 6b1659b commit 509902f

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

apiupdaterproject/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ reference to `NetworkTimeSystem` still resolves — to the stub — so it never
8484
If a future change ever makes the blocked row pass as "rewritten", the mechanism has changed and the
8585
one-sided-move conclusion needs revisiting.
8686

87+
### One reference form the updater does not migrate
88+
89+
`DeprecatedTimingUsage.cs` reaches `NetworkTickSystem` through a namespace alias
90+
(`using TimeNs = Unity.Netcode;` then `TimeNs.NetworkTickSystem`). The updater leaves that site alone,
91+
measured on CI. The alias itself still resolves - `Unity.Netcode` is very much alive - so only the
92+
member lookup inside it fails, and that does not appear to trigger a rewrite. Every other form in that
93+
file migrates, including the plain simple name.
94+
95+
The run asserts this as `blocked` rather than treating it as a bug to fix here. A user who writes
96+
references that way gets a compile error naming the type, so it is loud rather than silent, but it is
97+
worth knowing when someone reports that the upgrade "did not finish".
98+
8799
Default hub locations, if you need to pass `--unity` explicitly — note that on macOS the binary is
88100
inside the `.app` bundle rather than beside it:
89101

apiupdaterproject/run_upgrade_test.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@
7474

7575

7676
# Reference forms the per-type counts above cannot see, because the source never spells the type's
77-
# fully qualified name. 'TimeNs.NetworkTickSystem' in DeprecatedTimingUsage.cs goes through a
78-
# namespace alias and so matches neither the old nor the new spelling: without asserting on it
79-
# directly, the updater could leave that site unresolved and the run would still pass on the strength
80-
# of the other reference forms. The editor runs with -ignoreCompilerErrors, so nothing else catches it.
81-
UNQUALIFIED_FORMS = ['TimeNs.NetworkTickSystem']
77+
# fully qualified name, mapped to what the updater does with them.
78+
#
79+
# 'TimeNs.NetworkTickSystem' reaches the type through a namespace alias
80+
# ('using TimeNs = Unity.Netcode;'). The updater does not rewrite it - measured on CI, not assumed.
81+
# The alias itself still resolves, since Unity.Netcode is very much alive; only the member lookup
82+
# inside it fails, and that is apparently not a trigger. So this records the limitation, the same way
83+
# --collision-stub does, rather than asserting a fix that does not exist. A user who writes their
84+
# references this way gets a compile error naming the type and has to update it by hand.
85+
UNQUALIFIED_FORMS = {
86+
'TimeNs.NetworkTickSystem': 'blocked',
87+
}
8288

8389

8490
def expected_pairs():
@@ -277,12 +283,12 @@ def assert_rewritten(collision_stub):
277283
expect = 'blocked' if blocked else 'moved'
278284
print(f"{old:<72} {updated:>8} {stale:>6} {expect:>8} {'PASS' if passed else 'FAIL'}")
279285

280-
for form in UNQUALIFIED_FORMS:
286+
for form, expect in UNQUALIFIED_FORMS.items():
281287
survived = len(re.findall(re.escape(form) + boundary, all_text))
282-
passed = survived == 0
288+
passed = survived > 0 if expect == 'blocked' else survived == 0
283289
if not passed:
284290
failures += 1
285-
print(f"{form:<72} {'-':>8} {survived:>6} {'moved':>8} {'PASS' if passed else 'FAIL'}")
291+
print(f"{form:<72} {'-':>8} {survived:>6} {expect:>8} {'PASS' if passed else 'FAIL'}")
286292

287293
return failures
288294

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1919
- `Unity.Netcode.Editor.CodeGen``Unity.Netcode.GameObjects.Editor.CodeGen`
2020
- `Unity.Netcode.Editor.PackageChecker``Unity.Netcode.GameObjects.Editor.PackageChecker`
2121
- `Unity.Netcode.Editor.Tests``Unity.Netcode.GameObjects.Editor.Tests`
22-
- The timing types moved out of the `Unity.Netcode` namespace into `Unity.Netcode.GameObjects.Timing`. The assembly is unchanged, and existing scripts are migrated automatically when the package is upgraded. The exception is a reference another installed package still resolves under `Unity.Netcode`: the updater only rewrites references that fail to resolve, so those have to be updated by hand.
22+
- The timing types moved out of the `Unity.Netcode` namespace into `Unity.Netcode.GameObjects.Timing`. The assembly is unchanged, and existing scripts are migrated automatically when the package is upgraded. The exception is a reference another installed package still resolves under `Unity.Netcode`: the updater only rewrites references that fail to resolve, so those have to be updated by hand. A reference reached through a namespace alias is also left alone, and reports as a compile error naming the type.
2323
- `Unity.Netcode.NetworkTime``Unity.Netcode.GameObjects.Timing.NetworkTime`
2424
- `Unity.Netcode.NetworkTimeSystem``Unity.Netcode.GameObjects.Timing.NetworkTimeSystem`
2525
- `Unity.Netcode.NetworkTickSystem``Unity.Netcode.GameObjects.Timing.NetworkTickSystem`

0 commit comments

Comments
 (0)