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 363 2/24/2017
3.1.0 195 11/14/2016
3.0.2 127 11/7/2016
3.0.0 (current) 126 11/4/2016
2.4.3 200 4/17/2016
2.4.2 145 4/15/2016
2.4.1 173 3/5/2016
2.4.0 358 6/3/2015
2.3.5 192 4/28/2015
2.3.2 276 8/20/2014
2.3.1 202 7/10/2014
2.3.0 192 7/9/2014
2.2.1 196 7/2/2014
2.2.0 195 7/2/2014
2.1.0 200 6/20/2014
2.0.0 213 5/23/2014
1.4.1 200 5/18/2014
1.4.0 215 5/18/2014
1.2.1 201 4/28/2014
1.1.1 212 4/12/2014
1.1.0 196 4/12/2014
1.0.0 195 4/11/2014