feat: introduce IdentifierList for prerelease and build-metadata segments
All checks were successful
default / dotnet-default-workflow (push) Successful in 58s

Add a value type wrapping the dot-separated prerelease and build-metadata
identifiers, replacing the previous nullable string properties on
SemanticVersion. Implements IReadOnlyList<string>, zero-alloc
ReadOnlySpan<char> enumeration, Ordinal equality with implicit string
conversions, a JSON converter, and ISpanParsable/IParsable parsing
validated via IdentifierListFormatInfo.

Closes #1
This commit is contained in:
Louis Seubert 2026-07-12 23:02:24 +02:00
commit 50e15afb4f
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
9 changed files with 855 additions and 125 deletions

View file

@ -17,13 +17,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `SemanticVersion` and `SemanticVersionRange` can now be used as `System.Text.Json`
dictionary keys. The custom converters override `ReadAsPropertyName`/`WriteAsPropertyName`
so `Dictionary<TKey, TValue>` round-trips correctly.
- New `IdentifierList` value type for prerelease/build-metadata identifiers.
### Changed
- **Breaking:** `SemanticVersion.Prerelease` and `SemanticVersion.Metadata` are now `IdentifierList`
instead of `string?`. Implicit `string` conversions keep most call sites compiling, but the property
type change is breaking and requires a recompile. Constructors additionally accept `IdentifierList`.
- `SemanticVersion` `==`/`Equals`/`GetHashCode` now ignore build metadata, matching precedence comparison rules.
- `SemanticVersionRange` equality (`==`, `Equals`, `GetHashCode`) is now structural and based
on the constraint sets, so ranges that parse to the same comparators compare as equal
(previously it was reference-sensitive on the backing array).
- `SemanticVersionComparer` now enumerates the `IdentifierList` segments directly instead of
re-splitting the joined identifier strings.
### Fixed