adamreeve / semver.net

Semantic versioning for .NET
MIT License
117 stars 22 forks source link

Add build number comparison options #28

Closed lvermeulen closed 4 years ago

lvermeulen commented 7 years ago

Please note that prerelease takes precedence over build metadata, as per semver 2.0 precedence rules (section 11).

adamreeve commented 7 years ago

Thanks for this, I think it makes sense to allow comparing build numbers. The spec does say that build metadata can be a series of dot separated identifiers, in which case it might make sense to reuse PreReleaseVersion.Compare rather than only providing numeric or alphanumeric comparisons. In that case it would make sense to rename PreReleaseVersion to IdentifierSeries or something more generic. I guess if people want to compare build numbers it's likely they're just using a simple numeric build number, but I think it would be good to support a series of identifiers to be more flexible.

lvermeulen commented 7 years ago

I'm pretty sure that PreRelease needs to be handled differently from any build metadata that follows. The spec talks about major, minor, patch and pre-release first, so any build metadata should always figure later into the version comparison, i.e. after pre-release..

adamreeve commented 7 years ago

Yes I don't mean that they should be compared together somehow, I mean that the logic for comparing pre-releases could be reused to compare build metadata, because the spec says:

Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]

ie. the build metadata isn't necessarily just a number of an alphanumeric string but could be a series of numbers and/or strings.

adamreeve commented 4 years ago

Closing this due to lack of activity but if anybody wants to revisit this later I'd be happy to reopen it.