WalkerCodeRanger / semver

A semantic version library for .NET fully compliant with v2.0.0 of the spec found at http://semver.org/.
MIT License
296 stars 47 forks source link

In .NET 9, remove dependency on `Microsoft.Extensions.Primitives` by using `Span<char>` instead of `StringSegment` #84

Open WalkerCodeRanger opened 2 months ago

WalkerCodeRanger commented 2 months ago

The version parsing uses Microsoft.Extensions.Primitives.StringSegment to efficiently pass subsegments of strings without constructing new string instances. That library supports all the versions that the semver library does and provides all the needed functionality. As of .NET 9, Microsoft is adding additional methods to do things like split a Span<char> at separator characters. With that, there should be enough support in the BCL to implement semver in terms of Span<char> instead. That would eliminate the dependency on Microsoft.Extensions.Primitives, thereby reducing installed size in apps using the library and avoiding any conflicting dependency version issues.

I will investigate doing this for the next patch version. However, if it causes too much mess in the code to support a variation for newer versions, I may not do this.

rngcntr commented 2 days ago

After updating to Semver 3.0.0, I noticed that this exact dependency, Microsoft.Extensions.Primitives, can not be resolved.

Could not load /builds/***private***/***private***/***private***/***private***/tools/Addins/Semver.3.0.0/lib/net5.0/Semver.dll (missing Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

Error: Could not load file or assembly 'Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Is this related to this issue or is it just due to NET5, which is targeted by Semver 3.0.0, being end-of-life since May 2022 and the library not being available anymore?

WalkerCodeRanger commented 1 day ago

@rngcntr I'm not sure what is causing that error. It should be working. Please file a separate bug for that with more detail about versions being used and steps to reproduce.

rngcntr commented 1 day ago

For reference: https://github.com/WalkerCodeRanger/semver/issues/90