There and back again 1

Posted by jbevain Wed, 20 Apr 2005 20:55:04 GMT


I’m back !

I’ve spent a lot of time in the east of France, in Strasbourg. It’s a nice city, with lots of students. Sadly, I left my camera in Paris. Teaching XML, and making XML Schema writing (by hand) attractive for students is definitively not an easy thing. I’ve also visited friends from Evaluant in Mulhouse.

I’ve started working on Cecil again, I’m implementing the writing part of the API. You’ll be able to use both Mono.Cecil and System.Reflection object model, for instance, you can add custom attributes using those two factory methods defined in the ICustomAttributeProvider interface :

ICustomAttribute DefineCustomAttribute (IMethodReference ctor);
ICustomAttribute DefineCustomAttribute (ConstructorInfo ctor);

And Cecil will automatically add needed references to assemblies and types. Fun to do, hope it will be fun to use. Sebastien is using Cecil to make some drawing, read part 1 and part 2 of his work.

I’ve bought the Dragon Book !

The Dragon Book

Nice to read, but it was expansive… I’ve just found on amazon that they are writing a third version of the book, another best seller to come, take a look there. I’ve bought AspectJ Cookbook too, I had to, there is a monkey on the cover ! A good book, I now have few ideas for an AspectDNG in action…

Journée Académiques 2005

Posted by jbevain Wed, 23 Mar 2005 22:59:30 GMT


I have the honor to be one of the speaker of the “Academic Days” event, my talk is about Aspect Oriented Programming on the .net framework.

I have to admit that i’m really impressed, I’ll meet there people like John Lefor, PM for the Phoenix project at MSR. It seems that we share some ideas on compiler design, I hope I’ll be able to talk with him a little. Serge Lidin, the author of Inside .NET IL Assembler, and the writer of ildasm, ilasm, peverify, ..., will be here too, talking about the the evolution of the CIL. Be sure I’ll hear carefully ! Should be 3 exciting days ! All details here.

O Manifest resources, where are thou ? 1

Posted by jbevain Tue, 15 Mar 2005 21:52:58 GMT


Hum, what about going back to work ?

I’ve worked the past day on Manifest Resources for Cecil. Manifest Resources are another tricky thing in the .net framework. System.Reflection.Emit v1.x does not provides methods for embedding them in a fresh new assembly, so mcs have to use some hacks that only work on the Mono runtime. Cecil will be able to emit them, but first, let’s try to read them from a raw assembly.

First of all, they are called Manifest Resources, so I would except them to be saved in the assembly manifest. This is what we can find in the second partition of the ECMA CLI standard:

The ManifestResource table has the following columns:
  • Offset (a 4 byte constant)
  • Flags (a 4 byte bitmask of type ManifestResourceAttributes, clause )
  • Name (index into the String heap)
  • Implementation (index into File table, or AssemblyRef table, or null; more precisely, an Implementation coded index)

So if the Implementation metadata token points to a File row, it is a linked resource, if it is null, it is an embedded resource. We can guess that if it points to an AssemblyRef row, it would mean that resource is embedded into another assembly.

My problem is that whatever tool I’ve used, it seems that manifest resources are defined per module, not per assembly manifest. I have implemented a per module resource reading system in Cecil, but I don’t know how to implement the “AssemblyRef” case. Does someone have any idea about this, or any test case where an implementation token points to an AssemblyRef row ?

Cecil talks 4

Posted by jbevain Sun, 20 Feb 2005 16:42:35 GMT


A long time I have not blogged. Mainly spent my time working on Cecil. Better than a long talk, here is an example of what Cecil is able to do now. There is a name for programs that write themselves, I’ve forget it, and my example is not really one of them. My example is a very simple C# console program, but it will print its CIL representation, almost like ildasm.

I’ve not included the source and the result on the blog, because they are not really short. The source is viewable here : C# source. We simply load an assembly using Cecil, then we print the content of the methods. Easy no ? Let’s take a look at the output : here.

I have still a lot of work to do, and the API is not really stable, but I’m close to what I want. Once I’ll get it, I think I’ll call for contribution on this blog, to achieve the writing part of Cecil. Stay tuned !

Older posts: 1 ... 33 34 35 36 37 38