generic struct ref parameters
See original GitHub issueSuppose you have a generic struct
and want to do something neat with this
inside some method, like pass it to Console.WriteLine
. Maybe you just want to print this
out every time the constructor for a generic struct
is called. This is just an example, of course.
I can call param.Type.ToByRefSig().Next
to get a TypeSig
for this
, but I can’t convert that into something that I can box up. It seems fairly insistent that it’s NOT a generic sig, and it omits the <T, U>
stuff whenever I convert it to a TypeDef
with ToTypeDefOrRef()
. This kind of makes sense in the context of the tree structure of sigs, and I’m not surprised it doesn’t work.
For return values, which are GenericInstSig
for generic struct
s, I can just call OpCodes.Box.ToInstruction(method.ReturnValue.ToTypeDefOrRef())
, and it works great, but I can’t figure out a way to do the same for ref
parameters. My first thought was to manually create a GenericInstSig
from the TypeSig
, but I’m having trouble wrapping my head around that process.
Am I heading along the right track? If so, could you give me some pointers on how to do that? If not, what’s the proper method for getting this done?
Thanks for any help you can provide! I can show some code if anything isn’t clear.
Edit: removed misleading summary
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
@bprg Thanks very much! That’s very helpful.
@tgrindinger Try this example https://github.com/saneki/dnlib-examples