Support passing VirtualNode objects to ReportError - #760
bdunderscore with Copilot wants to merge 5 commits into
Conversation
- Added GetOriginalObject() method to VirtualNode class - Modified InlineError.AddContext to resolve VirtualNode objects to their original Unity objects - Added unit tests for VirtualNode resolution in error reporting Co-authored-by: bdunderscore <64174065+bdunderscore@users.noreply.github.com>
Added assertions to verify that no references are added when a VirtualNode has no original object, and that the error is still created successfully using the VirtualNode's ToString representation. Co-authored-by: bdunderscore <64174065+bdunderscore@users.noreply.github.com>
|
@copilot Address missing tests (check PR CI status). Also, add changelog entries (in both files); use the PR number for those entries. |
- Fixed TestVirtualNodeWithoutOriginalObject to use VirtualClip.Create instead of NewClip - Added changelog entries to both CHANGELOG.md and CHANGELOG-PRERELEASE.md for PR #760 Co-authored-by: bdunderscore <64174065+bdunderscore@users.noreply.github.com>
Fixed in commit 2bf4d01:
|
|
@copilot Rebase to the current main branch. |
There was a problem hiding this comment.
Pull request overview
Adds support for passing virtual animator objects (derived from VirtualNode, e.g. VirtualClip) into error reporting so they resolve to their underlying UnityEngine.Object when available, improving ErrorReport.ReportError context and UI references.
Changes:
- Added a
VirtualNodeAPI (GetOriginalObject) to expose the backing Unity object to internal systems. - Updated
InlineError.AddContextto treatVirtualNodearguments as context objects and resolve them toObjectReferences when possible. - Added unit tests and changelog entries documenting the new behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| UnitTests~/InlineErrorTests.cs | Adds coverage for VirtualNode arguments in InlineError substitutions/references. |
| Editor/ErrorReporting/InlineError.cs | Resolves VirtualNode arguments to original Unity objects (via ObjectRegistry) for error context. |
| Editor/API/AnimatorServices/VirtualObjects/VirtualNode.cs | Introduces GetOriginalObject() hook to retrieve the backing Unity object for a virtual node. |
| CHANGELOG.md | Documents the new ReportError behavior for virtual nodes in the main changelog. |
| CHANGELOG-PRERELEASE.md | Documents the new ReportError behavior for virtual nodes in the prerelease changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [Test] | ||
| public void TestVirtualNodeWithoutOriginalObject() | ||
| { | ||
| // Create a mock VirtualNode without an original object | ||
| var virtualClip = VirtualClip.Create("NewClip"); | ||
|
|
||
| // Create an error that includes the VirtualClip without an original object | ||
| var error = new InlineError(TEST_LOCALIZER, ErrorSeverity.Error, "Errors:test", | ||
| virtualClip, "arg1", "arg2"); | ||
|
|
||
| // The error should still be created, and should use the VirtualNode's ToString representation | ||
| // Since there's no original object, no reference should be added | ||
| Assert.AreEqual(0, error.References.Length, "Expected no references to be added for VirtualNode without original object"); | ||
|
|
||
| // The title should still be created successfully | ||
| var title = error.FormatTitle(); | ||
| Assert.IsNotEmpty(title, "Expected a non-empty title"); | ||
| } |
| // Create a VirtualClip that wraps the animation clip | ||
| var context = new CloneContext(GenericPlatformAnimatorBindings.Instance); | ||
| var virtualClip = VirtualClip.Clone(context, animClip); | ||
|
|
||
| // Create an error that includes the VirtualClip | ||
| var error = new InlineError(TEST_LOCALIZER, ErrorSeverity.Error, "Errors:test", | ||
| virtualClip, "arg1", "arg2"); | ||
|
|
||
| // Verify that the error has a reference to the original animation clip | ||
| Assert.IsNotEmpty(error.References, "Expected at least one reference to be added"); | ||
|
|
||
| // The reference should point to the original animation clip | ||
| var reference = error.References[0]; | ||
| Assert.IsNotNull(reference, "Expected a non-null reference"); | ||
|
|
||
| // The title should contain the VirtualClip's name (which comes from the original clip) | ||
| var title = error.FormatTitle(); | ||
| Assert.IsTrue(title.Contains("TestClip") || title.Contains("VirtualClip"), | ||
| $"Expected title to reference the clip, got: {title}"); |
…alclips-reporterror # Conflicts: # CHANGELOG-PRERELEASE.md # CHANGELOG.md
Plan: Support passing VirtualClips and other VirtualObjects to ReportError
Implementation Summary
This PR successfully implements support for passing VirtualClips and other VirtualObjects (all derived from VirtualNode) to ReportError. The implementation resolves these virtual objects back to their original Unity objects when available for better error reporting.
Changes Made:
VirtualNode.cs: Added
GetOriginalObject()protected internal method that returns the original Unity object (OriginalObjectproperty value)InlineError.cs:
nadena.dev.ndmf.animatornamespaceAddContext()method to check for VirtualNode objects BEFORE checking for Unity Objects (important since VirtualNode instances are not Unity Objects)InlineErrorTests.cs:
CHANGELOG.md & CHANGELOG-PRERELEASE.md: Added entry for PR Support passing VirtualNode objects to ReportError #760
Security Summary:
✅ CodeQL scan completed with 0 alerts - No security vulnerabilities detected.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.