Fix Unity 6000.5 compile error: migrate GetInstanceID to EntityId (#12)#13
Conversation
Unity 6000.5 makes the obsolete Object.GetInstanceID() a CS0619 compile error. The sole call site (building a write-only UI Toolkit element name) now routes through a small ObjectIdExtensions.GetObjectIdString helper that uses Object.GetEntityId()/EntityId.ToULong on Unity 6000.4+ (where EntityId was introduced) and falls back to GetInstanceID() on older editors. Bootstraps the package's first EditMode test assembly. The helper is public because InternalsVisibleTo is not honored for this editor/test assembly pair in Unity (verified: internal access yields CS0122/CS1061 from the test assembly even with a correct friend attribute in the compiled editor DLL). Verified via clean CLI EditMode runs (0 compile errors, test passes) on Unity 6000.5.2f1 and 6000.4.6f1 (EntityId branch) and 2022.3.62f2 (legacy branch). Bumps package version to 0.0.35. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Working-notes per the repo's session conventions: PLAN.md tracks active items; progress/session-001 records the red-green verification and the InternalsVisibleTo investigation behind the public-helper decision. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes the Unity 6000.5 compilation break caused by Object.GetInstanceID() becoming an error by introducing an editor-only helper that switches to EntityId on Unity 6000.4+ while preserving the legacy path for older Unity versions. Adds an EditMode test assembly to validate the helper’s behavior and bumps the package version to a stable release.
Changes:
- Replace the
GetInstanceID()UI element naming usage withGetObjectIdString()to avoid CS0619 on Unity 6000.5. - Add
ObjectIdExtensions.GetObjectIdString()withUNITY_6000_4_OR_NEWERgating (EntityIdvs legacy InstanceID). - Introduce a first Editor test assembly + NUnit test covering non-empty/stable/unique numeric IDs; bump
package.jsonversion.
Reviewed changes
Copilot reviewed 7 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Editor/DataVisualizer/DataVisualizer.cs | Switches object-row element naming to use the new ID helper. |
| Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs | Adds the GetObjectIdString() helper with Unity-version conditional behavior. |
| Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs.meta | Unity asset metadata for the new extension file. |
| package.json | Bumps package version to 0.0.35. |
| Tests.meta | Unity asset metadata for the new Tests folder. |
| Tests/Editor.meta | Unity asset metadata for the new Tests/Editor folder. |
| Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef | Defines the Editor test assembly and its references. |
| Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef.meta | Unity asset metadata for the new test asmdef. |
| Tests/Editor/ObjectIdExtensionsTests.cs | Adds EditMode test verifying ID helper behavior across Unity branches. |
| Tests/Editor/ObjectIdExtensionsTests.cs.meta | Unity asset metadata for the new test file. |
| PLAN.md | Adds a tracked work item entry for Issue #12. |
| PLAN.md.meta | Unity asset metadata for PLAN.md. |
| progress.meta | Unity asset metadata for the new progress/ folder. |
| progress/session-001-issue-12-entityid-fix.md | Adds a session log describing the investigation and fix. |
| progress/session-001-issue-12-entityid-fix.md.meta | Unity asset metadata for the new session log. |
Files not reviewed (8)
- Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs.meta: Generated file
- PLAN.md.meta: Generated file
- Tests.meta: Generated file
- Tests/Editor.meta: Generated file
- Tests/Editor/ObjectIdExtensionsTests.cs.meta: Generated file
- Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef.meta: Generated file
- progress.meta: Generated file
- progress/session-001-issue-12-entityid-fix.md.meta: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - Helper `internal static string GetObjectIdString(this Object obj)` in new `Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs` (testable; keeps `#if` out of the 6000-line `DataVisualizer.cs`). Name deliberately avoids "stable" — instance/entity IDs are per-session only. | ||
| - Test access via `[assembly: InternalsVisibleTo("WallstopStudios.DataVisualizer.Tests.Editor")]`, following the existing `Runtime/DataVisualizer/BaseDataObject.cs` precedent (no AssemblyInfo.cs). | ||
| - Bootstrap `Tests/Editor` (first tests in this package), modeled on the sibling `unity-helpers` package's test asmdef. Single behavior-focused test; no bloat. |
There was a problem hiding this comment.
Fixed in 5f1194b — the "Decisions" section now states the final public helper choice (the initial internal + InternalsVisibleTo plan was proven non-functional for this editor→test assembly pair, detailed in the Investigation section).
Addresses a Copilot review comment on PR #13: the Decisions bullets still described the initial internal + InternalsVisibleTo plan, which the Investigation section supersedes. Updated to state the final public helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 15 changed files in this pull request and generated no new comments.
Files not reviewed (8)
- Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs.meta: Generated file
- PLAN.md.meta: Generated file
- Tests.meta: Generated file
- Tests/Editor.meta: Generated file
- Tests/Editor/ObjectIdExtensionsTests.cs.meta: Generated file
- Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef.meta: Generated file
- progress.meta: Generated file
- progress/session-001-issue-12-entityid-fix.md.meta: Generated file
…efault) Two deprecation-warning families surfaced on Unity 2023.2+/6000.x: - HorizontalToggle used the deprecated UxmlFactory/UxmlTraits custom-control system (9 warnings). The element is only ever created via `new HorizontalToggle()` in C# and is referenced by no .uxml in the package, so the UXML/UI-Builder support was dead code — removed. Code instantiation and its default values are unchanged. - EventBase.PreventDefault() is obsolete on 2023.2+ (15 call sites). All are KeyDownEvent handlers already paired with StopPropagation(), which consumes the event (FocusController.IgnoreEvent no-ops on KeyDownEvent, so it does not apply here). Added EventExtensions.PreventDefaultCompat, which calls PreventDefault() only under #if !UNITY_2023_2_OR_NEWER and is a no-op above that, and routed all 15 sites through it. The 2023.2 gate is exact: PreventDefault was verified (baseline compile on 2023.2.13f1) to start warning at exactly that version. Verified via clean CLI EditMode runs (0 errors, 0 CS0618, test passes) on 2023.2.13f1, 6000.5.2f1, 6000.4.6f1, and 2022.3.62f2, and on the live 6000.4.6f1 editor the Data Visualizer window opens with a clean console. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 20 changed files in this pull request and generated 1 comment.
Files not reviewed (10)
- Editor/DataVisualizer/Extensions/EventExtensions.cs.meta: Generated file
- Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs.meta: Generated file
- PLAN.md.meta: Generated file
- Tests.meta: Generated file
- Tests/Editor.meta: Generated file
- Tests/Editor/ObjectIdExtensionsTests.cs.meta: Generated file
- Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef.meta: Generated file
- progress.meta: Generated file
- progress/session-001-issue-12-entityid-fix.md.meta: Generated file
- progress/session-002-uxml-preventdefault-deprecations.md.meta: Generated file
Addresses a Copilot review comment: the legacy GetInstanceID() branch returns an int, so int.TryParse reflects the contract precisely (was long.TryParse). Verified on 2022.3.62f2: test passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 20 changed files in this pull request and generated no new comments.
Files not reviewed (10)
- Editor/DataVisualizer/Extensions/EventExtensions.cs.meta: Generated file
- Editor/DataVisualizer/Extensions/ObjectIdExtensions.cs.meta: Generated file
- PLAN.md.meta: Generated file
- Tests.meta: Generated file
- Tests/Editor.meta: Generated file
- Tests/Editor/ObjectIdExtensionsTests.cs.meta: Generated file
- Tests/Editor/WallstopStudios.DataVisualizer.Tests.Editor.asmdef.meta: Generated file
- progress.meta: Generated file
- progress/session-001-issue-12-entityid-fix.md.meta: Generated file
- progress/session-002-uxml-preventdefault-deprecations.md.meta: Generated file
…acts - Resolve PLAN.md/PLAN.md.meta both-added conflict by untracking them (kept as local, gitignored working artifacts per .gitignore). - Stop tracking progress/* and progress.meta (local-only session logs). - All other paths auto-merged cleanly; EntityId migration intact (all ID usage routes through ObjectIdExtensions.GetObjectIdString). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Fixes #12 — Unity 6000.5 turns the obsolete
Object.GetInstanceID()into a CS0619 compile error, which blocks the package from compiling on Unity6000.5.x.The single call site (
Editor/DataVisualizer/DataVisualizer.cs, building a write-only UI Toolkit element nameobject-item-row-{id}) now routes through a small helper:UnityEngine.EntityId/Object.GetEntityId()were introduced in Unity 6000.4 (the docs 404 on 6000.3), so the guard isUNITY_6000_4_OR_NEWER— note this differs from theUNITY_6000_3_OR_NEWERsuggested in the issue. The guard also silences the pre-error deprecation warning on 6000.4. The value is only used to build a unique UI element name (grep-confirmed it is never read back), so theint→ulongchange on 6000.4+ is inert.Tests
Bootstraps the package's first EditMode test assembly (
Tests/Editor/) with one behavior test asserting the id string is non-empty, stable across calls, distinct between objects, and numeric on both branches.Verification (red → green)
Reproduced the bug and verified the fix via clean-slate CLI EditMode runs (deleted
Library/ScriptAssemblies+Library/Bee, then-runTests):EntityIdDataVisualizer.cs(5890,43): error CS0619(only error)EntityIdGetInstanceIDCS1061(proves test is non-vacuous)Notes for reviewers
public? The helper needs to be reachable from the editor test assembly.InternalsVisibleTois not honored for this editor→test assembly pair in Unity's compilation — verified across two clean compiles: extension-syntax access gaveCS1061, static-syntax gaveCS0122 'inaccessible due to its protection level', even though the compiled editor DLL provably contains the correct friend attribute.publicon this editor-only utility is the robust choice; the rationale is captured in the class XML doc.0.0.35-rc05.6→0.0.35.CS0618warnings (UI ToolkitUxmlTraits/PreventDefault) on 6000.5 — non-blocking, a separate failure mode, left for a follow-up.🤖 Generated with Claude Code
Note
Low Risk
Editor-only compile and warning fixes with behavior-preserving keyboard handling; object IDs remain session-scoped UI names and are not persisted.
Overview
Makes the package compile cleanly on Unity 6000.5+ and clears related CS0618 UIToolkit warnings on 2023.2+.
Unity 6000.4+ object IDs: UI row naming no longer calls obsolete
GetInstanceID()directly. It uses newGetObjectIdString(EntityIdon 6000.4+, legacy instance ID otherwise) for write-only element names.UIToolkit deprecations: All
KeyDownEventhandlers switch fromPreventDefault()toPreventDefaultCompat(still callsPreventDefaultonly before Unity 2023.2; pairedStopPropagationunchanged).HorizontalToggledrops unusedUxmlFactory/UxmlTraitsbecause the control is only constructed from C#.Adds the first EditMode test assembly with coverage for
GetObjectIdString, bumpspackage.jsonto 0.0.35, and adds internal PLAN/progress notes.Reviewed by Cursor Bugbot for commit 7fa6bfb. Bugbot is set up for automated code reviews on this repo. Configure here.
Update — also clears Unity 2023.2+ CS0618 deprecation warnings (folded in)
Two deprecation-warning families that surface on Unity 2023.2+/6000.x are now fixed in this PR:
HorizontalToggleUxmlTraits (9 warnings): the deprecatedUxmlFactory/UxmlTraitscustom-control pair was removed. The element is only ever created vianew HorizontalToggle()in C# and is referenced by no.uxmlin the package, so its UXML/UI-Builder support was dead code. Code instantiation and default values are unchanged.EventBase.PreventDefault()(15 sites): all areKeyDownEventhandlers already paired withStopPropagation()(which consumes the event;FocusController.IgnoreEventno-ops onKeyDownEvent, so it doesn't apply). A newEventExtensions.PreventDefaultCompatcallsPreventDefault()only under#if !UNITY_2023_2_OR_NEWERand is a no-op above that; all 15 sites route through it.The
UNITY_2023_2_OR_NEWERgate is exact — a baseline compile on 2023.2.13f1 confirmedPreventDefaultstarts warning at precisely that version.Verification (0 errors, 0 CS0618, EditMode test passes) on the full matrix: 2023.2.13f1, 6000.5.2f1, 6000.4.6f1, 2022.3.62f2 (legacy path still calls
PreventDefaultthere with no warning). On the live 6000.4.6f1 editor, the Data Visualizer window opens with a clean console (bothHorizontalToggleinstances build; migrated handlers run cleanly).