Revert "[2018-06] [System]: `MonoTlsStream` is now `IDisposable` and cleans up on...
[mono-project.git] / mono / tests / internalsvisibleto-compilertest.cs
blob196627e73e9792764c91750697685a549261a9b3
1 using System;
3 #if SIGN2048
4 using System.Reflection;
5 [assembly: AssemblyDelaySign(true)]
6 [assembly: AssemblyKeyFile(@"internalsvisibleto-2048.snk")]
7 #endif
9 namespace InternalsVisibleTo {
10 class Program {
11 static void Main (string[] args) {
12 var failCount = 0;
14 Console.WriteLine("-- Correct case --");
16 try {
17 var a = new CorrectCaseFriendAssembly.PublicClass ();
18 a.InternalMethod ();
19 Console.WriteLine ("Access friend internal method: OK");
20 } catch (MemberAccessException) {
21 failCount += 1;
22 Console.WriteLine ("Access friend internal method: Fail");
25 try {
26 var a = new CorrectCaseFriendAssembly.InternalClass(@internal: 0);
27 Console.WriteLine("Access internal class internal ctor: OK");
28 } catch (MemberAccessException) {
29 failCount += 1;
30 Console.WriteLine("Access friend internal ctor: Fail");
33 Console.WriteLine("-- Wrong case --");
35 try {
36 var a = new WrongCaseFriendAssembly.InternalClass(@internal: 0);
37 Console.WriteLine("Access internal class internal ctor: OK");
38 } catch (MemberAccessException) {
39 failCount += 1;
40 Console.WriteLine("Access friend internal ctor: Fail");
43 try {
44 // This also works in the Windows CLR. Huh.
45 WrongCaseFriendAssembly.InternalClass.PrivateStaticMethod();
46 Console.WriteLine("Access friend private static method: OK");
47 } catch (MemberAccessException) {
48 Console.WriteLine("Access friend private static method: Fail");
49 failCount += 1;
52 try {
53 WrongCaseFriendAssembly.InternalClass.InternalStaticMethod();
54 Console.WriteLine("Access friend internal static method: OK");
55 } catch (MemberAccessException) {
56 failCount += 1;
57 Console.WriteLine("Access friend internal static method: Fail");
60 try {
61 WrongCaseFriendAssembly.PublicClass.InternalStaticMethod();
62 Console.WriteLine("Access public internal static method: OK");
63 } catch (MemberAccessException) {
64 failCount += 1;
65 Console.WriteLine("Access public internal static method: Fail");
68 if (System.Diagnostics.Debugger.IsAttached)
69 Console.ReadLine();
71 Console.WriteLine("Incorrect results: {0}", failCount);
72 Environment.ExitCode = failCount;