Skip to content

SemVer scheme in AngleSharp -alpha versions broken #1171

Closed
@georg-jung

Description

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

Description

The AngleSharp prerelease packges use a naming scheme like 1.1.0-alpha-379 or 1.0.0-alpha-117. The interesting part about this is that alpha and the following number are seperated by a hypen. The SemVer spec § 11.4 reads (emphasis mine)

Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows:

  1. Identifiers consisting of only digits are compared numerically.
  2. Identifiers with letters or hyphens are compared lexically in ASCII sort order.
  3. Numeric identifiers always have lower precedence than non-numeric identifiers.
  4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
    Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.

The effects of applying this rule are easiest to observe on the AngelSharp.Css NuGet page. I still decided to create the issue here (on the main AngleSharp repo), as the root cause is shared accross the AngleSharp projects.

image

NuGet.org shows the versions according to their precedence. Thus, the -99 version is higher than the -117 version. I think this is not the intended outcome. If the hypen was a dot instead, the ordering would be correct.

Steps to Reproduce

dotnet new console
dotnet add AngleSharp.Css --prerelease

Expected Behavior

A message like the following, signalling the newest version of an AngleSharp prerelease package was installed

info : Die PackageReference für das Paket "AngleSharp.Css", Version 1.0.0-alpha.117, wurde der Datei "D:\git\anglesharptest\anglesharptest.csproj" hinzugefügt.

Actual Behavior

A message like

info : Die PackageReference für das Paket "AngleSharp.Css", Version 1.0.0-alpha-99, wurde der Datei "D:\git\anglesharptest\anglesharptest.csproj" hinzugefügt.

This is additionally problematic because NuGet lets you upgrade packages more easily than downgrading them. E.g. HtmlSanitizer beta references AngleSharp.Css >= 1.0.0-alpha-99. There is no way to upgrade to the newest AngleSharp.Css version by taking a direct dependency on 1.0.0-alpha-117, because nuget disallows the "downgrade":

error NU1109: Detected package downgrade: AngleSharp.Css from 1.0.0-alpha-99 to centrally defined 1.0.0-alpha-117. Update the centrally managed package version to a higher version.  [/home/vsts/work/1/s/MyProj.sln]
error NU1109:  MyProj -> HtmlSanitizer 8.1.844-beta -> AngleSharp.Css (>= 1.0.0-alpha-99)  [/home/vsts/work/1/s/MyProj.sln]
error NU1109:  MyProj -> AngleSharp.Css (>= 1.0.0-alpha-117) [/home/vsts/work/1/s/MyProj.sln]

Possible Solution / Known Workarounds

For future prerelease versions, a naming scheme that takes a higher precedence then all existing prerelease packages could be chosen. An easy way would be to name them beta instead of alpha, followed by a dot and then a number. I understand that this might not be a viable way though, given the different meaning of alpha and beta. Another way might be to use -alphax.N (I didn't test this) or something alike, or -prerelease.alpha.N. I guess that also depends on personal taste.

Let me know if there's anything further I can contribute to resolve this issue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions