Hey Sebastien,

Cecil is quite close to the metadata "under the hood." That is, the
way you represent things in Cecil objects is very close to how they're
represented in the physical metadata. This is both good and bad. You
have excellent control over what's in the metadata from "object land,"
but you sacrifice many high level niceties.

The relevant nicety here is representing a Type as a Type. According
to the Standard:
<quote source="CLI Standard v4, Partition II, 23.3">
If the parameter kind is System.Type, ... its value is stored as a
SerString (as defined in the previous paragraph), representing its
canonical name. The canonical name is its full type name, followed
optionally by the assembly where it is defined, its version, culture
and public-key-token.
</quote>
This is why ToString() on the Type works; it returns the full type
name.

The easy solution for you is to use the full type name, instead of a
Type or TypeDefinition object, as the parameter value of your
CustomAttribute. You could also build out a full "canonical name" if
you wish. The Specification doesn't do a good job specifying the EXACT
format, but this shows it by example for a non-generic type. It's for
the EditorAttribute from System.Drawing.Image:

'System.Drawing.Design.ImageEditor, System.Drawing.Design,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

(I hope you don't need a generic type as an attribute parameter. The
Standard is silent on that, far as I can find, and I haven't found an
example to follow.)

Hope that helps,
-- Keith
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to