Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate Extension Methods using System.CodeDom

Has anyone ever tried to generate extension methods using System.CodeDom under .NET 4.0? There doesn't seem to be any way to specify a CodeMemberMethod or CodeParameterDeclarationExpression as being an extension method/parameter.

If this isn't possible, are there any good workarounds?

Thanks

like image 247
LorenVS Avatar asked May 15 '11 21:05

LorenVS


1 Answers

Apparently CodeDom isn't able to generate the correct code for the first parameter of an extension method, but you can cheat it like this:

var param = new CodeParameterDeclarationExpression("this string", "s");

It will blissfully ignore the fact that "this string" is not a valid type...

like image 119
Thomas Levesque Avatar answered Oct 07 '22 10:10

Thomas Levesque