I have a CustomAttribute that contains public properties.  I want to
set these properties at compile time based on the location.

e.g.

    public class AttachDataAttribute : Attribute
    {
        /// <summary>
        /// The type this attribute was attached to (if attached to a
type).
        /// </summary>
        /// <remarks>
        /// An attribtue that is attached to an assembly directly is
not attached to a type,
        /// and so this value will be <see langword="null"/>.
        /// <para>If present this value is set at compile time by the
weaver. It is entirely
        /// optional in a weave. </para>
        /// <para>To match the name must match AttachedType and be a
readonly field
        /// of Type <see cref="Type"/>.</para></remarks>
        public Type AttachedType;
   }


    [AttachData]
    public class AttachmentDataTester
    {
        [AttachData]
        public int Method()
        {
            return 0;
        }
    }

In this case I want to set the 'AttachedType' property automatically
to the 'AttachmentDataTester' for the two cases.

I have the CustomAttributes, and I believe I need to use
Constructor.Paramter.Add(), however, Constructor.Parameter is null in
the case there are no parameters already.

Do I have to remove the existing attribute and re-add it or is it
possible to add the extra parameters (i.e.
AttachedType=typeof(AttachmentDataTester) to the existing attribute,
if so how?

I've used Type as an example as this has been mentioned before, I
believe you suggest the TypeReference should be set to System.Type
(can do) and the value should be TypeReference.FullName (i.e. a
string) - is this right?

Thanks in anticipation of your help.

-- 
--
mono-cecil

Reply via email to