-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Unity 6000.5 compile error: migrate GetInstanceID to EntityId (#12) #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
aef2c27
4d058a2
5f1194b
3a4d624
fcd7301
7fa6bfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| namespace WallstopStudios.DataVisualizer.Editor.Extensions | ||
| { | ||
| using UnityEngine.UIElements; | ||
|
|
||
| internal static class EventExtensions | ||
| { | ||
| /// <summary> | ||
| /// Prevents the event's default action on Unity versions where | ||
| /// <see cref="EventBase.PreventDefault"/> is supported. On Unity 2023.2+ that method | ||
| /// is obsolete, so this is a no-op there: every caller pairs it with | ||
| /// <see cref="EventBase.StopPropagation"/>, which consumes the event — the sanctioned | ||
| /// replacement for the KeyDownEvents handled here. FocusController.IgnoreEvent (the | ||
| /// other suggested replacement) only affects pointer/navigation events, so it is | ||
| /// intentionally not used. | ||
| /// </summary> | ||
| internal static void PreventDefaultCompat(this EventBase evt) | ||
| { | ||
| #if !UNITY_2023_2_OR_NEWER | ||
| evt.PreventDefault(); | ||
| #endif | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| namespace WallstopStudios.DataVisualizer.Editor.Extensions | ||
| { | ||
| using System.Globalization; | ||
| using UnityEngine; | ||
|
|
||
| /// <summary> | ||
| /// Helpers for deriving identifier strings from Unity objects. Public because the | ||
| /// package's editor test assembly cannot access internals of the editor assembly: | ||
| /// InternalsVisibleTo is not honored for this assembly pair in Unity's compilation | ||
| /// (verified — the internal type is reported CS0122 from the test assembly even with | ||
| /// a correct friend attribute compiled into the editor assembly). | ||
| /// </summary> | ||
| public static class ObjectIdExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns a per-session unique identifier string for the object, suitable for | ||
| /// building unique UI element names. NOT stable across editor sessions or domain | ||
| /// reloads; do not persist. | ||
| /// </summary> | ||
| public static string GetObjectIdString(this Object obj) | ||
| { | ||
| #if UNITY_6000_4_OR_NEWER | ||
| return EntityId.ToULong(obj.GetEntityId()).ToString(CultureInfo.InvariantCulture); | ||
| #else | ||
| return obj.GetInstanceID().ToString(CultureInfo.InvariantCulture); | ||
| #endif | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Plan | ||
|
|
||
| Active work items. Completed/obsolete items are removed after each session; history lives in `progress/`. | ||
|
|
||
| ## Active | ||
|
|
||
| - [ ] PR [#13](https://github.com/wallstop/DataVisualizer/pull/13) (branch `dev/wallstop/bug-fixes`) — Unity 6000.x compile-cleanliness. Open and green; awaiting merge (merge to `main` publishes 0.0.35 to npm). | ||
| - Issue #12 — CS0619: `Object.GetInstanceID()` → `EntityId` behind `UNITY_6000_4_OR_NEWER`; first EditMode tests; version bump to 0.0.35. Tracking: `progress/session-001-issue-12-entityid-fix.md`. | ||
| - CS0618 deprecations — remove dead `UxmlTraits`/`UxmlFactory` from `HorizontalToggle`; gate `EventBase.PreventDefault()` behind `UNITY_2023_2_OR_NEWER` via `EventExtensions.PreventDefaultCompat`. Tracking: `progress/session-002-uxml-preventdefault-deprecations.md`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| namespace WallstopStudios.DataVisualizer.Tests.Editor | ||
| { | ||
| using NUnit.Framework; | ||
| using UnityEngine; | ||
| using WallstopStudios.DataVisualizer.Editor.Extensions; | ||
|
|
||
| public sealed class ObjectIdExtensionsTests | ||
| { | ||
| [Test] | ||
| public void GetObjectIdStringIsNonEmptyStableAndUnique() | ||
| { | ||
| ScriptableObject first = ScriptableObject.CreateInstance<ScriptableObject>(); | ||
| ScriptableObject second = ScriptableObject.CreateInstance<ScriptableObject>(); | ||
| try | ||
| { | ||
| string firstId = first.GetObjectIdString(); | ||
| string secondId = second.GetObjectIdString(); | ||
|
|
||
| Assert.That(firstId, Is.Not.Null.And.Not.Empty); | ||
| Assert.That(secondId, Is.Not.Null.And.Not.Empty); | ||
| Assert.AreEqual( | ||
| firstId, | ||
| first.GetObjectIdString(), | ||
| "The id must be stable across repeated calls on the same object." | ||
| ); | ||
| Assert.AreNotEqual( | ||
| firstId, | ||
| secondId, | ||
| "Distinct objects must produce distinct ids." | ||
| ); | ||
| #if UNITY_6000_4_OR_NEWER | ||
| Assert.IsTrue( | ||
| ulong.TryParse(firstId, out _), | ||
| "The EntityId branch must produce a numeric (ulong) id string." | ||
| ); | ||
| #else | ||
| Assert.IsTrue( | ||
| int.TryParse(firstId, out _), | ||
| "The legacy InstanceID branch must produce a numeric (int) id string." | ||
| ); | ||
| #endif | ||
| } | ||
| finally | ||
| { | ||
| Object.DestroyImmediate(first); | ||
| Object.DestroyImmediate(second); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "name": "WallstopStudios.DataVisualizer.Tests.Editor", | ||
| "rootNamespace": "WallstopStudios.DataVisualizer.Tests.Editor", | ||
| "references": [ | ||
| "UnityEditor.TestRunner", | ||
| "UnityEngine.TestRunner", | ||
| "WallstopStudios.DataVisualizer.Editor" | ||
| ], | ||
| "includePlatforms": ["Editor"], | ||
| "excludePlatforms": [], | ||
| "allowUnsafeCode": false, | ||
| "overrideReferences": true, | ||
| "precompiledReferences": ["nunit.framework.dll"], | ||
| "autoReferenced": false, | ||
| "defineConstraints": ["UNITY_INCLUDE_TESTS"], | ||
| "versionDefines": [], | ||
| "noEngineReferences": false | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.