Merge pull request #2003 from esdrubal/seq_test_fix2
[mono.git] / mcs / class / corlib / Test / System.Reflection.Emit / DynamicMethodTest.cs
1 //
2 // DynamicMethodTest.cs - NUnit Test Cases for the DynamicMethod class
3 //
4 // Gert Driesen (drieseng@users.sourceforge.net)
5 // Konrad Kruczynski
6 //
7 // (C) 2006 Novell
8
9
10 using System;
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using System.Runtime.InteropServices;
14 using System.Text;
15 using System.Diagnostics;
16 using System.Runtime.ExceptionServices;
17
18 using NUnit.Framework;
19
20 namespace MonoTests.System.Reflection.Emit
21 {
22         [TestFixture]
23         public class DynamicMethodTest
24         {
25                 private delegate int HelloInvoker (string msg);
26
27                 [Test]
28                 public void Constructor1_Name_Null ()
29                 {
30                         try {
31                                 new DynamicMethod (null,
32                                         typeof (void),
33                                         new Type[] { typeof (string) },
34                                         typeof (DynamicMethodTest).Module);
35                                 Assert.Fail ("#1");
36                         } catch (ArgumentNullException ex) {
37                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
38                                 Assert.AreEqual ("name", ex.ParamName, "#3");
39                                 Assert.IsNull (ex.InnerException, "#4");
40                         }
41                 }
42
43                 [Test]
44                 public void Constructor2_Name_Null ()
45                 {
46                         try {
47                                 new DynamicMethod (null,
48                                         typeof (void),
49                                         new Type[] { typeof (string) },
50                                         typeof (DynamicMethodTest));
51                                 Assert.Fail ("#1");
52                         } catch (ArgumentNullException ex) {
53                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
54                                 Assert.AreEqual ("name", ex.ParamName, "#3");
55                                 Assert.IsNull (ex.InnerException, "#4");
56                         }
57                 }
58
59                 [Test]
60                 public void Constructor3_Name_Null ()
61                 {
62                         try {
63                                 new DynamicMethod (null,
64                                         typeof (void),
65                                         new Type[] { typeof (string) },
66                                         typeof (DynamicMethodTest).Module, true);
67                                 Assert.Fail ("#1");
68                         } catch (ArgumentNullException ex) {
69                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
70                                 Assert.AreEqual ("name", ex.ParamName, "#3");
71                                 Assert.IsNull (ex.InnerException, "#4");
72                         }
73                 }
74
75                 [Test]
76                 public void Constructor4_Name_Null ()
77                 {
78                         try {
79                                 new DynamicMethod (null,
80                                         typeof (void),
81                                         new Type[] { typeof (string) },
82                                         typeof (DynamicMethodTest), true);
83                                 Assert.Fail ("#1");
84                         } catch (ArgumentNullException ex) {
85                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
86                                 Assert.AreEqual ("name", ex.ParamName, "#3");
87                                 Assert.IsNull (ex.InnerException, "#4");
88                         }
89                 }
90
91                 [Test]
92                 public void Constructor5_Name_Null ()
93                 {
94                         try {
95                                 new DynamicMethod (null,
96                                         MethodAttributes.Public | MethodAttributes.Static,
97                                         CallingConventions.Standard,
98                                         typeof (void),
99                                         new Type[] { typeof (string) },
100                                         typeof (DynamicMethodTest).Module, true);
101                                 Assert.Fail ("#1");
102                         } catch (ArgumentNullException ex) {
103                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
104                                 Assert.AreEqual ("name", ex.ParamName, "#3");
105                                 Assert.IsNull (ex.InnerException, "#4");
106                         }
107                 }
108
109                 [Test]
110                 public void Constructor6_Name_Null ()
111                 {
112                         try {
113                                 new DynamicMethod (null,
114                                         MethodAttributes.Public | MethodAttributes.Static,
115                                         CallingConventions.Standard,
116                                         typeof (void),
117                                         new Type[] { typeof (string) },
118                                         typeof (DynamicMethodTest), true);
119                                 Assert.Fail ("#1");
120                         } catch (ArgumentNullException ex) {
121                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
122                                 Assert.AreEqual ("name", ex.ParamName, "#3");
123                                 Assert.IsNull (ex.InnerException, "#4");
124                         }
125                 }
126
127                 [Test]
128                 public void OwnerCantBeArray ()
129                 {
130                         TestOwner (typeof (int[]));
131                 }
132
133                 [Test]
134                 public void OwnerCantBeInterface ()
135                 {
136                         TestOwner (typeof (global::System.Collections.IEnumerable));
137                 }
138
139                 private void TestOwner (Type owner)
140                 {
141                         try {
142                                 new DynamicMethod ("Name", MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard,
143                                                    typeof(void), new Type[] { }, owner, true);
144                                 Assert.Fail (string.Format ("Created dynamic method with owner being {0}.", owner));
145                         } catch (ArgumentException) {
146                         }
147                 }
148
149                 [Test] // bug #78253
150                 public void DynamicMethodReference ()
151                 {
152                         DynamicMethod hello = new DynamicMethod ("Hello",
153                                 typeof (int),
154                                 new Type[] { typeof (string) },
155                                 typeof (DynamicMethodTest).Module);
156                         Assert.IsNull (hello.DeclaringType, "#1");
157
158                         DynamicMethod write = new DynamicMethod ("Write",
159                                 typeof (int),
160                                 new Type[] { typeof (string) },
161                                 typeof (DynamicMethodTest));
162                         Assert.IsNull (hello.DeclaringType, "#2");
163
164                         MethodInfo invokeWrite = write.GetBaseDefinition ();
165
166                         ILGenerator helloIL = hello.GetILGenerator ();
167                         helloIL.Emit (OpCodes.Ldarg_0);
168                         helloIL.EmitCall (OpCodes.Call, invokeWrite, null);
169                         helloIL.Emit (OpCodes.Ret);
170
171                         ILGenerator writeIL = write.GetILGenerator ();
172                         writeIL.Emit (OpCodes.Ldc_I4_2);
173                         writeIL.Emit (OpCodes.Ret);
174
175                         HelloInvoker hi =
176                                 (HelloInvoker) hello.CreateDelegate (typeof (HelloInvoker));
177                         int ret = hi ("Hello, World!");
178                         Assert.AreEqual (2, ret, "#3");
179
180                         object[] invokeArgs = { "Hello, World!" };
181                         object objRet = hello.Invoke (null, invokeArgs);
182                         Assert.AreEqual (2, objRet, "#4");
183                 }
184
185                 [Test]
186                 public void EmptyMethodBody ()
187                 {
188                         DynamicMethod hello = new DynamicMethod ("Hello",
189                                 typeof (int),
190                                 new Type[] { typeof (string) },
191                                 typeof (DynamicMethodTest).Module);
192                         object[] invokeArgs = { "Hello, World!" };
193
194                         // no IL generator
195                         try {
196                                 hello.Invoke (null, invokeArgs);
197                                 Assert.Fail ("#1");
198                         } catch (InvalidOperationException) {
199                         }
200
201                         // empty method body
202                         hello.GetILGenerator ();
203                         try {
204                                 hello.Invoke (null, invokeArgs);
205                                 Assert.Fail ("#2");
206                         } catch (InvalidOperationException) {
207                         }
208                 }
209
210                 private delegate string ReturnString (string msg);
211                 private delegate void DoNothing (string msg);
212
213                 private static string private_method (string s) {
214                         return s;
215                 }
216
217                 [Test]
218                 public void SkipVisibility ()
219                 {
220                         DynamicMethod hello = new DynamicMethod ("Hello",
221                                 typeof (string),
222                                 new Type[] { typeof (string) },
223                                 typeof (DynamicMethodTest).Module, true);
224
225                         ILGenerator helloIL = hello.GetILGenerator ();
226                         helloIL.Emit (OpCodes.Ldarg_0);
227                         helloIL.EmitCall (OpCodes.Call, typeof (DynamicMethodTest).GetMethod ("private_method", BindingFlags.Static|BindingFlags.NonPublic), null);
228                         helloIL.Emit (OpCodes.Ret);
229
230                         ReturnString del =
231                                 (ReturnString) hello.CreateDelegate (typeof (ReturnString));
232                         Assert.AreEqual ("ABCD", del ("ABCD"));
233                 }
234
235                 [Test]
236                 public void ReturnType_Null ()
237                 {
238                         DynamicMethod hello = new DynamicMethod ("Hello",
239                                 null,
240                                 new Type[] { typeof (string) },
241                                 typeof (DynamicMethodTest).Module, true);
242                         Assert.AreEqual (typeof (void), hello.ReturnType, "#1");
243
244                         ILGenerator helloIL = hello.GetILGenerator ();
245                         helloIL.Emit (OpCodes.Ret);
246
247                         DoNothing dn = (DoNothing) hello.CreateDelegate (typeof (DoNothing));
248                         dn ("whatever");
249
250                         object[] invokeArgs = { "Hello, World!" };
251                         object objRet = hello.Invoke (null, invokeArgs);
252                         Assert.IsNull (objRet, "#2");
253                 }
254
255                 [Test]
256                 public void Name_Empty ()
257                 {
258                         DynamicMethod hello = new DynamicMethod (string.Empty,
259                                 typeof (int),
260                                 new Type[] { typeof (string) },
261                                 typeof (DynamicMethodTest).Module);
262                         Assert.AreEqual (string.Empty, hello.Name, "#1");
263
264                         DynamicMethod write = new DynamicMethod ("Write",
265                                 typeof (int),
266                                 new Type[] { typeof (string) },
267                                 typeof (DynamicMethodTest));
268
269                         MethodInfo invokeWrite = write.GetBaseDefinition ();
270
271                         ILGenerator helloIL = hello.GetILGenerator ();
272                         helloIL.Emit (OpCodes.Ldarg_0);
273                         helloIL.EmitCall (OpCodes.Call, invokeWrite, null);
274                         helloIL.Emit (OpCodes.Ret);
275
276                         ILGenerator writeIL = write.GetILGenerator ();
277                         writeIL.Emit (OpCodes.Ldc_I4_2);
278                         writeIL.Emit (OpCodes.Ret);
279
280                         HelloInvoker hi =
281                                 (HelloInvoker) hello.CreateDelegate (typeof (HelloInvoker));
282                         int ret = hi ("Hello, World!");
283                         Assert.AreEqual (2, ret, "#2");
284
285                         object[] invokeArgs = { "Hello, World!" };
286                         object objRet = hello.Invoke (null, invokeArgs);
287                         Assert.AreEqual (2, objRet, "#3");
288                 }
289
290                 [Test]
291                 public void Circular_Refs () {
292                         DynamicMethod m1 = new DynamicMethod("f1", typeof(int), new Type[] { typeof (int) },
293                                                                                                  typeof(object));
294                         DynamicMethod m2 = new DynamicMethod("f2", typeof(int), new Type[] { typeof (int) },
295                                                                                                  typeof(object));
296
297                         ILGenerator il1 = m1.GetILGenerator();
298                         ILGenerator il2 = m2.GetILGenerator();
299
300                         Label l = il1.DefineLabel ();
301                         //il1.EmitWriteLine ("f1");
302                         il1.Emit (OpCodes.Ldarg_0);
303                         il1.Emit (OpCodes.Ldc_I4_0);
304                         il1.Emit (OpCodes.Bne_Un, l);
305                         il1.Emit (OpCodes.Ldarg_0);
306                         il1.Emit (OpCodes.Ret);
307                         il1.MarkLabel (l);
308                         il1.Emit (OpCodes.Ldarg_0);
309                         il1.Emit (OpCodes.Ldc_I4_1);
310                         il1.Emit (OpCodes.Sub);
311                         il1.Emit (OpCodes.Call, m2);
312                         il1.Emit (OpCodes.Ret);
313
314                         //il2.EmitWriteLine("f2");
315                         il2.Emit(OpCodes.Ldarg_0);
316                         il2.Emit(OpCodes.Call, m1);
317                         il2.Emit(OpCodes.Ret);
318
319                         m1.Invoke(null, new object[] { 5 });
320                 }
321
322                 // Disabl known warning, the Field is never used directly from C#
323                 #pragma warning disable 414
324                 class Host {
325                         static string Field = "foo";
326                 }
327                 #pragma warning restore 414
328                 [Test]
329                 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=297416
330                 public void TestOwnerMemberAccess ()
331                 {
332                         DynamicMethod method = new DynamicMethod ("GetField",
333                                 typeof (string), new Type [0], typeof (Host));
334
335                         ILGenerator il = method.GetILGenerator ();
336                         il.Emit (OpCodes.Ldsfld, typeof (Host).GetField (
337                                 "Field", BindingFlags.Static | BindingFlags.NonPublic));
338                         il.Emit (OpCodes.Ret);
339
340                         string ret = (string) method.Invoke (null, new object [] {});
341                         Assert.AreEqual ("foo", ret, "#1");
342                 }
343
344                 [Test]
345                 public void AnonHosted ()
346                 {
347                         DynamicMethod hello = new DynamicMethod ("Hello",
348                                                                                                          typeof (int),
349                                                                                                          new Type[] { typeof (string) });
350                         ILGenerator helloIL = hello.GetILGenerator ();
351                         helloIL.Emit (OpCodes.Ldc_I4_2);
352                         helloIL.Emit (OpCodes.Ret);
353
354                         HelloInvoker hi =
355                                 (HelloInvoker) hello.CreateDelegate (typeof (HelloInvoker));
356                         int ret = hi ("Hello, World!");
357                         Assert.AreEqual (2, ret);
358
359                         object[] invokeArgs = { "Hello, World!" };
360                         object objRet = hello.Invoke (null, invokeArgs);
361                         Assert.AreEqual (2, objRet);
362                 }
363
364                 public delegate int IntInvoker();
365
366                 public class Foo<T> {
367                         public virtual int Test () { return 99; }
368                 } 
369
370                 [Test]
371                 public void ConstrainedPrexixDoesntCrash () //bug #529238
372                 {
373                         Type foo = typeof (Foo<int>);
374
375                         DynamicMethod dm = new DynamicMethod ("Hello", typeof (int), null);
376                         ILGenerator ilgen = dm.GetILGenerator ();
377                         ilgen.DeclareLocal (foo);
378                         ilgen.Emit (OpCodes.Newobj, foo.GetConstructor (new Type [0]));
379                         ilgen.Emit (OpCodes.Stloc_0);
380                         ilgen.Emit (OpCodes.Ldloca_S, 0);
381                         ilgen.Emit (OpCodes.Constrained, foo);
382                         ilgen.Emit (OpCodes.Callvirt, foo.GetMethod ("Test"));
383                         ilgen.Emit (OpCodes.Ret);
384
385                         IntInvoker hi = (IntInvoker) dm.CreateDelegate (typeof (IntInvoker));
386                         Assert.AreEqual (99, hi (), "#1");      
387                 }
388
389                 // #575955
390                 [Test]
391                 public void Module_GetMethod () {
392                         AssemblyName assemblyName = new AssemblyName ();
393                         assemblyName.Name = "foo";
394
395                         AssemblyBuilder assembly =
396                                 AppDomain.CurrentDomain.DefineDynamicAssembly (
397                                                                                                                            assemblyName, AssemblyBuilderAccess.RunAndSave);
398
399                         ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
400
401                         var d = new DynamicMethod ("foo", typeof (int), new Type [] { typeof (int[,]) }, module);
402                         var ig = d.GetILGenerator ();
403                         ig.Emit (OpCodes.Ldarg_0);
404                         ig.Emit (OpCodes.Ldc_I4, 1);
405                         ig.Emit (OpCodes.Ldc_I4, 1);
406                         ig.Emit (OpCodes.Call, module.GetArrayMethod (typeof (int[,]), "Get", CallingConventions.Standard, typeof (int), new Type [] { typeof (int), typeof (int) }));
407                         ig.Emit (OpCodes.Ret);
408                 
409                         var del = (Func<int[,], int>)d.CreateDelegate (typeof (Func<int[,], int>));
410                         int[,] arr = new int [10, 10];
411                         arr [1, 1] = 5;
412                         Assert.AreEqual (5, del (arr));
413                 }
414
415                 [Test]
416                 [Category ("NotWorking")]
417                 public void InvalidUnicodeName ()
418                 {
419                         var name = new StringBuilder ().Append ('\udf45').Append ('\ud808');
420                         var method = new DynamicMethod (name.ToString (), typeof (bool), new Type [0]);
421                         var il = method.GetILGenerator ();
422                         il.Emit (OpCodes.Ldc_I4_1);
423                         il.Emit (OpCodes.Ret);
424
425                         var function = (Func<bool>) method.CreateDelegate (typeof (Func<bool>));
426
427                         Assert.IsTrue (function ());
428                 }
429
430                 [Test]
431                 [ExpectedException (typeof (InvalidOperationException))]
432                 public void GetMethodBody ()
433                 {
434                         var method = new DynamicMethod ("method", typeof (object), new Type [] { typeof (object) });
435
436                         var il = method.GetILGenerator ();
437                         il.Emit (OpCodes.Ldarg_0);
438                         il.Emit (OpCodes.Ret);
439
440                         var f = (Func<object, object>) method.CreateDelegate (typeof (Func<object, object>));
441                         f.Method.GetMethodBody ();
442                 }
443
444         public delegate object RetObj();
445                 [Test] //#640702
446                 public void GetCurrentMethodWorksWithDynamicMethods ()
447                 {
448                 DynamicMethod dm = new DynamicMethod("Foo", typeof(object), null);
449                 ILGenerator ilgen = dm.GetILGenerator();
450                 ilgen.Emit(OpCodes.Call, typeof(MethodBase).GetMethod("GetCurrentMethod"));
451                 ilgen.Emit(OpCodes.Ret);
452                 RetObj del = (RetObj)dm.CreateDelegate(typeof(RetObj));
453                     MethodInfo res = (MethodInfo)del();
454                         Assert.AreEqual (dm.Name, res.Name, "#1");
455
456                 }
457
458                 [StructLayout (LayoutKind.Explicit)]
459                 struct SizeOfTarget {
460                         [FieldOffset (0)] public int X;
461                         [FieldOffset (4)] public int Y;
462                 }
463
464                 [Test]
465                 public void SizeOf ()
466                 {
467                         var method = new DynamicMethod ("", typeof (int), Type.EmptyTypes);
468                         var il = method.GetILGenerator ();
469                         il.Emit (OpCodes.Sizeof, typeof (SizeOfTarget));
470                         il.Emit (OpCodes.Ret);
471
472                         var func = (Func<int>) method.CreateDelegate (typeof (Func<int>));
473                         var point_size = func ();
474
475                         Assert.AreEqual (8, point_size);
476                 }
477
478                 class TypedRefTarget {
479                         public string Name;
480                 }
481
482                 class ExceptionHandling_Test_Support
483                 {
484                         public static Exception Caught;
485                         public static string CaughtStackTrace;
486
487                         public static void ThrowMe ()
488                         {
489                                 Caught = null;
490                                 CaughtStackTrace = null;
491                                 throw new Exception("test");
492                         }
493
494                         public static void Handler (Exception e)
495                         {
496                                 Caught = e;
497                                 CaughtStackTrace = e.StackTrace.ToString ();
498                         }
499                 }
500
501                 [Test]
502                 public void ExceptionHandling ()
503                 {
504                         var method = new DynamicMethod ("", typeof(void), new[] { typeof(int) }, typeof (DynamicMethodTest));
505                         var ig = method.GetILGenerator ();
506
507                         ig.BeginExceptionBlock();
508                         ig.Emit(OpCodes.Call, typeof(ExceptionHandling_Test_Support).GetMethod("ThrowMe"));
509
510                         ig.BeginCatchBlock(typeof(Exception));
511                         ig.Emit(OpCodes.Call, typeof(ExceptionHandling_Test_Support).GetMethod("Handler"));
512                         ig.EndExceptionBlock();
513
514                         ig.Emit(OpCodes.Ret);
515
516                         var invoke = (Action<int>) method.CreateDelegate (typeof(Action<int>));
517                         invoke (456324);
518
519                         Assert.IsNotNull (ExceptionHandling_Test_Support.Caught, "#1");
520                         Assert.AreEqual (2, ExceptionHandling_Test_Support.CaughtStackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.None).Length, "#2");
521
522                         var st = new StackTrace (ExceptionHandling_Test_Support.Caught, 0, true);
523
524                         // Caught stack trace when dynamic method is gone
525                         Assert.AreEqual (ExceptionHandling_Test_Support.CaughtStackTrace, st.ToString (), "#3");
526
527                         // Catch handler stack trace inside dynamic method match
528                         Assert.AreEqual (ExceptionHandling_Test_Support.Caught.StackTrace, st.ToString (), "#4");
529                 }
530
531                 class ExceptionHandlingWithExceptionDispatchInfo_Test_Support
532                 {
533                         public static Exception Caught;
534                         public static string CaughtStackTrace;
535
536                         public static void ThrowMe ()
537                         {
538                                 Caught = null;
539                                 CaughtStackTrace = null;
540
541                                 Exception e;
542                                 try {
543                                         throw new Exception("test");
544                                 } catch (Exception e2) {
545                                         e = e2;
546                                 }
547
548                                 var edi = ExceptionDispatchInfo.Capture(e);
549
550                                 edi.Throw();
551                         }
552
553                         public static void Handler (Exception e)
554                         {
555                                 var split = e.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
556                                 Assert.AreEqual (5, split.Length, "#1");
557                                 Assert.IsTrue (split [1].Contains ("---"), "#2");
558                         }
559                 }
560
561                 [Test]
562                 public void ExceptionHandlingWithExceptionDispatchInfo ()
563                 {
564                         var method = new DynamicMethod ("", typeof(void), new[] { typeof(int) }, typeof (DynamicMethodTest));
565                         var ig = method.GetILGenerator ();
566
567                         ig.BeginExceptionBlock();
568                         ig.Emit(OpCodes.Call, typeof(ExceptionHandlingWithExceptionDispatchInfo_Test_Support).GetMethod("ThrowMe"));
569
570                         ig.BeginCatchBlock(typeof(Exception));
571                         ig.Emit(OpCodes.Call, typeof(ExceptionHandlingWithExceptionDispatchInfo_Test_Support).GetMethod("Handler"));
572                         ig.EndExceptionBlock();
573
574                         ig.Emit(OpCodes.Ret);
575
576                         var invoke = (Action<int>) method.CreateDelegate (typeof(Action<int>));
577                         invoke (444);
578                 }
579
580 #if !MONODROID
581                 // RUNTIME: crash
582                 [Test]
583                 public void TypedRef ()
584                 {
585                         var method = new DynamicMethod ("", typeof (TypedRefTarget), new [] {typeof (TypedRefTarget)}, true);
586                         var il = method.GetILGenerator ();
587                         var tr = il.DeclareLocal (typeof (TypedReference));
588
589                         il.Emit (OpCodes.Ldarga, 0);
590                         il.Emit (OpCodes.Mkrefany, typeof (TypedRefTarget));
591                         il.Emit (OpCodes.Stloc, tr);
592
593                         il.Emit (OpCodes.Ldloc, tr);
594                         il.Emit (OpCodes.Call, GetType ().GetMethod ("AssertTypedRef", BindingFlags.NonPublic | BindingFlags.Static));
595
596                         il.Emit (OpCodes.Ldloc, tr);
597                         il.Emit (OpCodes.Refanyval, typeof (TypedRefTarget));
598                         il.Emit (OpCodes.Ldobj, typeof (TypedRefTarget));
599                         il.Emit (OpCodes.Ret);
600
601                         var f = (Func<TypedRefTarget, TypedRefTarget>) method.CreateDelegate (typeof (Func<TypedRefTarget, TypedRefTarget>));
602
603                         var target = new TypedRefTarget { Name = "Foo" };
604                         var rt = f (target);
605
606                         Assert.AreEqual (target, rt);
607                 }
608
609                 private static void AssertTypedRef (TypedReference tr)
610                 {
611                         Assert.AreEqual (typeof (TypedRefTarget), TypedReference.GetTargetType (tr));
612                 }
613 #endif
614         }
615 }
616