Navigate to Class Based on Interface Naming Convention

Hello everyone,

I'm trying to find a way to navigate to a class based on the naming of an interface. Here's a simplified example of what I'm working with:

csharp

Copy code

IMyClass mc = SomeFunction();

When I CTRL+Click on IMyClass, I want to navigate directly to a class named MyClass (i.e., without the "I" prefix) instead of navigating to the IMyClass interface.

A key point: MyClass does not implement or inherit from IMyClass. The two are unrelated except for this naming convention.

Is there any way to achieve this behavior, either out of the box or through an existing plugin?

Thanks in advance!

0
1 comment

Well I am going to respond to myself. I found a clunky way of doing this using Macros. 

You need the following Macro:
 

  • Select Word (Action: EditorSelectWord): The macro begins by selecting the word under the cursor, which would be the name of the interface (e.g., IMyClass).
  • Copy Selected Text (Action: EditorCopy): It copies the selected interface name to the clipboard.
  • Open Go to Symbol Dialog (Action: GotoSymbol): The macro opens the Go to Symbol dialog, allowing for quick symbol lookup within the project.
  • Paste Copied Text (Action: EditorPaste): It pastes the copied interface name (IMyClass) into the search field.
  • Move to Line Start (Action: EditorLineStart): The macro moves the cursor to the beginning of the pasted text (IMyClass), likely to prepare for modifying it.
  • Delete the First Character (Keystroke: "DELETE"): The macro deletes the first character, effectively removing the leading I from the interface name, resulting in MyClass.
  • Initiate Search (Keystroke: "ENTER"): Finally, the macro hits Enter, triggering a navigatio for the first item in the Go to Symbol dialog. Hopefully this is `MyClass`.
0

Please sign in to leave a comment.