Closed AlgorithmsAreCool closed 8 years ago
https://github.com/kevin-montrose/Sigil/blob/master/Sigil/Emit.Call.cs#L90 - here an example of method with generic (type) parameter. If you need more - you can always make an extension methods for Emit
er. But what exactly are you trying to achive?
Well I can call a generic method just fine. But I need to be able to specify/define a generic method. When I call Emit.InstanceMethod I kinda need some access to the method builder or an overload that can assign generic parameters to a method builder. I can submit a PR for this when I get a bit more free time.
It turns out i was being dense. Sigil can do this just fine.
The trick is you need is to fixup the generic args after you have built the body of the method.
When you call Emit.CreateMethod
, you get the raw MethodBuilder
that is still flexible so just call MethodBuilder.DefineGenericParameters(string[] names)
Ugh, i lied. My tests pass when i was emitting a stub method body with just a return
in it. But when i wrote the actual method body it failed with a "Sigil does not currently support generic types" InvalidOperationException. Which answers my question about if they work or not. :(
Does Sigil support building generic methods?
I have not found a way to specify generic parameters on the method.