In Visual Studio, I can right-click a method from a compiled assembly and pick "Peek Definition" to see a list of method definitions, properties, enums, etc from that class. This definition has a [from metadata]
qualification, indicating that this isn't actual source, but something generated from (I assume) reflected metadata.
My question is, what actually produces this code, and can I access it programmatically? My goal is to take a 3rd party assembly and generate dummy code from it. For example, given an assembly compiled from a class like:
public class TheirClass
{
public TheirClass()
{
// initialization magic
}
public string Name { get; private set; }
public void SayHowdy() { Console.WriteLine("Howdy"); }
private int Add(int x, int y) => x + y;
}
I want to generate minimal code like:
public class TheirClass
{
public TheirClass() { }
public string Name { get; }
public void SayHowdy() => throw new NotImplementedException();
}
So, given that the "Peek Definition" feature in Visual Studio already does 90% of this, how can I access that tool programmatically?