protected virtual bool VerifyClsCompliance ()
{
if (HasClsCompliantAttribute) {
if (!Module.DeclaringAssembly.HasCLSCompliantAttribute) {
Attribute a = OptAttributes.Search (Module.PredefinedAttributes.CLSCompliant);
if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) {
Report.Warning (3021, 2, a.Location,
"`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant",
GetSignatureForError ());
} else {
Report.Warning (3014, 1, a.Location,
"`{0}' cannot be marked as CLS-compliant because the assembly is not marked as CLS-compliant",
GetSignatureForError ());
}
return false;
}
if (!IsExposedFromAssembly ()) {
Attribute a = OptAttributes.Search (Module.PredefinedAttributes.CLSCompliant);
Report.Warning (3019, 2, a.Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
return false;
}
if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) {
if (Parent is Interface && Parent.IsClsComplianceRequired ()) {
Report.Warning (3010, 1, Location, "`{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError ());
} else if (Parent.Kind == MemberKind.Class && (ModFlags & Modifiers.ABSTRACT) != 0 && Parent.IsClsComplianceRequired ()) {
Report.Warning (3011, 1, Location, "`{0}': only CLS-compliant members can be abstract", GetSignatureForError ());
}
return false;
}
if (Parent.Kind != MemberKind.Namespace && Parent.Kind != 0 && !Parent.IsClsComplianceRequired ()) {
Attribute a = OptAttributes.Search (Module.PredefinedAttributes.CLSCompliant);
Report.Warning (3018, 1, a.Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'",
GetSignatureForError (), Parent.GetSignatureForError ());
return false;
}
} else {
if (!IsExposedFromAssembly ())
return false;
if (!Parent.IsClsComplianceRequired ())
return false;
}
if (member_name.Name [0] == '_') {
Warning_IdentifierNotCompliant ();
}
if (member_name.TypeParameters != null)
member_name.TypeParameters.VerifyClsCompliance ();
return true;
}