Showing posts with label Crossplatform. Show all posts
Showing posts with label Crossplatform. Show all posts

Sunday, June 20, 2010

MEF is now cross platform friendly, kinda

So in February I noted some attempts at using MEF and the disappointment that it was Windows only at the time. MEF in short is a way to break up your C# application into smaller pieces that are loosely connected.

Since multiple of the tasks I have for iteration 9 involve refactoring, I figured I'd take a look at MEF again and see if it is in better shape. The short answer answer is that it works with mono, but only in their development branch. A kind fellow in the mono IRC channel pointed me to a copy he built of System.ComponentModel.Composition.dll that I could use. It works under Windows, Mac, and Linux.

In the next release of Mono it seems likely that this will be built into the .NET 4 client profile, but packaging a single assembly along with your application seems to be an easy solution for now.

Once I break up magecrawl into smaller components, I'm planning on making another post describing MEF and showing how I used it.

Tuesday, February 2, 2010

Crossplatform issues with MEF Preview 8

While far from perfect, Magecrawl has a decent amount of modularity. The GameEngine with all map generation and the details of the running world have a hard boundary between it and the GUI. However, I feel that the GameEngine has gotten a bit too big and I'd like to split out of parts of it into separate components.

One of my first tasks this release was to investigate MEF. MEF, to put it shortly, let's you part a part of your class as [Import] and then say, "Go find a library in this directory which implements IGameEngine, load it, and fix up this variable." I implemented the first baby steps of using it late night and things were going well. That was, until I tested in under Linux.

MEF preview 8 as it stands does not work with mono/Linux. I'm not talking about a single specific issue that my code happens to trip, the built in examples don't even work. Examples bugs can be found here and here. One of them mentions this as won't be fixed until after the end of March at the earliest (post .Net 4 release). This leaves me with the unhappy situation of either:
  • Use MEF, and for at least the next two month have no chance of having a Linux version of Magecrawl
  • Don't use MEF, and either use another IoCish framework or wait until MEF works.
The only reasonable choice is the latter, punt on using MEF until the it can at least pretend to care about Linux/mono enough to get its built in examples working.

As a side note, this is why I test under Linux before each tech demo and whenever I'm about to make a large architectural change. If your writing something on one platform and expect it to work elsewhere, even if the library/language you're using claims to work there, testing early and often is a good idea.