Skip to content

Commit

Permalink
Fixed type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 11, 2025
1 parent 859cf32 commit 6231f78
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/DotNext/Sentinel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using System.Runtime.InteropServices;

namespace DotNext;

internal static class Sentinel
{
// instance has fixed address in memory which is critical to ValueReference implementation
internal static readonly object Instance = GC.AllocateUninitializedArray<byte>(length: 0, pinned: true);
internal static readonly object Instance = GC.AllocateUninitializedArray<Dummy>(length: 0, pinned: true);

// The struct is needed to avoid false positives caused by the type check on the variable that stores singleton
[StructLayout(LayoutKind.Auto)]
private struct Dummy;
}

0 comments on commit 6231f78

Please sign in to comment.