Hey,
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;
}
> Even I know one of ConstructorArguments cannot be resolved, then how
> can I access other ConstructorArguments(or Perperties and Fields)?
You can't, that's not specific to Cecil, it's specific to the custom
attribute encoding format. Basically the issue is that they encode
enums using their underlying type's value. And there's no way to read
this value properly (it can be anything between one and eight bytes
long) without resolving the enumeration type to know the actual size
of the enum. Cecil can't take a guess here.
> I can get TypeReference of the enum type, it's ok for me, but how to
> get the value 0 without resolve it?
As I said, it's not possible.
--
Jb EvainĀ <[email protected]>
--
--
mono-cecil