不使用c#解析器即可获取字段的行号

问题描述

| 我想获取类型字段的行号。 要在一个方法获取语句的行号,这很简单:
Type type = typeof(MyClass);
MethodInfo methodInfo = type.getmethod(\"SomeMethod\");
int token = methodInfo.MetadataToken;
ISymbolReader reader = SymUtil.GetSymbolReaderForFile(@\"dllName\",null); // from mike stall\'s pdb2xml
ISymbolMethod methodSymbol = reader.getmethod(new SymbolToken(token));
int count = methodSymbol.SequencePointCount;
ISymbolDocument[] docs = new ISymbolDocument[count];
int[] startColumn = new int[count];
int[] endColumn = new int[count];
int[] startRow = new int[count];
int[] endRow = new int[count];
method.GetSequencePoints(offsets,docs,startRow,startColumn,endRow,endColumn);
不幸的是,获取构造函数的局部变量是不够的,因为某些类型的变量可以是const / static。     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)