O Manifest resources, where are thou ? 15 Mar 2005



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 ?