I have done a massive amount of fixes to IKVM.Reflection.Emit to make it full featured (even though it still doesn't implement all Reflection.Emit APIs, the functionality should (almost) all be there, for example via different overloads).
I completed support for generics (I think) and fixed many bugs in that area, ikvmc only uses a very small amount of generics so these fixes are unlikely to affect it.
It's worth explicitly stating the design goals of IKVM.Reflection.Emit:
- It's a write-only API. Some GetXXX methods or properties may be implemented, but that's mostly for its internal convenience.
- There is intentionally no error checking. During ikvm development the error checking in System.Reflection.Emit has cost me a huge amount of time, it is generally much easier to diagnose the problem when you have a broken assembly file. PEverify and ILDASM are your friends.
- Code that uses System.Reflection.Emit in a write-only way is supposed to "just work" (modulo missing APIs, but those changes should be trivial).
I've done some pretty heavy duty testing on it. It should be ready for external (i.e. non-ikvmc) usage now. If you decide to use it (or consider using it), please let me know. As always, feedback is appreciated.
- Added support for ByRef and Pointer types.
- Completed support for all literal field constant types and fixed null literal fields.
- Added ModuleBuilder.DefineInitializedData().
- Fixed many generics related bugs.
- Added a (non-standard) API to ModuleBuilder to set the PE image base address.
- Added TypeBuilder.SetParent().
- Added TypeBuilder.GetMethod() and TypeBuilder.GetConstructor() to instantiate methods on generic types.
- Added a (non-standard) API to ILGenerator to disable the "helpful" automatic leave/endfinally instructions in exception blocks.
- Added support for pinned local variables.
- Added UIntPtr and TypedReference signature encodings.
- Fixed handling of TypeBuilder enums in custom attributes.
- Added MethodBuilder.SetSignature().
- Added GenericTypeParameterBuilder.SetInterfaceConstraints() and .SetGenericParameterAttributes().
- Fixed (Method|Type)Builder.SetCustomAttribute() to set HasSecurity flag when SuppressUnmanagedCodeSecurityAttribute is set.
- Added support for defining events.
Binary available here: ikvm-refemit-0.41.3464.zip