public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.AttributeUsage) { if (!BaseType.IsAttribute && spec.BuiltinType != BuiltinTypeSpec.Type.Attribute) { Report.Error (641, a.Location, "Attribute `{0}' is only valid on classes derived from System.Attribute", a.GetSignatureForError ()); } } if (a.Type == pa.Conditional && !BaseType.IsAttribute) { Report.Error (1689, a.Location, "Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods or attribute classes"); return; } if (a.Type == pa.ComImport && !attributes.Contains (pa.Guid)) { a.Error_MissingGuidAttribute (); return; } if (a.Type == pa.Extension) { a.Error_MisusedExtensionAttribute (); return; } if (a.Type.IsConditionallyExcluded (this)) return; base.ApplyAttributeBuilder (a, ctor, cdata, pa); }
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.Conditional) { if (IsExplicitImpl) { Error_ConditionalAttributeIsNotValid (); return; } if ((ModFlags & Modifiers.OVERRIDE) != 0) { Report.Error (243, Location, "Conditional not valid on `{0}' because it is an override method", GetSignatureForError ()); return; } if (ReturnType.Kind != MemberKind.Void) { Report.Error (578, Location, "Conditional not valid on `{0}' because its return type is not void", GetSignatureForError ()); return; } if (IsInterface) { Report.Error (582, Location, "Conditional not valid on interface members"); return; } if (MethodData.implementing != null) { Report.SymbolRelatedToPreviousError (MethodData.implementing.DeclaringType); Report.Error (629, Location, "Conditional member `{0}' cannot implement interface member `{1}'", GetSignatureForError (), TypeManager.CSharpSignature (MethodData.implementing)); return; } for (int i = 0; i < parameters.Count; ++i) { if ((parameters.FixedParameters [i].ModFlags & Parameter.Modifier.OUT) != 0) { Report.Error (685, Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError ()); return; } } } if (a.Type == pa.Extension) { a.Error_MisusedExtensionAttribute (); return; } base.ApplyAttributeBuilder (a, ctor, cdata, pa); }