public void Setup() { this.bigStruct = new BigStruct(); this.bigStruct20 = new BigStruct20(); this.bigStruct40 = new BigStruct40(); this.bigClass = new BigClass(); }
public static int Main() { BigStruct[,] a = new BigStruct[1, 3]; BigStruct v = new BigStruct(); v.x65 = 5; // Use reflection to set the array element. This will guarantee that we are not // hitting the JIT bug while setting the array element. a.SetValue(v, 0, 2); int x = a[0, 2].x65; if (x == 5) { Console.WriteLine("PASSED"); return 100; } else { Console.WriteLine("FAILED"); return 101; } }
static void Main() { decimal total = 0m; // JIT first ReturnValue(); BigStruct tmp; OutParameter(out tmp); Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < Iterations; i++) { BigStruct bs = ReturnValue(); total += bs.dec1; } sw.Stop(); Console.WriteLine("Using return value: {0}", sw.ElapsedMilliseconds); sw = Stopwatch.StartNew(); for (int i = 0; i < Iterations; i++) { BigStruct bs; OutParameter(out bs); total += bs.dec1; } Console.WriteLine("Using out parameter: {0}", sw.ElapsedMilliseconds); }
public void ByReference() { for (int i = 0; i < array.Length; i++) { ref BigStruct reference = ref array[i]; reference.Int1 = 1; reference.Int2 = 2; reference.Int3 = 3; reference.Int4 = 4; reference.Int5 = 5; }
static int NewVariableDirectSetting() { int total = 0; for (int i = 0; i < Iterations; i++) { BigStruct b = new BigStruct(); b.value = i; total += b.value; } return(total); }
static int NewVariableObjectInitializer() { int total = 0; for (int i = 0; i < Iterations; i++) { BigStruct b = new BigStruct { value = i }; total += b.value; } return(total); }
public void ByValue() { for (int i = 0; i < array.Length; i++) { BigStruct value = array[i]; value.Int1 = 1; value.Int2 = 2; value.Int3 = 3; value.Int4 = 4; value.Int5 = 5; array[i] = value; } }
public static Matrix4x4 AddTest(Matrix4x4 value1, Matrix4x4 value2) { BigStruct b = new BigStruct(); b.float1 = value1.M11 + value2.M11; b.float255 = value1.M12 + value2.M12; AddHelper(ref b); Matrix4x4 m; m = value1; m.M11 = b.float1 + b.float255; m.M12 = b.float1 - b.float255; return(m); }
public void ConsumeReference() { var collection = new[] { new BigStruct { Text = "My value" } }; BigStruct first = GetFirst(collection); // Modify first.Text = "Changed value"; // Print Console.WriteLine(collection[0].Text); }
public async Task Test_Binding_OfNestedStructs() { SqliteTable table = new SqliteTable("Item.Integer", "Item.String", "Item.Sub.Value") { new object[] { 1, "Jerrycurl", 2 }, }; BigStruct result1 = DatabaseHelper.Default.Query <BigStruct>(table).FirstOrDefault(); BigStruct result2 = (await DatabaseHelper.Default.QueryAsync <BigStruct>(table)).FirstOrDefault(); result1.Integer.ShouldBe(1); result2.Integer.ShouldBe(1); result1.String.ShouldBe("Jerrycurl"); result2.String.ShouldBe("Jerrycurl"); result1.Sub.Value.ShouldBe(2); result2.Sub.Value.ShouldBe(2); }
public static void OutParameter(out BigStruct x) { x = new BigStruct(); }
public static void Run() { var o = new TestDelegateFatFunctionPointers(); string hw = "Hello World"; string roundtrip = o.Generic <string>(hw); if (roundtrip != hw) { throw new Exception(); } { VoidGenericDelegate <object> f = o.VoidGeneric; object obj = new object(); object location = null; f(ref location, obj); if (location != obj) { throw new Exception(); } } { Func <SmallStruct, SmallStruct> f = o.SmallStructGeneric <object>; SmallStruct x = new SmallStruct { X = 12345 }; SmallStruct result = f(x); if (result.X != x.X) { throw new Exception(); } } { Func <MediumStruct, MediumStruct> f = o.MediumStructGeneric <object>; MediumStruct x = new MediumStruct { X = 12, Y = 34, Z = 56, W = 78 }; MediumStruct result = f(x); if (result.X != x.X || result.Y != x.Y || result.Z != x.Z || result.W != x.W) { throw new Exception(); } } unsafe { Func <BigStruct, BigStruct> f = o.BigStructGeneric <object>; BigStruct x = new BigStruct(); for (int i = 0; i < BigStruct.Length; i++) { x.Bytes[i] = (byte)(i * 2); } BigStruct result = f(x); for (int i = 0; i < BigStruct.Length; i++) { if (x.Bytes[i] != result.Bytes[i]) { throw new Exception(); } } } }
BigStruct BigStructGeneric <T>(BigStruct x) { return(x); }
private int Helper1(ref BigStruct data, int index) { return(data.Value1); }
public BigStruct echoBigStruct(/*[in]*/BigStruct arg) { return arg; }
public BigStruct echoBigStruct(/*[in]*/ BigStruct arg) { return(arg); }
public static void AddHelper(ref BigStruct b) { b.float1 += 1.0F; b.float255 += 2.0F; }