1

我需要能够从 .NET 程序集获取源文件中的类/结构/接口定义位置(文件名、begin_line、begin_column、end_line、end_column)。

我想到的第一个解决方案是使用一些 pdb quering api,但似乎我只能通过这种方式获取方法定义的此类信息。或者,也许我错了……

为了提供上下文,我正在尝试为 VS 2008 构建一个插件,它通过 VS 自动化模型编译所有解决方案项目,获取程序集并使用反射进行一些可视化建模表示。我需要的是源代码和模型元素之间的连接。事实上,我什至可以以某种方式分析/修改来源,让他们记住位置信息。

任何想法,将不胜感激。

4

1 回答 1

0

I'm assuming that the existing Class Diagram does not help you, and that you cannot use a tool that already knows how to reverse-engineer C#? Sparx Enterprise Architect comes to mind because it can not only do the reverse engineering - it can also run user-defined transformations of the resulting models. You should be able to generate anything you want out of that, both in terms of model and in terms of artifacts.

You'll also want to consider that a class may be partial - the same class may exist in several pieces.

于 2009-03-27T01:35:09.973 回答