1 module csharp.library; 2 3 export int freeFunction (int value) { 4 return value; 5 } 6 7 export string stringFunction(string value) nothrow { 8 return value; 9 } 10 11 export s2[] arrayFunction(s2[] arr) { 12 return arr.dup; 13 } 14 15 export c1[] classRangeFunction(c1[] arr) { 16 import std.stdio; 17 writeln("Array Length: ", arr.length); 18 foreach (c1 a; arr) { 19 writeln("Class String Value: ", a.stringValue); 20 writeln("Class Int Value: ", a.intValue); 21 } 22 return arr.dup; 23 } 24 25 export string testErrorMessage(bool throwException) { 26 if(throwException) 27 throw new Exception("Test Error Message"); 28 else 29 return "No Exception Thrown"; 30 } 31 32 struct s1 { 33 public float value; 34 public s2 nestedStruct; 35 36 public float getValue() { 37 return value; 38 } 39 40 public void setNestedStruct(s2 nested) { 41 nestedStruct = nested; 42 } 43 } 44 45 struct s2 { 46 public int value; 47 public string str; 48 } 49 50 class c1 { 51 public int intValue; 52 protected string stringValue; 53 54 public this(string s, int i) { 55 intValue = i; 56 stringValue = s; 57 } 58 59 //Member test cases 60 public bool boolMember; 61 public byte byteMember; 62 public ubyte ubyteMember; 63 public short shortMember; 64 public ushort ushortMember; 65 public int intMember; 66 public uint uintMember; 67 public long longMember; 68 public ulong ulongMember; 69 public float floatMember; 70 public double doubleMember; 71 public string stringMember; 72 public wstring wstringMember; 73 public dstring dstringMember; 74 public s1 valueMember; 75 public c1 refMember; 76 public c1[] refArray; 77 public s1[] structArray; 78 79 //Property test cases 80 private s2 _structProperty; 81 public @property s2 structProperty() { 82 return _structProperty; 83 } 84 public @property s2 structProperty(s2 value) { 85 return _structProperty = value; 86 } 87 88 private c1 _refProperty; 89 public @property c1 refProperty() { 90 return _refProperty; 91 } 92 public @property c1 refProperty(c1 value) { 93 return _refProperty = value; 94 } 95 96 private ulong _valueProperty; 97 public @property ulong valueProperty() { 98 return _valueProperty; 99 } 100 public @property ulong valueProperty(ulong value) { 101 return _valueProperty = value; 102 } 103 104 private ulong[] _valueSliceProperty; 105 public @property ulong[] valueSliceProperty() { 106 return valueSliceProperty; 107 } 108 public @property ulong[] valueSliceProperty(ulong[] value) { 109 return valueSliceProperty = value; 110 } 111 112 private string[] _stringSliceProperty; 113 public @property string[] stringSliceProperty() { 114 return _stringSliceProperty; 115 } 116 public @property string[] stringSliceProperty(string[] value) { 117 return _stringSliceProperty = value; 118 } 119 120 private wstring[] _wstringSliceProperty; 121 public @property wstring[] wstringSliceProperty() { 122 return _wstringSliceProperty; 123 } 124 public @property wstring[] wstringSliceProperty(wstring[] value) { 125 return _wstringSliceProperty = value; 126 } 127 128 private dstring[] _dstringSliceProperty; 129 public @property dstring[] dstringSliceProperty() { 130 return _dstringSliceProperty; 131 } 132 public @property dstring[] dstringSliceProperty(dstring[] value) { 133 return _dstringSliceProperty = value; 134 } 135 136 private s1[] _structSliceProperty; 137 public @property s1[] structSliceProperty() { 138 return _structSliceProperty; 139 } 140 public @property s1[] structSliceProperty(s1[] value) { 141 return _structSliceProperty = value; 142 } 143 144 private c1[] _refSliceProperty; 145 public @property c1[] refSliceProperty() { 146 return _refSliceProperty; 147 } 148 public @property c1[] refSliceProperty(c1[] value) { 149 return _refSliceProperty = value; 150 } 151 152 public string testMemberFunc(string test, s1 value){ 153 return test; 154 } 155 }