Hi,

I'm attempting to use Cecil in a rather esoteric scenario, and am wondering 
whether I should be. Let me explain my scenario first...

I'm writing a cross-platform game using MonoGame in VS2013. Because 
MonoGame does not yet support the content pipeline (*sigh*), I need to use 
VS2010 to build the content. Fine - I have separate 2010 solution and 
project files for those projects I need in a content build. Whenever I need 
to build content, I switch to my VS2010 (running in a VM) and build. It 
automatically copies all my content to the right places. I can then switch 
back to my VS2013 to run/debug the game. This was a nightmare to set up, 
but I have it working perfectly now.

But here's the thing...recently I decided to try and prove the 
cross-platform nature of my setup. The game already runs on WindowGL, so I 
decided to target Windows8 next, since that is the closest thing to 
WindowsGL. Immediately I ran into a bug in MonoGame's (de)serialization 
code - it was unable to deserialize my content on Win8 even though it could 
do so on WinGL.

I had run up against so many MonoGame serialization and content issues at 
that point I decided to take matters into my own hands and write my own 
serialization logic. I decided to use Fody's in-solution weaving to add Readand 
Write methods to my data classes (tagged with an attribute) and to generate 
XNA reader/writer types that then call into those Read/Write methods. Fast 
forward a week or so and I have this all working on Win8/VS2013, with unit 
tests to prove it.

However, I just now tried building content in my VS2010 instance and - 
surprise, surprise - have run into other issues. Specifically, I have some 
Cecil code like this:

var typeType = context.ModuleDefinition.Import(typeof(Type));
var typeInfoType = context.ModuleDefinition.Import(typeof(TypeInfo));
var objectType = context.ModuleDefinition.TypeSystem.Object;
var introspectionExtensionsType = context.ModuleDefinition.Import(typeof(
IntrospectionExtensions));

var typeGetTypeInfoMethod = 
context.ModuleDefinition.Import(introspectionExtensionsType.Resolve().Methods.First(x
 
=> x.Name == "GetTypeInfo"));
var typeInfoGetDeclaredMethodMethod = 
context.ModuleDefinition.Import(typeInfoType.Resolve().Methods.First(x => 
x.Name == "GetDeclaredMethod" && x.Parameters.Count == 1));
var methodBaseInvokeMethod = 
context.ModuleDefinition.Import(methodBaseType.Resolve().Methods.First(x => 
x.Name == "Invoke" && x.Parameters.Count == 2));

 
I use the above to do some simple reflection in the generated code. 
However, this fails to build in VS2010 targeting FX4 because TypeInfo and 
IntrospectionExtensions are 4.5/PCL types. My first thought was that maybe 
my weavers project needed to be a PCL, but there does not appear to be a 
PCL version of Cecil, so I guess that's not the answer?

Now I'm worried: am I barking up the wrong tree with my approach? Bear in 
mind I will later be adding support for iOS and maybe Android platforms. Is 
using Cecil a viable approach? If so, any recommendations for how I should 
proceed?

Thanks

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to