PointerToolkit 1.0.0-preview1

This is a prerelease version of PointerToolkit.
There is a newer version of this package available.
See the version list below for details.
dotnet add package PointerToolkit --version 1.0.0-preview1                
NuGet\Install-Package PointerToolkit -Version 1.0.0-preview1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PointerToolkit" Version="1.0.0-preview1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PointerToolkit --version 1.0.0-preview1                
#r "nuget: PointerToolkit, 1.0.0-preview1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PointerToolkit as a Cake Addin
#addin nuget:?package=PointerToolkit&version=1.0.0-preview1&prerelease

// Install PointerToolkit as a Cake Tool
#tool nuget:?package=PointerToolkit&version=1.0.0-preview1&prerelease                

UnsafeRuntime

Provides structs that wrap pointers, Unsafe methods for converting to and from ref pointers of any type, as well as Interlocked and Volatile operations on ref pointers.

Even using the built-in System.Runtime.CompilerServices.Unsafe class, you cannot reinterpret refs to raw pointers for use in calls to methods such as Interlocked.Exchange() or Volatile.Read().

Pointers up to 3 levels of indirection are supported, e.g. void*** and T***. The helper classes UnsafePtr, InterlockedPtr, and VolatilePtr are provided.

We may get this in .NET itself someday, if https://github.com/dotnet/runtime/issues/62342 is approved and landed. Until then, you can use this.

namespace PointerToolkit;

public static unsafe class UnsafePtr
{
    public static ref T As<T>(ref void* source)
        where T : unmanaged;

    public static ref U As<T, U>(ref T* source)
        where T : unmanaged
        where U : unmanaged;

    // etc.
}

public static unsafe class InterlockedPtr
{
    public static void* Exchange(ref void* location1, void* value);

    public static T* Exchange<T>(ref T* location1, T* value)
        where T : unmanaged;

    // etc.
}

public static unsafe class VolatilePtr
{
    public static void* Read(ref void* location);

    public static T* Read<T>(ref T* location)
        where T : unmanaged;

    public static void Write(ref void* location, void* value);

    public static void Write<T>(ref T* location, T* value)
        where T : unmanaged;

    // etc.
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 239 12/30/2023
1.0.0 424 11/29/2022
1.0.0-preview8 138 11/9/2022
1.0.0-preview7 212 1/26/2022
1.0.0-preview6 156 1/3/2022
1.0.0-preview5 147 12/7/2021
1.0.0-preview4 167 12/7/2021
1.0.0-preview3 445 12/4/2021
1.0.0-preview2 398 12/4/2021
1.0.0-preview1 397 12/4/2021