3
using System.Reflection;
4
using csharp_prepostNamespace;
6
public class csharp_prepost_runme {
8
public static void Main() {
11
csharp_prepost.globalfunction(out v);
19
new PrePostTest(out v);
26
PrePostTest p = new PrePostTest();
34
PrePostTest.staticmethod(out v);
40
// Check attributes are generated for the constructor helper function
42
CsinAttributes c = new CsinAttributes(5);
43
Assert(c.getVal(), 500);
45
Type type = typeof(CsinAttributes);
47
MethodInfo member = (MethodInfo)type.GetMember("SwigConstructCsinAttributes", BindingFlags.NonPublic | BindingFlags.Static)[0];
48
if (Attribute.GetCustomAttribute(member, typeof(CustomIntPtrAttribute)) == null)
49
throw new Exception("No CustomIntPtr attribute for " + member.Name);
50
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
51
if (parameter.Name != "val")
52
throw new Exception("Incorrect parameter name");
53
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
54
if (attribute.GetType() != typeof(CustomIntAttribute))
55
throw new Exception("Expecting CustomInt attribute");
59
private static void Assert(double d1, double d2) {
61
throw new Exception("assertion failure. " + d1 + " != " + d2);
65
// Custom attribute classes
66
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
67
public class CustomIntAttribute : Attribute {}
69
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
70
public class CustomIntPtrAttribute : Attribute {}