Skip to content

Commit

Permalink
restored SqlTypeWorkarounds.SqlGuidCtor for non .NET8 tagrets
Browse files Browse the repository at this point in the history
This reverts commit 288a70c partially
  • Loading branch information
wilbit committed Jan 19, 2024
1 parent 00db92d commit 1f4676d
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,31 @@ private struct SqlBinaryCaster
internal SqlBinaryLookalike Fake;
}
#endregion

#region Work around inability to access SqlGuid.ctor(byte[], bool)
internal static SqlGuid SqlGuidCtor(byte[] value, bool ignored)
{
// Construct a SqlGuid without allocating/copying the byte[]. This provides
// the same behavior as SqlGuid.ctor(byte[], bool).
var c = default(SqlGuidCaster);
c.Fake._value = value;
return c.Real;
}

[StructLayout(LayoutKind.Sequential)]
private struct SqlGuidLookalike
{
internal byte[] _value;
}

[StructLayout(LayoutKind.Explicit)]
private struct SqlGuidCaster
{
[FieldOffset(0)]
internal SqlGuid Real;
[FieldOffset(0)]
internal SqlGuidLookalike Fake;
}
#endregion
}
}

0 comments on commit 1f4676d

Please sign in to comment.