Open-NET-Libraries / Open.ChannelExtensions

A set of extensions for optimizing/simplifying System.Threading.Channels usage.
https://open-net-libraries.github.io/Open.ChannelExtensions/api/Open.ChannelExtensions.Extensions.html#methods
MIT License
401 stars 25 forks source link

Conditional package reference to System.Threading.Channels NuGet #32

Closed darcon77 closed 8 months ago

darcon77 commented 8 months ago

Since System.Threading.Channels is part of the framework since .Net Core 3, the NuGet reference can be made conditional to netstandard 2.0 and 2.1

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
    <PackageReference Include="System.Threading.Channels" Version="8.*" />
</ItemGroup>

This way .net 6 and .net 8 versions of Open.ChannelExtensions won't have any dependencies.

As per Microsoft: The System.Threading.Channels namespace provides a set of synchronization data structures for passing data between producers and consumers asynchronously. The library targets .NET Standard and works on all .NET implementations. This library is available in the System.Threading.Channels NuGet package. However, if you're using .NET Core 3.0 or later, the package is included as part of the framework.

And Steven Toub recommends using System.Threading.Channels that ships with framework, over the NuGet when possible, since the native version is optimized and performs better (paraphrasing). Direct quote below:

System.Threading.Channels is part of the .NET Core shared framework, meaning a .NET Core app can start using it without installing anything additional. It’s also available as a separate NuGet package, though the separate implementation doesn’t have all of the optimizations that built-in implementation has, in large part because the built-in implementation is able to take advantage of additional runtime and library support in .NET Core. Source: https://devblogs.microsoft.com/dotnet/an-introduction-to-system-threading-channels/

electricessence commented 8 months ago

Ok. I like your suggestion. I'll work on it. :)

electricessence commented 8 months ago

And done. https://www.nuget.org/packages/Open.ChannelExtensions/8.0.1

electricessence commented 8 months ago

@darcon77 ... Thanks for the nudge. Lemme know if there's anything else.

darcon77 commented 7 months ago

yes, there is... Thank you for your work on this library! I love it