2010-05-25 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / gtest-262.cs
blob9a71d8b6accb4c03b7e0d239b99cfd4e907f9ad5
1 using System;
2 using System.Reflection;
3 using System.Runtime.InteropServices;
5 public class Test {
6 public enum ParamEnum {
7 None = 0,
8 Foo = 1,
9 Bar = 2
12 public void f1 ([System.Runtime.InteropServices.DefaultParameterValue (null)] object x) {}
13 public void f2 ([System.Runtime.InteropServices.DefaultParameterValue (null)] string x) {}
14 public void f3 ([System.Runtime.InteropServices.DefaultParameterValue (null)] Test x) {}
15 public void f4 ([System.Runtime.InteropServices.DefaultParameterValue (1)] int x) {}
16 public void f5 ([System.Runtime.InteropServices.DefaultParameterValue ((short) 1)] short x) {}
17 public void f6 ([DefaultParameterValue (ParamEnum.Foo)] ParamEnum n) {}
19 static void Main ()
21 string problems = "";
22 Type t = typeof (Test);
23 foreach (MethodInfo m in t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) {
24 ParameterInfo p = m.GetParameters () [0];
25 Console.WriteLine (m.Name + " parameter attributes: " + p.Attributes);
26 if ((p.Attributes & ParameterAttributes.HasDefault) == 0)
27 problems = problems + " " + m.Name;
28 if (problems.Length != 0)
29 throw new Exception ("these functions don't have default values: " + problems);