Hey,

On 7/19/07, Wicky <[EMAIL PROTECTED]> wrote:
> For example, this simple class:
>
>     public class Class1
>     {
>         [DefaultValue(DayOfWeek.Friday)]
>         public DayOfWeek TestProperty
>         {
>             get { return DayOfWeek.Friday; }
>         }
>     }
>
> When I loaded the CustomAttributes collection of TestProperty, I
> couldn't find any thing about the type DayOfWeek. And then I traced
> into Cecil, I found a internal class CustomAttrib which contain the
> related assembly and type reference information (ElemType).
>
> May I ask why Cecil doesn't expose such useful information?
> Or I missed something?

Actually, yeah. When you use an enumeration defined in another
assembly in a CustomAttribute, Cecil will not decode the
CustomAttribute, so its property IsResolved will return false. That's
because we cannot know the size of the enumeration (byte, int32,
int64, ..) without loading the assembly the enumeration is declared
in.

By calling Resolve on the CustomAttribute, it will try to resolve the
assembly in which the enumeration is defined, so the custom attribute
is actually decoded.

-- 
Jb

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to