Introduce api for prerelease and buildmetadata segments #1

Open
opened 2026-05-23 06:59:53 +00:00 by louis9902 · 0 comments
Owner

Curretly the PreRelase and BuildMeatData is exposed as nullable string which is fine for basic interaction. But when you need to extract information from these you have to manually split the string and extract the segments. Each of the Properties is essentially a list separated with a ..
To make it easier to interact with the segments we should introduce a Value type wrapper for these strings. The type should be an implicit string but have more functionality. This includes the following:

  • Iterate the parts because it implements IReadOnlyList<string>
    • Get the Count of the segments (satisfied by IReadOnlyList<string>)
    • Get a segment by index (satisfied by IReadOnlyList<string>)
  • Have a performance oriented way to iterate the segments. This should be by exposing a ReadOnlySpan based Enumerable and make the type itself Enumerable without implementing (IEnumerable<string>)
  • Be equatable to each other and other strings. The comparison should there always be Ordinal
  • Have a IsEmpty property to check if the type is empty as it's going to be a value type. The value type should then not be nullable in the SemanticVersion

The api should orient itself on the StringValues from Microsoft.Extensions.Primitives

Curretly the PreRelase and BuildMeatData is exposed as nullable string which is fine for basic interaction. But when you need to extract information from these you have to manually split the string and extract the segments. Each of the Properties is essentially a list separated with a `.`. To make it easier to interact with the segments we should introduce a Value type wrapper for these strings. The type should be an implicit string but have more functionality. This includes the following: - Iterate the parts because it implements `IReadOnlyList<string>` - Get the `Count` of the segments (satisfied by `IReadOnlyList<string>`) - Get a segment by index (satisfied by `IReadOnlyList<string>`) - Have a performance oriented way to iterate the segments. This should be by exposing a ReadOnlySpan<char> based Enumerable and make the type itself Enumerable without implementing (`IEnumerable<string>`) - Be equatable to each other and other strings. The comparison should there always be **Ordinal** - Have a `IsEmpty` property to check if the type is empty as it's going to be a value type. The value type should then not be nullable in the `SemanticVersion` The api should orient itself on the [`StringValues` from **Microsoft.Extensions.Primitives**](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.primitives.stringvalues)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geekeey/semver#1
No description provided.