I am 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 test this IL, I see that the operand of the command is GenericInstanceMethod, which contains an ElementMethod of type MethodReference. This Reference method, in turn, has a GenericParameter return type.
I would like to create the same objects manually, but get to catch-22. To create a GenericParameter, I need an IGenericParameterOwner, which seems to be the same MethodReference method above. Therefore, I would like to pass a MethodReference to the GenericParameter constructor. However, I cannot create a MethodReference without a TypeReference for the return type, which I suppose should be a GenericParameter.
How do i solve this? What do I misunderstand?
Einar source share