Cecil is slang for cocaine 29 Aug 2005



Everybody's round tripping, 'tripping assemblies

Some very exciting progress have been made today. Let me explain in what I've spend the lasts minutes:

  • I have compiled Cecil HEAD normally, this produces a Mono.Cecil.dll file.
  • I have compiled this little piece of code referencing the previous assembly:
using System;

using Mono.Cecil;

class Test {

    static void Main ()
    {
        RoundTripCecil ();
    }

    static void RoundTripCecil ()
    {
        Console.WriteLine ("Round Trip Cecil");
        IAssemblyDefinition asm = AssemblyFactory.GetAssembly (
            "Mono.Cecil.dll");

        Console.WriteLine ("Cecil is loaded");

        AssemblyFactory.SaveAssembly (asm, "Mono.Cecil.dll", AssemblyKind.Dll);

        Console.WriteLine ("Cecil is written back");
    }
}
  • I've runned it, the result is a fresh new round tripped Mono.Cecil.dll
  • I've modified the previous code to round trip mcs, our C# compiler (if you still follow me, we are here using a round tripped Cecil to round trip mcs)
  • I've re-compiled Cecil using the fresh new mcs
  • And the new Cecil is perfectly working, wow.

The conclusion of all of that is that the writing layer of Cecil is more and more mature and stable. Few things are missing, especially multiple modules assemblies, but who uses that, and complex custom attributes, using arrays, or properties and fields.

Also the new API is in the SVN, it is now much easier for users to modify and create assemblies. Previous code samples on this blog are now deprecated, maybe I should remove them. Or update them. I will see. If you are already using Cecil, you fool, you may encounter one or two little API break with SVN head. The first that comes to my mind is the method of the AssemblyFactory to get an assembly, wich used to take a string and an LoadingType enumeration. This enumeration does not exists anymore, as I decided to get rid of two different engines to load assemblies. The LazyLoading was introducing a lot of complexity, so for the sake of simplicity, I've removed it.

Few things are still not implemented in the modifying layer, but I prefer focusing on the writing one before the end of Google's Summer of Code. Some times after the end of the SoC, I will release the first public version of Cecil. Wich means API freeze, bugs reports, blah.

Sadly, Cecil itself can't be use to make some nice screen shot. I had to find other ways: