[corlib] Preserve List<T>.ConvertAll in TypeTest (#5215)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 15 Jul 2017 23:49:00 +0000 (01:49 +0200)
committerGitHub <noreply@github.com>
Sat, 15 Jul 2017 23:49:00 +0000 (01:49 +0200)
TypeTest.GetGenericMethodDefinitionOverInflatedMethodOnGTD accesses
List<T>.ConvertAll() via reflection but doesn't use the method
elsewhere so the linker can remove it. Added some usage to avoid that.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=56242

mcs/class/corlib/Test/System/TypeTest.cs

index 9cc8ca79a413f707d27ad210899583c3fdb03456..d03e4c21f2af694ee1ea2bf45fa97fad43341c19 100644 (file)
@@ -2261,11 +2261,14 @@ namespace MonoTests.System
 
                [Test]
                public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
+                       var s = new List<int> () { 1, 2, 3 }.ConvertAll ( i => i.ToString () );
+                       Assert.AreEqual (3, s.Count);
                        var l = typeof (List<>);
                        var m = l.GetMethod ("ConvertAll");
                        var infl = m.MakeGenericMethod (typeof (int));
                        var res = m.GetGenericMethodDefinition ();
                        Assert.AreEqual (m, res, "#1");
+                       Assert.AreEqual (1, infl.GetGenericArguments().Length, "#2");
                }
 
                [Test]