1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
21
public static class ValueTypes
32
public void SetField()
37
public void MethodCalls()
40
ValueTypes.S.Test(this);
41
ValueTypes.S.Test(ref this);
44
private static void Test(ValueTypes.S byVal)
48
private static void Test(ref ValueTypes.S byRef)
53
private static readonly ValueTypes.S ReadOnlyS = default(ValueTypes.S);
54
private static ValueTypes.S MutableS = default(ValueTypes.S);
55
private static volatile int VolatileInt;
57
public static void CallMethodViaField()
59
ValueTypes.ReadOnlyS.SetField();
60
ValueTypes.MutableS.SetField();
61
ValueTypes.S mutableS = ValueTypes.MutableS;
65
public static ValueTypes.S InitObj1()
67
ValueTypes.S result = default(ValueTypes.S);
68
ValueTypes.MakeArray();
72
public static ValueTypes.S InitObj2()
74
return default(ValueTypes.S);
77
public static void InitObj3(out ValueTypes.S p)
79
p = default(ValueTypes.S);
82
public static ValueTypes.S CallValueTypeCtor1()
84
return new ValueTypes.S(10);
87
public static ValueTypes.S CallValueTypeCtor2()
89
ValueTypes.S result = new ValueTypes.S(10);
93
public static ValueTypes.S Copy1(ValueTypes.S p)
98
public static ValueTypes.S Copy2(ref ValueTypes.S p)
103
public static void Copy3(ValueTypes.S p, out ValueTypes.S o)
108
public static void Copy4(ref ValueTypes.S p, out ValueTypes.S o)
113
public static void Copy4b(ref ValueTypes.S p, out ValueTypes.S o)
115
// test passing through by-ref arguments
116
ValueTypes.Copy4(ref p, out o);
119
public static void Issue56(int i, out string str)
125
public static void CopyAroundAndModifyField(ValueTypes.S s)
132
private static int[] MakeArray()
137
public static void IncrementArrayLocation()
139
ValueTypes.MakeArray()[Environment.TickCount]++;
142
public static bool Is(object obj)
144
return obj is ValueTypes.S;
147
public static bool IsNullable(object obj)
149
return obj is ValueTypes.S?;
152
public static ValueTypes.S? As(object obj)
154
return obj as ValueTypes.S?;
157
public static ValueTypes.S OnlyChangeTheCopy(ValueTypes.S p)
164
public static void UseRefBoolInCondition(ref bool x)
168
Console.WriteLine("true");