I am generating a custom workflow diagram via DGML API where each node corresponds to a C# class. I would like to be able to use the built-in 'Go To Definition' feature but the documentation is lacking.
DGML: how to enable the 'Go To Definition' for custom diagrams?
617 Views Asked by Den At
3
There are 3 best solutions below
1
On
You cannot modify goto definition, but you can use "goto reference" instead. If you manually edit the DGML file in a text editor you can add a "Reference" property to a node, like this:
<Node Id="Boomerang" Reference="Boomerang.dgml"/>
Then when you right click this node in VS you will see a new menu appear named "Go To Reference" with a submenu containing "Reference", if you click this it will open the referenced DGML file.
See https://msdn.microsoft.com/en-us/library/ee842619.aspx#AddReferences for more detail.
0
On
Visual studio have it's own property "SourceLocation"
You should declare it in properties
<Properties>
...
<Property Id="SourceLocation" Label="Start Line Number" DataType="Microsoft.VisualStudio.GraphModel.CodeSchema.SourceLocation" />
...
</Properties>
then use it inside Node element f.e.
<Node Id="class1" Label="FirstClass" SourceLocation="(Assembly=file:///D:/Prj/TestApp/AppConsole/Program.cs StartLineNumber=8 StartCharacterOffset=1 EndLineNumber=8 EndCharacterOffset=1)"/>
If you know the class´s filename and the position of the symbol definition, you can use the
VsShellUtilitiesclass to open the document and scroll the code artifact into the view (by setting the caret position). In one of my extensions I do something like this...If have a
SourceInfotype which I use to store the filename and text-range...