private static bool ProblemWithPrimitiveDst() { WrapTuple p = new WrapTuple { FieldOne = { Value = 1 }, FieldTwo = { Value = 2 } }; Wrap a = p.FieldTwo; WrapTuple.GetFieldTwo(ref p) = a; if (a.Value == p.FieldOne.Value) { return(true); } WrapTuple.GetFieldOne(ref p) = a; if (a.Value != p.FieldOne.Value) { return(true); } return(false); }
private static bool ProblemWithPrimitiveSrc() { WrapTuple p = new WrapTuple { FieldOne = { Value = 1 }, FieldTwo = { Value = 2 } }; Wrap a = p.FieldTwo; Wrap b = WrapTuple.GetFieldTwo(ref p); if (a.Value != b.Value) { return(true); } a = p.FieldOne; b = WrapTuple.GetFieldOne(ref p); if (a.Value != b.Value) { return(true); } return(false); }
public static ref Wrap GetFieldTwo(ref WrapTuple t) => ref Unsafe.Add(ref t.FieldOne, 1);