Arguments to an attribute may take two forms: positional arguments and data member/property initializers. Positional arguments to the attribute (if any) must precede the data member/property initializers. A positional argument consists of a constant expression; a data member/property initializer consists of an identifier, followed by a colon and an equal sign, followed by a constant expression.
Given an attribute with attribute class T
, positional argument list P
and data member/property initializer list N
, determining whether the arguments are legal consists of the following steps:
New T(P)
. This either results in a compile time error, or determines a constructor on T
that can be invoked at runtime.Arg
in N
:
Name
be the identifier of the data member/property initializer Arg
.Name
must identify a non-shared read-write public data member or property on T
. If T
has no such data member or property, then a compile time error occurs.,
DataMemberPropertyInitializerList |,
ConstantExpression,
DataMemberPropertyInitializer:
=
ConstantExpression