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

   - 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 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

   - 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

   - 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)

   - 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)

   - 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    

   - 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

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

Version History

Version Downloads Last updated
3.2.0 221 2/24/2017
3.1.0 147 11/14/2016
3.0.2 79 11/7/2016
3.0.0 (current version) 79 11/4/2016
2.4.3 152 4/17/2016
2.4.2 95 4/15/2016
2.4.1 121 3/5/2016
2.4.0 303 6/3/2015
2.3.5 143 4/28/2015
2.3.2 224 8/20/2014
2.3.1 151 7/10/2014
2.3.0 142 7/9/2014
2.2.1 145 7/2/2014
2.2.0 145 7/2/2014
2.1.0 148 6/20/2014
2.0.0 156 5/23/2014
1.4.1 144 5/18/2014
1.4.0 161 5/18/2014
1.2.1 146 4/28/2014
1.1.1 158 4/12/2014
1.1.0 142 4/12/2014
1.0.0 143 4/11/2014