-
Notifications
You must be signed in to change notification settings - Fork 111
Refactor ContextMenu API and usages (breaking API change) #119
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the context menu system by extracting the MenuEntry struct into a separate ContextMenuEntry class and updating the API to support MemberInfo parameters. The refactoring distributes context menu registration across individual feature classes rather than centralizing it in the ContextMenu class.
Key changes:
- Extracted
MenuEntryto a newContextMenuEntryclass with updated API signature - Moved context menu entry registration from centralized initialization to individual feature classes
- Changed
MenuContentsfrom instance to static property for easier access across features
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| RuntimeUnityEditor.Core/Features/ContextMenuEntry.cs | New file defining the extracted ContextMenuEntry struct with MemberInfo support |
| RuntimeUnityEditor.Core/Features/ContextMenu.cs | Refactored to use new ContextMenuEntry, removed MenuEntry definition and centralized menu registration |
| RuntimeUnityEditor.Core/Windows/REPL/REPLWindow.cs | Added "Send to REPL" context menu entry registration |
| RuntimeUnityEditor.Core/Windows/ObjectView/ObjectViewWindow.cs | Added preview and event details context menu entry registrations |
| RuntimeUnityEditor.Core/Windows/ObjectTree/ObjectTreeViewer.cs | Added find in object tree and find references context menu entry registrations |
| RuntimeUnityEditor.Core/Windows/Inspector/Inspector.cs | Added "Send to inspector" context menu entry registration |
| RuntimeUnityEditor.Core/Windows/Clipboard/ClipboardWindow.cs | Added copy to clipboard context menu entry registration |
| RuntimeUnityEditor.Core/Windows/Breakpoints/BreakpointsWindow.cs | Moved breakpoint context menu registration from ContextMenu to BreakpointsWindow |
| RuntimeUnityEditor.Core/Utils/Abstractions/DnSpyHelper.cs | Added dnSpy-related context menu entry registrations |
| RuntimeUnityEditor.Bepin5/PatchInspector/PatchInspector.cs | Added harmony patch management context menu entry registrations |
| RuntimeUnityEditor.Core/RuntimeUnityEditor.Core.projitems | Added ContextMenuEntry.cs to project compilation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MinimumSize = new Vector2(250, 100); | ||
| DefaultScreenPosition = ScreenPartition.LeftUpper; | ||
|
|
||
| ContextMenu.MenuContents.Add(new ContextMenuEntry("Copy to clipboard", null, (o, info, name) => { if (Contents.LastOrDefault() != (o ?? info)) Contents.Add(o ?? info); })); |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline lambda is complex with nested logic (o ?? info used twice) and the condition check. Consider extracting this to a named method for better readability and testability.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.