Previewing IL generated by ILGenerator
After generating a constructor method using a ConstructorBuilder and ILGenerator, how can I preview the full generated IL of the constructor method?
I'd like to compare the generated IL with something I can check on sharplab.io or in Rider, as my generated constructor isn't working, and I'd like to figure out what is different.
4 Replies
u can for example use ILSpy to load the built assembly to inspect the IL
Where would I be able to get hold of the built assembly from for this?
If I've dynamically generated IL, can I write it out?
oh, sorry, i mixed this up with Mono.Cecil's
ILProcessor
.
tbh no clue how to do that for runtime generated ILyeah - that's my problem 🙂
From looking at my
il.Emit()
calls, it looks like I'm matching what happens from a normally compiled constructor, but it's telling me it's an invalid program
Ah, I figured out my actual issue here...
(still would love to know how to do the above, though)
Thanks - interesting. I might keep hold of these links for next time around