如何在.NET程序集中包含源代码位置信息(文件/行/列)? [英] How to include source code location information (file/line/column) in .NET assembly?

查看:72
本文介绍了如何在.NET程序集中包含源代码位置信息(文件/行/列)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to be able to get from .NET assembly a class/struct/interface definition location (filename,begin_line,begin_column,end_line,end_column) in my source files.

我想到的第一个解决方案是使用一些pdb查询api,但是看来我只能以这种方式为方法定义获取此类信息.也许我错了...

First solution that came to my mind was using some pdb quering api, but it seems that I can obtain such info only for method definition this way. Or maybe I'm wrong...

为提供上下文,我试图构建一个VS 2008外接程序,该外接程序通过VS自动化模型编译所有解决方案项目,采用程序集并使用Reflections进行可视化建模.我需要的是源代码和模型元素之间的连接.实际上,我什至可以以某种方式分析/修改来源,以使他们记住位置信息.

To provide the context, i'm trying to build an add-in to VS 2008 which compiles all solution projects through VS automation model, takes assemblies and using Reflections makes some visual modeling representation. What i need is a connection between source code and model elements. In fact i could even analyze/modify sources in some way to make them remember the location info.

任何想法都会受到赞赏.

Any ideas would be appreciated.

推荐答案

我假设现有的类图对您没有帮助,并且您不能使用已经知道如何对C#进行反向工程的工具?想到了 Sparx Enterprise Architect ,因为它不仅可以进行逆向工程-还可以运行用户定义的结果模型的转换.无论是在模型还是在工件方面,您都应该能够从中生成任何想要的东西.

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.

这篇关于如何在.NET程序集中包含源代码位置信息(文件/行/列)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆