Skip to content

SemVerHelper.PreRelease.TryParse cannot parse valid nuget pre-release identifiers #522

Closed

Description

@HCanber

The current SemVerHelper.PreRelese parser isn't following the current SemVer spec.
For example this is a valid prerelease string Beta.7.z.92 that the PreRelease has problems with.

This is fine because nuget does not support those either. :)

The Nuget prerelease spec says

If there's a string there, it's a prerelease version.
The prerelease versions are given precedence in alphabetical order (well technically lexicographic ASCII sort order).

Since SemVerHelper:PreRelease.TryParse expects a string followed by an int the following strings cannot be parsed, but they should as nuget will accept them:

  • dev20140819130924 (the digits are the date + time in ISO8601) order as the number is to large for an int. This is something I really need!
  • dev-2014-08-19T130924

I suggest you remove the int-parsing and just use the regex [0-9A-Za-z-]+ as SemVer spec defines. The spec says that prerelease with only digits should be compared numerically, and identifiers with letters or hyphens should be compared in ascii order. However Nuget specifies ascii sort order so just treating it as a string will be fine.

Activity

  1. forki commented on Aug 19, 2014

    @forki
    Member

    Nice analysis. I'm currently on vacation. Are you interested in sending a pull request for this?

  2. HCanber commented on Aug 19, 2014

    @HCanber
    Author

    I'm guessing this is a trivial fix for someone that knows F#. Unfortunately I don't. :(

  3. weismat commented on Aug 26, 2014

    @weismat

    I have problems to map the members of PreRelease to the naming inside the spec.
    The spec does not mention "origin".
    Furthermore I think that the code is currently not handling multiple elements/dots inside the build metadata (as Build is mapped to the hardcoded 3rd instead of the last element).

  4. added a commit that references this issue on Nov 14, 2014
  5. dsyme commented on Oct 1, 2016

    @dsyme
    Collaborator

    Fixed in #1325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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