Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose OriginalVersion property on NuGetVersion #5068

Closed
xavierdecoster opened this issue Apr 19, 2017 · 3 comments
Closed

Expose OriginalVersion property on NuGetVersion #5068

xavierdecoster opened this issue Apr 19, 2017 · 3 comments
Assignees

Comments

@xavierdecoster
Copy link
Member

xavierdecoster commented Apr 19, 2017

There's no reliable way to get a hold of the original, unmodified version string used to construct a NuGetVersion instance.

NuGetVersion.ToString() returns normalized version string for SemVer2 versions, and original version string for non-SemVer2 versions.

NuGetVersion.ToFullString() returns normalized version string + metadata (e.g. when original version was "01.0.42.0", this will return "1.0.42", which is not the original version string).

Simply exposing the _originalString field through a readonly public property would allow the caller to get a hold of the original version string.

@emgarten
Copy link
Member

Is there a reason to allow non-normalized SemVer2 versions?

If it were not for legacy reasons ToString() would also return the normalized version. The design here was that going forward everything would be normalized, since SemVer2 is new, all of those should be normalized.

@xavierdecoster
Copy link
Member Author

The issue here is that V2 endpoints (OData) currently have the behavior of always returning the original version string as-is in the Version property. For SemVer2 packages, that would be a call to .ToFullString (to include the metadata). However, that very call would return a normalized version string instead of the original version string for non-SemVer2 packages.

To not break that behavior, an easy-to-access OriginalVersion property would come in really useful.

@xavierdecoster
Copy link
Member Author

Just discovered another inconsistency: I noticed that e.g. new NuGetVersion("1.0.0+metadata") returns "1.0.0" as the original version, which is incorrect. This never surfaced, as the Metadata property is correctly set, and the .ToString method never had to return SemVer2 original version strings so far :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants