Project Description
The EmitCF project is intended to provide a Reflection.Emit-like library for Compact Framework.

The library provides a coherent interface with the System.Reflection.Emit namespace, in order to port existing code for standard Framework as easily as possible to devices.

At a very high level, the transformation of a System.Reflection.Emit code to a EmitCF code consists simply in transforming the header:
using System;
using System.Reflection;
using System.Reflection.Emit;

using SystemCF;
using SystemCF.Reflection;
using SystemCF.Reflection.Emit;

The code must generally be modified when invoking methods from a System.Type by appending the CLR namespace, for example:
MethodInfo writeString = typeof(Console).GetMethod("WriteLine", new Type[] {typeof(string), typeof(int)});

(in this code, writeString is a System.Reflection.MethodInfo instance)

MethodInfo writeString = typeof(System.Console).GetMethod("WriteLine", new System.Type[] {typeof(string), typeof(int)});

(in this code, writeString is a SystemCF.Reflection.MethodInfo instance)

EmitCF has some limitations (we are on a device!):
  • An AssemblyBuilder object can only be build from the SystemCF.AppDomain.CurrentDomain instance;
  • No support for .PDB generation (useless with CF);
  • No support for unmanaged resource;
  • DynamicMethodBuilder can only access public or protected members of the initial instance;
  • No support for AssemblyBuilderAccess in method SystemCF.AppDomain.DefineDynamicAssembly: an assembly file is always saved on disk because CF doesn't support building assembly from scratch...
  • Methods GetCustomAttributes not implemented.
  • TypeBuilder.CreateType() does not return a System.Type ==> use SystemCF.Activator.CreateInstance(<typeBuilder>) to return a System.Type.

Last edited Feb 14, 2008 at 9:05 AM by rvaquette, version 5