Provides resource pooling of any type for performance-critical applications that allocate and deallocate objects frequently. Commonly Used Types: System.Buffers.ArrayPool<T>
$ dotnet add package NetFx.System.BuffersProvides resource pooling of any type for performance-critical applications that allocate and deallocate objects frequently.
Commonly Used Types:
This package adds support for System.Buffers types on .NET Framework 4.0.
As the source code is not available for the System.Buffers package that works on .NET Framework 4.5, types in this package have either been decompiled from System.Buffers 4.5.1 or have been sourced from newer versions of .NET. Most of the tests from the last release of .NET Core 3.1 (version 3.1.29) have been ported and are all passing.
This is not meant to be an upgrade to System.Buffers 4.5.1, it is simply to add support on the net40 target for all of the existing APIs in System.Buffers 4.5.1. It is recommended to use the official release of System.Buffers on newer versions of .NET.
Since the runtime for net40 hasn't been supported for many years, most likely you will be using a newer runtime with this library. But you may be interoperating with other components that target System.Runtime.CompilerServices.Unsafe, which will cause type collisions by default.
In this case, it is recommended to remove System.Buffers from compilation and add NetFx.System.Runtime.CompilerServices.Unsafe in its place. Add the following to your .csproj or .vbproj file. This example is for using net452.
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<!-- ExcludeAssets=compile removes the dependency from being referenced.
ExcludeAssets=runtime removes the dependency from the build output. -->
<PackageReference Include="System.Buffers"
Version="4.5.1"
ExcludeAssets="compile;runtime" />
<PackageReference Include="NetFx.System.Buffers"
Version="4.0.0" />
</ItemGroup>
Only SDK-style projects are supported using this method.
For transitive dependencies (that is, dependencies that are not directly referenced) that have a net40 target, consider forcing a specific target framework.
If you find this library to be useful, please star us on GitHub and consider a sponsorship so we can continue bringing you great free tools like this one. It really would make a big difference!