Hi, Jb

On Aug 6, 5:18 pm, Jb Evain <[email protected]> wrote:
> On Fri, Aug 6, 2010 at 7:15 AM, Wicky <[email protected]> wrote:
> > I don't know it would fail before accessing it, right?
>
> You can know.
>
> static bool IsResolvable (CustomAttribute attribute)
> {
>     try {
>         foreach (var parameter in attribute.Constructor.Parameters)
>             if (parameter.ParameterType.Resolve () == null)
>                 return false;
>     } catch (FileNotFoundException) {
>         return false;
>     }
>
>     return true;
>
> }

I tried your function, but seems not working as expected.

For example:
 public class EnumTest
    {
        [DefaultValue(EnumByte.EV2), Description("EnumByte")]
        public void FooA()
        {
        }
    }

EnumByte is defined in another assembly, the parameter types for above
two attributes are System.Object and System.String, so they can both
be resolved.

Any idea?

Thanks
Wicky

-- 
--
mono-cecil

Reply via email to