diff --git a/mcs/class/corlib/Test/System/TypeTest.cs b/mcs/class/corlib/Test/System/TypeTest.cs index 6608ef9cc430..2c9bd2728afd 100644 --- a/mcs/class/corlib/Test/System/TypeTest.cs +++ b/mcs/class/corlib/Test/System/TypeTest.cs @@ -4886,6 +4886,30 @@ public void NullFullNameForSpecificGenericTypes() } } + // https://github.com/mono/mono/issues/6579 + [Test] + public void GetInterfaceCaseInsensitiveTest() + { + var type = typeof(Dictionary); + + Assert.NotNull ( + type.GetInterface ("System.Collections.IDictionary", false), + "strict named interface must be found (ignoreCase = false)" + ); + Assert.NotNull ( + type.GetInterface ("System.Collections.IDictionary", true), + "strict named interface must be found (ignoreCase = true)" + ); + Assert.Null ( + type.GetInterface ("System.Collections.Idictionary", false), + "interface, named in mixed case, must not be found (ignoreCase = false)" + ); + Assert.NotNull ( + type.GetInterface ("System.Collections.Idictionary", true), + "interface, named in mixed case, must be found (ignoreCase = true)" + ); + } + interface Bug59738Interface { } diff --git a/mcs/class/referencesource/mscorlib/system/rttype.cs b/mcs/class/referencesource/mscorlib/system/rttype.cs index 61b46433b342..42a445bc5cf5 100644 --- a/mcs/class/referencesource/mscorlib/system/rttype.cs +++ b/mcs/class/referencesource/mscorlib/system/rttype.cs @@ -3413,9 +3413,12 @@ public override Type GetInterface(String fullname, bool ignoreCase) #if MONO List list = null; + var nameComparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; foreach (RuntimeType t in GetInterfaces ()) { - if (t.Name != name) - continue; + + if (!String.Equals(t.Name, name, nameComparison)) { + continue; + } if (list == null) list = new List (2);