Replies: 5 comments
-
You can check it out this way. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your prompt response! However, I was actually asking if we can get the location of method signature or method name, like what is indicated in the attached code snippet below. using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args) // <- location of this part of the code
{
Console.WriteLine("Hello World!");
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, no. The MethodDef table in the CLR metadata doesn't store source information, and the Portable PDB metadata's method debug info is based on IL offsets within methods (docs). The sequence points, if present, are stored in offset order, so if there are sequence points, the first one will be the one closest to the method declaration, but that's the best you can do. |
Beta Was this translation helpful? Give feedback.
-
Usually (i.e. if it's the result of a normal C# compilation using the Microsoft compiler), certainly in a Debug build (not 100% about Release builds), there'll be a sequence point attached to a So if you use the standard MS style with the
Looking now, constructors seem different; they don't get a Of course, none of the above is guaranteed in any way. |
Beta Was this translation helpful? Give feedback.
-
Methods start with a |
Beta Was this translation helpful? Give feedback.
-
Hi,
As it is easy to get the location of method body instructions through
MethodDefinition.DebugInformation.SequencePoints
ofmono.cecil
, I am wondering can we get the location, such as line number and column number, of method name and signature throughmono.cecil
?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions