我正在通过DGML API生成一个自定义工作流图,其中每个节点对应一个C#类。我希望能够使用内置的“转到定义”功能,但缺乏文档。
发布于 2015-02-13 23:12:27
如果您知道类的文件名和符号定义的位置,则可以使用VsShellUtilities类打开文档并将代码工件滚动到视图中(通过设置插入符号位置)。在我的一个扩展中,我做了这样的事情...
如果我有一个用来存储文件名和文本范围的SourceInfo类型...
void GotoDefinition(
IServiceProvider serviceProvider,
SourceInfo source)
{
IVsUIHierarchy hierarchy;
uint itemId;
IVsWindowFrame windowFrame;
IVsTextView view;
VsShellUtilities.OpenDocument(
serviceProvider,
source.Filename,
Guid.Empty,
out hierarchy,
out itemId,
out windowFrame,
out view);
if (view != null)
{
int line, column;
int pos = source.TextRange.Start;
if (view.GetLineAndColumn(pos, out line, out column) == VSConstants.S_OK)
{
view.SetCaretPos(line, column);
view.CenterLines(line, 1);
}
}
}
class SourceInfo
{
public string Filename { get; set; }
public TextRange TextRange { get; set; }
}发布于 2016-05-02 09:36:50
您不能修改goto定义,但您可以使用"goto引用“。如果在文本编辑器中手动编辑DGML文件,则可以向节点添加"Reference“特性,如下所示:
<Node Id="Boomerang" Reference="Boomerang.dgml"/>然后,当你在VS中右击这个节点时,你会看到一个名为"Go To Reference“的新菜单出现,带有一个包含"Reference”的子菜单,如果你点击它,它将打开被引用的DGML文件。
有关更多详细信息,请参阅https://msdn.microsoft.com/en-us/library/ee842619.aspx#AddReferences。
发布于 2017-05-16 19:47:51
Visual studio有自己的属性"SourceLocation“
您应该在属性中声明它
<Properties>
...
<Property Id="SourceLocation" Label="Start Line Number" DataType="Microsoft.VisualStudio.GraphModel.CodeSchema.SourceLocation" />
...
</Properties>然后在Node元素f.e中使用它。
<Node Id="class1" Label="FirstClass" SourceLocation="(Assembly=file:///D:/Prj/TestApp/AppConsole/Program.cs StartLineNumber=8 StartCharacterOffset=1 EndLineNumber=8 EndCharacterOffset=1)"/>https://stackoverflow.com/questions/28497753
复制相似问题