(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / Test / System.Reflection / ParameterInfoTest.cs
bloba025c7ca9be73e161d6f9754153918c20993e8fb
1 //
2 // ParameterInfoTest - NUnit Test Cases for the ParameterInfo class
3 //
4 // Zoltan Varga (vargaz@freemail.hu)
5 //
6 // (C) Ximian, Inc. http://www.ximian.com
7 //
8 //
10 using System;
11 using System.Threading;
12 using System.Reflection;
13 using System.Reflection.Emit;
14 using System.Runtime.InteropServices;
16 using NUnit.Framework;
18 namespace MonoTests.System.Reflection
22 public class Marshal1 : ICustomMarshaler
24 public static ICustomMarshaler GetInstance (string s) {
25 return new Marshal1 ();
28 public void CleanUpManagedData (object managedObj)
32 public void CleanUpNativeData (IntPtr pNativeData)
36 public int GetNativeDataSize ()
38 return 4;
41 public IntPtr MarshalManagedToNative (object managedObj)
43 return IntPtr.Zero;
46 public object MarshalNativeToManaged (IntPtr pNativeData)
48 return null;
52 [TestFixture]
53 public class ParameterInfoTest : Assertion
55 public static void paramMethod (int i, [In] int j, [Out] int k, [Optional] int l, [In,Out] int m) {
58 [DllImport ("foo")]
59 public extern static void marshalAsMethod (
60 [MarshalAs(UnmanagedType.Bool)]int p0,
61 [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)] string [] p1,
62 [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal1), MarshalCookie = "5")] object p2);
64 #if NET_2_0
65 [Test]
66 public void PseudoCustomAttributes () {
67 ParameterInfo[] info = typeof (ParameterInfoTest).GetMethod ("paramMethod").GetParameters ();
68 AssertEquals (0, info[0].GetCustomAttributes (true).Length);
69 AssertEquals (1, info[1].GetCustomAttributes (typeof (InAttribute), true).Length);
70 AssertEquals (1, info[2].GetCustomAttributes (typeof (OutAttribute), true).Length);
71 AssertEquals (1, info[3].GetCustomAttributes (typeof (OptionalAttribute), true).Length);
72 AssertEquals (2, info[4].GetCustomAttributes (true).Length);
74 ParameterInfo[] pi = typeof (ParameterInfoTest).GetMethod ("marshalAsMethod").GetParameters ();
75 MarshalAsAttribute attr;
77 attr = (MarshalAsAttribute)(pi [0].GetCustomAttributes (true) [0]);
78 AssertEquals (UnmanagedType.Bool, attr.Value);
80 attr = (MarshalAsAttribute)(pi [1].GetCustomAttributes (true) [0]);
81 AssertEquals (UnmanagedType.LPArray, attr.Value);
82 AssertEquals (UnmanagedType.LPStr, attr.ArraySubType);
84 attr = (MarshalAsAttribute)(pi [2].GetCustomAttributes (true) [0]);
85 AssertEquals (UnmanagedType.CustomMarshaler, attr.Value);
86 AssertEquals ("5", attr.MarshalCookie);
87 AssertEquals (typeof (Marshal1), Type.GetType (attr.MarshalType));
89 #endif