public void VerifyClsCompliance ()
{
if (types == null || cls_checked)
return;
cls_checked = true;
// TODO: This is quite ugly way to check for CLS compliance at namespace level
var locase_types = new Dictionary<string, List<TypeSpec>> (StringComparer.OrdinalIgnoreCase);
foreach (var tgroup in types.Values) {
foreach (var tm in tgroup) {
if ((tm.Modifiers & Modifiers.PUBLIC) == 0 || !tm.IsCLSCompliant ())
continue;
List<TypeSpec> found;
if (!locase_types.TryGetValue (tm.Name, out found)) {
found = new List<TypeSpec> ();
locase_types.Add (tm.Name, found);
}
found.Add (tm);
}
}
foreach (var locase in locase_types.Values) {
if (locase.Count < 2)
continue;
bool all_same = true;
foreach (var notcompliant in locase) {
all_same = notcompliant.Name == locase[0].Name;
if (!all_same)
break;
}
if (all_same)
continue;
TypeContainer compiled = null;
foreach (var notcompliant in locase) {
if (!notcompliant.MemberDefinition.IsImported) {
if (compiled != null)
compiled.Compiler.Report.SymbolRelatedToPreviousError (compiled);
compiled = notcompliant.MemberDefinition as TypeContainer;
} else {
compiled.Compiler.Report.SymbolRelatedToPreviousError (notcompliant);
}
}
compiled.Compiler.Report.Warning (3005, 1, compiled.Location,
"Identifier `{0}' differing only in case is not CLS-compliant", compiled.GetSignatureForError ());
}
}
}