Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to Reflection.Emit for the Compact Framework

It seems that .NET CF is missing the very useful Reflection.Emit. So far, I found this library as an alternative: http://www.codeplex.com/EmitCF.

However it seems to be an abandoned early version, so I'm looking for more options.

Does anyone know of another alternative to Emit? Or perhaps someone used EmitCF and can comment on its status?

BTW, the bigger picture: I'm trying to get Emit for the CF, so that I can get http://dynamic.codeplex.com to work under the CF, so I can optimize the serialization code I'm using (http://www.codeproject.com/KB/XML/GR_CustomXmlSerializer.aspx)

like image 281
Hermit Avatar asked Sep 05 '09 15:09

Hermit


2 Answers

What you need is Cecil (http://mono-project.com/Cecil), a Mono project library to generate and inspect programs and libraries in CIL format. It's actively maintained, does a lot more than Reflection.Emit and it's used in a lot of projects, including some that target .NET CF.

like image 94
Andreia Gaita Avatar answered Oct 21 '22 23:10

Andreia Gaita


This isn't exactly an answer to your question, but since Reflection.Emit isn't supported in CF, an alternative approach you could take to serialization/deserialization would be to compile your classes into a regular Windows application, and make use of Reflection.Emit to programatically generate serialize and de-serialize methods for each class, which could then be incorporated back into the class in the CF version. Basically, you'd use Reflection.Emit in the full framework for code generation.

This would be more work (and a constant source of more work, of course), but it would perform better than a dynamic, Reflection.Emit-based approach (which doesn't work in CF anyway). Most CF classes will work unchanged in the full framework, although not necessarily, of course.

like image 32
MusiGenesis Avatar answered Oct 22 '22 00:10

MusiGenesis