Merge pull request #4938 from kumpera/optimize_ref_queries
[mono.git] / mono / tests / internalsvisibleto-compilertest.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(@internal: 0);
12                 Console.WriteLine("Access internal class internal ctor: OK");
13             } catch (MemberAccessException) {
14                 failCount += 1;
15                 Console.WriteLine("Access friend internal ctor: Fail");
16             }
17
18             Console.WriteLine("-- Wrong case --");
19
20             try {
21                 var a = new WrongCaseFriendAssembly.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                 // This also works in the Windows CLR. Huh.
30                 WrongCaseFriendAssembly.InternalClass.PrivateStaticMethod();
31                 Console.WriteLine("Access friend private static method: OK");
32             } catch (MemberAccessException) {
33                 Console.WriteLine("Access friend private static method: Fail");
34                 failCount += 1;
35             }
36
37             try {
38                 WrongCaseFriendAssembly.InternalClass.InternalStaticMethod();
39                 Console.WriteLine("Access friend internal static method: OK");
40             } catch (MemberAccessException) {
41                 failCount += 1;
42                 Console.WriteLine("Access friend internal static method: Fail");
43             }
44
45             try {
46                 WrongCaseFriendAssembly.PublicClass.InternalStaticMethod();
47                 Console.WriteLine("Access public internal static method: OK");
48             } catch (MemberAccessException) {
49                 failCount += 1;
50                 Console.WriteLine("Access public internal static method: Fail");
51             }
52
53             if (System.Diagnostics.Debugger.IsAttached)
54                 Console.ReadLine();
55
56             Console.WriteLine("Incorrect results: {0}", failCount);
57             Environment.ExitCode = failCount;
58         }
59     }
60 }