Add .NET Standard 2.0 build support #42
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Thank you for building this library. Unfortunately, currently it cannot be used with legacy runtimes like .NET Framework. But since this library does not use many "new" .NET-specific features, adding support for .NET Standard 2.0 (and thus supporting .NET Framework 4.6.2 and later) is quite easy.
The proposed changes include the following:
latest
language version so the default language version limiter does not kick inSystem.Numerics.BitOperations.LeadingZeroCount(ulong)
instead ofulong.LeadingZeroCount(ulong)
(same functionality, different names) since it's easier to polyfill + polyfilling it with relatively quick implementation that is only used for .NET Standard 2.0BitConverter.ToUint64
overload that specifies the target index, because only it is available in .NET Standard 2.0 (there is no performance degradation for the "main" case of .NET 8+9, I ran the benchmarks to verify it)IEnumerable<>.ToHashSet<>
polyfill for .NET Standard 2.0With these changes, most of the library remains unmodified, the added files are only built for the new TFM and the performance of the existing code is unchanged, but the library can be used by many more developers, who cannot right now target modern versions of .NET for compatibility reasons.
Thanks for taking a look.