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