I'm trying to reproduce the following IL using Mono.Cecil:
call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange<class [System]System.ComponentModel.PropertyChangedEventHandler>(!!0&, !!0, !!0)
When I use Mono.Cecil to inspect this IL, I see that the operand of the instruction is a GenericInstanceMethod, which holds an ElementMethod of type MethodReference. This MethodReference in turn has a return type of type GenericParameter.
I'd like to create the same objects by hand, but reach a catch-22 it seems. To create a GenericParameter, I need an IGenericParameterOwner, which seems to be the very same MethodReference above. So I'd like to pass the MethodReference to the GenericParameter constructor. However, I can't create the MethodReference without a TypeReference for the return type either, which I assume should be the GenericParameter.
How do I resolve this? What I am misunderstanding?
This seems to be an issue with the API as it is.
An easy way to work around this would be to pass a TypeReference to void as the ReturnType of your MethodReference, and change the ReturnType to the later created GenericParameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With