[runtime] Accomplish BITCODE build symbol sharing with only make (#3329)
[mono-project.git] / mono / tests / shared-generic-synchronized.2.cs
blob2145f0561c00cfea150b74a07b4b78c70a1ce635
1 //
2 // shared-generic-synchronized.2.cs:
3 //
4 // Tests for the 'synchronized' method attribute in shared generic methods
5 //
7 using System;
8 using System.Threading;
9 using System.Runtime.CompilerServices;
11 public class Test<T> {
13 [MethodImplAttribute(MethodImplOptions.Synchronized)]
14 public int test () {
15 Monitor.Exit (this);
16 Monitor.Enter (this);
17 return 2 + 2;
20 [MethodImplAttribute(MethodImplOptions.Synchronized)]
21 public static int test_static () {
22 Monitor.Exit (typeof (Test<T>));
23 Monitor.Enter (typeof (Test<T>));
24 return 2 + 2;
27 [MethodImplAttribute(MethodImplOptions.Synchronized)]
28 public int test_exception () {
29 Monitor.Exit (this);
30 throw new Exception ("A");
33 [MethodImplAttribute(MethodImplOptions.Synchronized)]
34 public virtual int test_virtual () {
35 Monitor.Exit (this);
36 Monitor.Enter (this);
37 return 2 + 2;
41 class main {
42 public delegate int Delegate1 ();
44 static public int Main (String[] args) {
45 Test<string> b = new Test<string> ();
46 int res;
48 Console.WriteLine ("Test1...");
49 b.test ();
50 Console.WriteLine ("Test2...");
51 Test<string>.test_static ();
52 Console.WriteLine ("Test3...");
53 try {
54 b.test_exception ();
56 catch (SynchronizationLockException ex) {
57 // OK
59 catch (Exception ex) {
60 // The other exception should be overwritten by the lock one
61 return 1;
64 Console.WriteLine ("Test4...");
65 b.test_virtual ();
67 Console.WriteLine ("Test5...");
68 Delegate1 d = new Delegate1 (b.test);
69 res = d ();
71 Console.WriteLine ("Test6...");
72 d = new Delegate1 (Test<string>.test_static);
73 res = d ();
75 Console.WriteLine ("Test7...");
76 d = new Delegate1 (b.test_virtual);
77 res = d ();
79 Console.WriteLine ("Test8...");
80 d = new Delegate1 (b.test_exception);
81 try {
82 d ();
84 catch (SynchronizationLockException ex) {
85 // OK
87 catch (Exception ex) {
88 return 2;
91 return 0;