NativeInterop 3.0.0

Provides generic pointer operations for all of .NET, building on the capabilities provided by FSharp.NativeInterop.NativePtr, which this package extends with features like 64-bit capabilities, exposed in an OOP-friendly manner as NativePtr<T> and extension methods to System.IntPtr.

NativeArray, an array-like collection of items of unmanaged (blittable) type allocated on the unmanaged heap, supports 64-bit addressing and item access with and without bounds checks, utilizing the CPU's AGUs for address offset calculation where possible.

The included System.IO.Stream extension methods as well as the Buffer and Structure modules enable easy and efficient handling of structured binary data (convert array types, convert structs, access structs in an element-wise fashion, memcpy...).

Install-Package NativeInterop -Version 3.0.0
dotnet add package NativeInterop --version 3.0.0
paket add NativeInterop --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

major release - includes breaking changes to the API surface

Global:
   - all modules, classes and functions have been moved to namespace NativeInteropEx to avoid name clashes with FSharp.NativeInterop
   - .NET Standard 1.1 compatibility
   - Improved XML doc comments for all types and functions

NativePtr:
   - NativePtr is now an F#-specific module containing inlined compile-time generic functions; use IntPtrEx instead if calling from other languages like C#
   - changed order of arguments of multiple functions
   - added functions ofNativeInt, toNativeInt and stackalloc
   - fixed ctor throws on length == 0

NativePtr<T>
   - ctor now accepts ilsigptr<T> (typed native CLR pointer)

IntPtrEx (new):
   - maps the functionality of NativePtr to IntPtr extension methods for use from non-F# languages

Structure:
   - added functions write, get and set
   - renamed function convert to read
   - removed obsolete APIs
   - eliminated use of inline IL; as a consequence, some arguments need to be passed by reference (which makes sense to avoid copies due to pass by value anyhow)

Buffer:
   - added function toStructureWithOffset (method ToStructure)    
   - memcpy (Copy): length argument is now of type nativeint (IntPtr)
   - removed obsolete APIs
   - removed duplicate APIs also found in Structure
   - renamed Convert to Copy (overloaded)

NativeArray<T>:
   - renamed from NativeArray64
   - type parameter further constrained to conform with System.Numerics.Vector<T> (in preparation for SIMD support)
   - enabled bounds check for all indexers in debug mode
   - more efficient indexer
   - added At indexed property which always performs bounds checking
   - added Get/Set methods for bounds-checked access from languages that don't support indexed properties
   - simplified IDisposable implementation
   - added specialized struct-based IEnumerator implementation, replaces Items property    

NativeArray:
   - ofArray uses Buffer.memcpy to initialize the new NativeArray
   - zeroCreate now takes an explicit type parameter
   - all higher order functions are now inline
   - generalized type signatures
   - added multiple functions (fold2, prod, sum, dot, ...)
   - added RequireQualifiedAccess attribute
   - implemented extension methods for use from C# etc.

ReinterpretCast<T, U>:
   - added indexer (forwards to NativePtr<U>.Item)
   - simplified IDisposable implementation

Stream:
   - Re-implemented readStructureArray to read structs one-by-one instead of creating a giant buffer

Version History

Version Downloads Last updated
3.2.0 247 2/24/2017
3.1.0 157 11/14/2016
3.0.2 89 11/7/2016
3.0.0 (current version) 89 11/4/2016
2.4.3 163 4/17/2016
2.4.2 106 4/15/2016
2.4.1 133 3/5/2016
2.4.0 319 6/3/2015
2.3.5 155 4/28/2015
2.3.2 236 8/20/2014
2.3.1 162 7/10/2014
2.3.0 154 7/9/2014
2.2.1 157 7/2/2014
2.2.0 156 7/2/2014
2.1.0 160 6/20/2014
2.0.0 170 5/23/2014
1.4.1 158 5/18/2014
1.4.0 175 5/18/2014
1.2.1 157 4/28/2014
1.1.1 169 4/12/2014
1.1.0 153 4/12/2014
1.0.0 154 4/11/2014