Skip to content

NuGet API v3#549

Merged
JoC0de merged 15 commits intoGlitchEnzo:masterfrom
JoC0de:feature/nuget-api-v3
Aug 3, 2023
Merged

NuGet API v3#549
JoC0de merged 15 commits intoGlitchEnzo:masterfrom
JoC0de:feature/nuget-api-v3

Conversation

@JoC0de
Copy link
Collaborator

@JoC0de JoC0de commented Jul 30, 2023

This PR adds support for NuGet repositories that are using the API version 3. This involves some big changes. e.g.:

  • Added INugetPackage interface with 3 different implementations for v2, v3 or local NuGet package sources.
  • Version Numbers are now normalized according the Microsoft documentation

Copy link
Collaborator

@igor84 igor84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this big feature. Can't wait to try it out :)

@JoC0de
Copy link
Collaborator Author

JoC0de commented Aug 2, 2023

@popara96 @igor84
I changed the way NugetPackageVersion.cs normalizes versions because version number comparison didn't comply to the Microsoft documentation.
In the implementation before the version 4.39.6.0 was not treated equal to 4.39.6 when calling Equals or GetHashCode, only Compare had the correct behavior. To achieve this I changed NugetPackageVersion.NormalizedVersion to not contain the additional 0 at the end. So Equals can just use the NormalizedVersion.
As INugetPackage.Version returns the NormalizedVersion this has the side effect that e.g. the name of the output folder where the Package content is stored changes. Do you think this is a problem?
I am not sure if Microsoft already removes the .0 in the API response but at least in the UI they removed it e.g. https://www.nuget.org/packages/StyleCop.MSBuild/4.7.49#versions-body-tab has no .0.

@igor84
Copy link
Collaborator

igor84 commented Aug 2, 2023

I never encountered a version like that (that I am aware of) so I don't see any issue with this change.

public override INugetPackageSource PackageSource => packageSourceV2;

/// <inheritdoc />
public override List<NugetPackageVersion> Versions => null;
Copy link
Collaborator

@igor84 igor84 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this returns null but on line 40 we are passing NugetPackageV2 to FillFromNuspec method that has this line: package.Versions.Add(package.PackageVersion); which will cause NullReferenceException, right? Should we just change that line to package.Versions?.Add(package.PackageVersion);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. It will be fixed in #568

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

Successfully merging this pull request may close these issues.

3 participants

Comments