在不使用c#解析器的情况下获取字段的行号

在不使用c#解析器的情况下获取字段的行号,c#,system.diagnostics,line-numbers,fieldinfo,C#,System.diagnostics,Line Numbers,Fieldinfo,我想获取类型字段的行 要在方法中获取语句的行#,非常简单: Type type = typeof(MyClass); MethodInfo methodInfo = type.GetMethod("SomeMethod"); int token = methodInfo.MetadataToken; ISymbolReader reader = SymUtil.GetSymbolReaderForFile(@"dllName", null); // from mike stall's pdb2x

我想获取类型字段的行

要在方法中获取语句的行#,非常简单:

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);
不幸的是,仅仅获取构造函数的局部变量是不够的,因为某些类型的变量可以是常量/静态的