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

test-91.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 11dddc6b45c112f02bec5f40842790ef12530a74 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Reflection;

class Test {

	static protected internal void MyProtectedInternal () { }
	static internal void MyInternal() { }
	static public void MyPublic () { }
	static void MyPrivate () {}
	      
	static int Main ()
	{
		Type myself = typeof (Test);
		BindingFlags bf = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
		MethodAttributes mpia;
		MethodInfo mpi;

		//
		// protected internal
		//
		mpi = myself.GetMethod ("MyProtectedInternal", bf);
		mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
		if (mpia != MethodAttributes.FamORAssem)
			return 1;

		//
		// internal
		//
		mpi = myself.GetMethod ("MyInternal", bf);
		mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
		if (mpia != MethodAttributes.Assembly)
			return 2;

		//
		// public
		//
		mpi = myself.GetMethod ("MyPublic", bf);
		mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
		if (mpia != MethodAttributes.Public)
			return 3;

		//
		// private
		//
		mpi = myself.GetMethod ("MyPrivate", bf);
		mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
		if (mpia != MethodAttributes.Private)
			return 4;

		Console.WriteLine ("All tests pass");
		return 0;
	}
}