4 using System.Reflection;
5 [assembly: AssemblyDelaySign(true)]
6 [assembly: AssemblyKeyFile(@"internalsvisibleto-2048.snk")]
9 namespace InternalsVisibleTo {
11 static void Main (string[] args) {
14 Console.WriteLine("-- Correct case --");
17 var a = new CorrectCaseFriendAssembly.PublicClass ();
19 Console.WriteLine ("Access friend internal method: OK");
20 } catch (MemberAccessException) {
22 Console.WriteLine ("Access friend internal method: Fail");
26 var a = new CorrectCaseFriendAssembly.InternalClass(@private: false);
27 Console.WriteLine("Access internal class private ctor: OK");
28 // Microsoft behaves this way
29 } catch (MemberAccessException) {
30 Console.WriteLine("Access internal class private ctor: Fail");
31 // FIXME: Mono behaves this way
36 var a = new CorrectCaseFriendAssembly.InternalClass(@internal: 0);
37 Console.WriteLine("Access internal class internal ctor: OK");
38 } catch (MemberAccessException) {
40 Console.WriteLine("Access friend internal ctor: Fail");
44 var b = new CorrectCaseFriendAssembly.InternalClass(@public: 'a');
45 Console.WriteLine("Access internal class public ctor: OK");
47 Console.WriteLine("Access friend internal method: OK");
48 } catch (MemberAccessException) {
50 Console.WriteLine("Access friend internal method with wrong case: Fail");
53 Console.WriteLine("-- Wrong case --");
56 var a = new WrongCaseFriendAssembly.InternalClass(@private: false);
57 // Microsoft behaves this way
58 Console.WriteLine("Access internal class private ctor: OK");
59 } catch (MemberAccessException) {
60 // FIXME: Mono behaves this way
61 Console.WriteLine("Access internal class private ctor: Fail");
66 var a = new WrongCaseFriendAssembly.InternalClass(@internal: 0);
67 Console.WriteLine("Access internal class internal ctor: OK");
68 } catch (MemberAccessException) {
70 Console.WriteLine("Access friend internal ctor: Fail");
74 var b = new WrongCaseFriendAssembly.InternalClass(@public: 'a');
75 Console.WriteLine("Access internal class public ctor: OK");
77 Console.WriteLine("Access friend internal method: OK");
78 } catch (MemberAccessException) {
80 Console.WriteLine("Access friend internal method: Fail");
84 // Surprisingly this works in the Windows CLR, even though it seems like it shouldn't
85 WrongCaseFriendAssembly.InternalClass.PrivateStaticMethod();
86 Console.WriteLine("Access friend private static method: OK");
87 } catch (MemberAccessException) {
88 Console.WriteLine("Access friend private static method: Fail");
93 WrongCaseFriendAssembly.InternalClass.InternalStaticMethod();
94 Console.WriteLine("Access friend internal static method: OK");
95 } catch (MemberAccessException) {
97 Console.WriteLine("Access friend internal static method: Fail");
101 WrongCaseFriendAssembly.PublicClass.InternalStaticMethod();
102 Console.WriteLine("Access public internal static method: OK");
103 } catch (MemberAccessException) {
105 Console.WriteLine("Access public internal static method: Fail");
108 if (System.Diagnostics.Debugger.IsAttached)
111 Console.WriteLine("Incorrect results: {0}", failCount);
112 Environment.ExitCode = failCount;