/// <summary>
/// Get a string containing a list of valid targets for the attribute 'attr'
/// </summary>
- static string GetValidTargets (Attribute attr)
+ public string GetValidTargets ()
{
StringBuilder sb = new StringBuilder ();
- AttributeTargets targets = attr.GetAttributeUsage ().ValidOn;
+ AttributeTargets targets = GetAttributeUsage ().ValidOn;
if ((targets & AttributeTargets.Assembly) != 0)
sb.Append ("'assembly' ");
}
- public static void Error_AttributeNotValidForElement (Attribute a, Location loc)
- {
- Report.Error (
- 592, loc, "Attribute '" + a.Name +
- "' is not valid on this declaration type. " +
- "It is valid on " + GetValidTargets (a) + "declarations only.");
- }
-
-
/// <summary>
/// Returns AttributeUsage attribute for this type
/// </summary>
return attr_class.AttributeUsage;
}
-
- //
- // This pulls the condition name out of a Conditional attribute
- //
- public string Conditional_GetConditionName ()
- {
- //
- // So we have a Conditional, pull the data out.
- //
- if (Arguments == null || Arguments [0] == null){
- Error_AttributeConstructorMismatch ();
- return null;
- }
-
- ArrayList pos_args = (ArrayList) Arguments [0];
- if (pos_args.Count != 1){
- Error_AttributeConstructorMismatch ();
- return null;
- }
-
- Argument arg = (Argument) pos_args [0];
- if (!(arg.Expr is StringConstant)){
- Error_AttributeConstructorMismatch ();
- return null;
- }
-
- return ((StringConstant) arg.Expr).Value;
- }
-
public string IndexerName_GetIndexerName (EmitContext ec)
{
if (Arguments == null || Arguments [0] == null){
AttributeUsageAttribute usage_attr = GetAttributeUsage ();
if ((usage_attr.ValidOn & ias.AttributeTargets) == 0) {
- Error_AttributeNotValidForElement (this, Location);
+ // "Attribute '{0}' is not valid on this declaration type. It is valid on {1} declarations only.";
+ Report.Error_T (592, Location, Name, GetValidTargets ());
return;
}
ias.ApplyAttributeBuilder (this, cb);
- if (!usage_attr.AllowMultiple && emitted_attr.Contains (Target)) {
+ if (!usage_attr.AllowMultiple) {
+ ArrayList emitted_targets = (ArrayList)emitted_attr [Type];
+ if (emitted_targets == null) {
+ emitted_targets = new ArrayList ();
+ emitted_attr.Add (Type, emitted_targets);
+ } else if (emitted_targets.Contains (Target)) {
Report.Error (579, Location, "Duplicate '" + Name + "' attribute");
+ return;
+ }
+ emitted_targets.Add (Target);
}
- emitted_attr [Type] = Target;
-
// Here we are testing attribute arguments for array usage (error 3016)
if (ias.IsClsCompliaceRequired (ec.DeclSpace)) {
if (Arguments == null)
if (mc != null)
return mc.GetObsoleteAttribute ();
- // TODO: remove after Constructor will be ready for IMethodData
- if ((mb.DeclaringType is TypeBuilder) || mb.DeclaringType.IsGenericInstance)
- return null;
-
return GetMemberObsoleteAttribute (mb);
}
if (type_obsolete != null)
return (ObsoleteAttribute)type_obsolete;
+ if ((mi.DeclaringType is TypeBuilder) || mi.DeclaringType.IsGenericInstance)
+ return null;
+
ObsoleteAttribute oa = System.Attribute.GetCustomAttribute (mi, TypeManager.obsolete_attribute_type, false) as ObsoleteAttribute;
analyzed_member_obsolete.Add (mi, oa == null ? FALSE : oa);
return oa;
object excluded = analyzed_method_excluded [mb];
if (excluded != null)
return excluded == TRUE ? true : false;
+
+ if (mb.Mono_IsInflatedMethod)
+ return false;
ConditionalAttribute[] attrs = mb.GetCustomAttributes (TypeManager.conditional_attribute_type, true) as ConditionalAttribute[];
if (attrs.Length == 0) {