Hi

It used to be the case that CustomAttribute.ConstructorArguments[i]
contains a struct of type CustomAttributeArgument containing only the
type and value of the constructor *argument*, i.e. something
reminiscent of this:

    new CustomAttributeArgument {
        Type = <argument type>,
        Value = <argument value>
    }

However, this seems to have changed. It seems that in some cases, this
struct now contains two levels; at the first level, the type is the
type of the constructor *parameter*, i.e. I seem to get something
reminiscent of this:

    new CustomAttributeArgument {
        Type = <parameter type>,
        Value = new CustomAttributeArgument {
            Type = <argument type>,
            Value = <argument value>
        }
    }

In particular, this happens if the constructor *parameter* is of type
“object” and the constructor *argument* is of an enum type. In other
words, I get this:

    new CustomAttributeArgument {
        Type = "System.Object",
        Value = new CustomAttributeArgument {
            Type = "MyProject.MyEnum",
            Value = <an integer>
        }
    }

I suspect that this is the result of the following change in git:
http://goo.gl/b8Yyr

Is this behaviour intentional? It seems that it would require all
users of this API to make a special case for when the Value is of type
“CustomAttributeArgument”.

I think the preferred behaviour would be what it used to be: the
“Type” field should specify only the *argument* type (in this case,
MyEnum). The *parameter* type can always be retrieved by looking at
CustomAttribute.Constructor.Parameters[i].ParameterType.

What do you think?

-- 
--
mono-cecil

Reply via email to