Skip to content

Commit 6231f78

Browse files
committed
Fixed type safety
1 parent 859cf32 commit 6231f78

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/DotNext/Sentinel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
using System.Runtime.InteropServices;
2+
13
namespace DotNext;
24

35
internal static class Sentinel
46
{
57
// instance has fixed address in memory which is critical to ValueReference implementation
6-
internal static readonly object Instance = GC.AllocateUninitializedArray<byte>(length: 0, pinned: true);
8+
internal static readonly object Instance = GC.AllocateUninitializedArray<Dummy>(length: 0, pinned: true);
9+
10+
// The struct is needed to avoid false positives caused by the type check on the variable that stores singleton
11+
[StructLayout(LayoutKind.Auto)]
12+
private struct Dummy;
713
}

0 commit comments

Comments
 (0)