Wheelie
Wheelie

Reputation: 3916

C# Description of a method signature

Is there a .NET method that will produce a description of a C# method signature from a MethodInfo object. E.g. The following code might display "static int Main(string[])"

static int Main(string[] args)
{
    var method = MethodInfo.GetCurrentMethod();
    Console.WriteLine(DescribeMethodSignature(method));
}

Upvotes: 2

Views: 1249

Answers (2)

Jon Grant
Jon Grant

Reputation: 11520

This isn't a complete answer, but there is code generation functionality in the Framework. Check out the CSharpCodeProvider, specifically the ICodeGenerator interface.

There is an example on CodeProject on how to use it.

Upvotes: 2

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422310

.NET base class library does not have such a method. This is C# specific and it doesn't make sense to have it in a class library shared among many languages. It shouldn't be hard to write one though.

Upvotes: 1

Related Questions