Welcome to mirror list, hosted at ThFree Co, Russian Federation.

consumer.cs « StaticInterfaceMembers « reflection « tests « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7775c4c058681fadc1a0c21ac8eda9bbb0866d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Reflection;

class Program
{
    static int Main()
    {
        {
            FieldInfo fi = typeof(IFoo<object>).GetField("O");
            object val = fi.GetValue(null);
            if (!object.ReferenceEquals(val, typeof(object[])))
                throw new Exception();
        }

        {
            MethodInfo mi = typeof(IFoo<string>).GetMethod("GimmeT");
            object val = mi.Invoke(null, Array.Empty<object>());
            if (!object.ReferenceEquals(val, typeof(string)))
                throw new Exception();
        }

        {
            MethodInfo mi = typeof(IFoo<object>).GetMethod("GimmeU").MakeGenericMethod(typeof(string));
            object val = mi.Invoke(null, Array.Empty<object>());
            if (!object.ReferenceEquals(val, typeof(string)))
                throw new Exception();
        }

        return 100;
    }
}