Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-262.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f92c60fcd0b6ea892487805be290e84342b65867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Reflection;
using System.Runtime.InteropServices;

public class Test {
	public enum ParamEnum {
		None = 0,
		Foo = 1,
		Bar = 2
	};
	
	public void f1 ([System.Runtime.InteropServices.DefaultParameterValue (null)] object x) {}
	public void f2 ([System.Runtime.InteropServices.DefaultParameterValue (null)] string x) {}
	public void f3 ([System.Runtime.InteropServices.DefaultParameterValue (null)] Test x) {}
	public void f4 ([System.Runtime.InteropServices.DefaultParameterValue (1)] int x) {}
	public void f5 ([System.Runtime.InteropServices.DefaultParameterValue ((short) 1)] short x) {}
	public void f6 ([DefaultParameterValue (ParamEnum.Foo)] ParamEnum n) {}

	public static void Main ()
	{
		string problems = "";
		Type t = typeof (Test);
		foreach (MethodInfo m in t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) {
			ParameterInfo p = m.GetParameters () [0];
			Console.WriteLine (m.Name + " parameter attributes: " + p.Attributes);
			if ((p.Attributes & ParameterAttributes.HasDefault) == 0)
				problems = problems + " " + m.Name;
			if (problems.Length != 0)
				throw new Exception ("these functions don't have default values: " + problems);
		}
	}
}