[CI] ignore appdomain-unload-asmload.exe on interp and full-aot
[mono.git] / mono / tests / internalsvisibleto-runtimetest.cs
1 using System;
2
3 namespace InternalsVisibleTo {
4     class Program {
5         static void Main (string[] args) {
6             var failCount = 0;
7
8             Console.WriteLine("-- Correct case --");
9
10             try {
11                 var a = new CorrectCaseFriendAssembly.InternalClass(@private: false);
12                 Console.WriteLine("Access internal class private ctor: OK");
13                 // Microsoft behaves this way
14             } catch (MemberAccessException) {
15                 Console.WriteLine("Access internal class private ctor: Fail");
16                 // FIXME: Mono behaves this way
17                 // failCount += 1;
18             }
19
20             try {
21                 var a = new CorrectCaseFriendAssembly.InternalClass(@internal: 0);
22                 Console.WriteLine("Access internal class internal ctor: OK");
23             } catch (MemberAccessException) {
24                 failCount += 1;
25                 Console.WriteLine("Access friend internal ctor: Fail");
26             }
27
28             try {
29                 var b = new CorrectCaseFriendAssembly.InternalClass(@public: 'a');
30                 Console.WriteLine("Access internal class public ctor: OK");
31                 b.InternalMethod();
32                 Console.WriteLine("Access friend internal method: OK");
33             } catch (MemberAccessException) {
34                 failCount += 1;
35                 Console.WriteLine("Access friend internal method with wrong case: Fail");
36             }
37
38             Console.WriteLine("-- Wrong case --");
39
40             try {
41                 var a = new WrongCaseFriendAssembly.InternalClass(@private: false);
42                 // Microsoft behaves this way
43                 Console.WriteLine("Access internal class private ctor: OK");
44             } catch (MemberAccessException) {
45                 // FIXME: Mono behaves this way
46                 Console.WriteLine("Access internal class private ctor: Fail");
47                 // failCount += 1;
48             }
49
50             try {
51                 var a = new WrongCaseFriendAssembly.InternalClass(@internal: 0);
52                 Console.WriteLine("Access internal class internal ctor: OK");
53             } catch (MemberAccessException) {
54                 failCount += 1;
55                 Console.WriteLine("Access friend internal ctor: Fail");
56             }
57
58             try {
59                 var b = new WrongCaseFriendAssembly.InternalClass(@public: 'a');
60                 Console.WriteLine("Access internal class public ctor: OK");
61                 b.InternalMethod();
62                 Console.WriteLine("Access friend internal method: OK");
63             } catch (MemberAccessException) {
64                 failCount += 1;
65                 Console.WriteLine("Access friend internal method: Fail");
66             }
67
68             try {
69                 // Surprisingly this works in the Windows CLR, even though it seems like it shouldn't
70                 WrongCaseFriendAssembly.InternalClass.PrivateStaticMethod();
71                 Console.WriteLine("Access friend private static method: OK");
72             } catch (MemberAccessException) {
73                 Console.WriteLine("Access friend private static method: Fail");
74                 failCount += 1;
75             }
76
77             try {
78                 WrongCaseFriendAssembly.InternalClass.InternalStaticMethod();
79                 Console.WriteLine("Access friend internal static method: OK");
80             } catch (MemberAccessException) {
81                 failCount += 1;
82                 Console.WriteLine("Access friend internal static method: Fail");
83             }
84
85             try {
86                 WrongCaseFriendAssembly.PublicClass.InternalStaticMethod();
87                 Console.WriteLine("Access public internal static method: OK");
88             } catch (MemberAccessException) {
89                 failCount += 1;
90                 Console.WriteLine("Access public internal static method: Fail");
91             }
92
93             if (System.Diagnostics.Debugger.IsAttached)
94                 Console.ReadLine();
95
96             Console.WriteLine("Incorrect results: {0}", failCount);
97             Environment.ExitCode = failCount;
98         }
99     }
100 }