public bool DoResolve(ResolveContext rc) { AttributeType.LookForAttribute = true; ResolvedAttribute = CreateResolvedAttribute(rc); if (ResolvedAttribute.AttributeType is UnknownTypeSpec) { rc.Report.Error(151, Location, "The attribute type `{0}' does not exist in the current context", AttributeType.GetSignatureForError()); } else { if (ResolvedAttribute.AttributeType is ResolvedTypeDefinitionSpec) { var t = ResolvedAttribute.AttributeType as ResolvedTypeDefinitionSpec; if (t.IsAbstract) { rc.Report.Error(168, Location, "Cannot apply attribute class `{0}' because it is abstract", ResolvedAttribute.AttributeType.ToString()); } if (t.IsStatic) { rc.Report.Error(169, Location, "Cannot apply attribute class `{0}' because it is static", ResolvedAttribute.AttributeType.ToString()); } } bool is_attrib = false; foreach (IType b in ResolvedAttribute.AttributeType.DirectBaseTypes) { if (b.FullName == "Std.Attribute") { is_attrib = true; break; } } if (!is_attrib) { rc.Report.Error(170, Location, "<`{0}': is not an attribute class", ResolvedAttribute.AttributeType.ToString()); } // ctor checking var ctor = (ResolvedAttribute as VSharpResolvedAttribute).GetCtorInvocation(); if (ctor != null && ctor.IsError) { rc.Report.Error(171, Location, "A constructor has been found for `{0}' but an error has occured", ResolvedAttribute.AttributeType.ToString()); } else if (ctor == null) { rc.Report.Error(172, Location, "No suitable constructor has been found for `{0}'", ResolvedAttribute.AttributeType.ToString()); } } return(true); }