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

[Client SDK] Add package deprecation #471

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/BaGet.Protocol/Models/AlternatePackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace BaGet.Protocol.Models
{
/// <summary>
/// The alternate package that should be used instead of a deprecated package.
///
/// See https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#package-deprecation
/// </summary>
public class AlternatePackage
{
[JsonProperty("@id")]
public string Url { get; set; }

[JsonProperty("@type")]
public string Type { get; set; }

/// <summary>
/// The ID of the alternate package.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// The allowed version range, or * if any version is allowed.
/// </summary>
[JsonProperty("range")]
public string Range { get; set; }
}
}
38 changes: 38 additions & 0 deletions src/BaGet.Protocol/Models/PackageDeprecation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace BaGet.Protocol.Models
{
/// <summary>
/// A package's metadata.
///
/// See https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#package-deprecation
/// </summary>
public class PackageDeprecation
{
/// <summary>
/// The URL to the document used to produce this object.
/// </summary>
[JsonProperty("@id")]
public string CatalogLeafUrl { get; set; }

/// <summary>
/// The reasons why the package was deprecated.
/// Deprecation reasons include: "Legacy", "CriticalBugs", and "Other".
/// </summary>
[JsonProperty("reasons")]
public IReadOnlyList<string> Reasons { get; set; }

/// <summary>
/// The additional details about this deprecation.
/// </summary>
[JsonProperty("message")]
public string Message { get; set; }

/// <summary>
/// The alternate package that should be used instead.
/// </summary>
[JsonProperty("alternatePackage")]
public AlternatePackage AlternatePackage { get; set; }
}
}
18 changes: 12 additions & 6 deletions src/BaGet.Protocol/Models/PackageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ public class PackageMetadata
[JsonProperty("authors")]
public string Authors { get; set; }

/// <summary>
/// The dependencies of the package, grouped by target framework.
/// </summary>
[JsonProperty("dependencyGroups")]
public IReadOnlyList<DependencyGroupItem> DependencyGroups { get; set; }

/// <summary>
/// The deprecation associated with the package, if any.
/// </summary>
[JsonProperty("deprecation")]
public PackageDeprecation Deprecation { get; set; }

/// <summary>
/// The package's description.
/// </summary>
Expand Down Expand Up @@ -113,11 +125,5 @@ public class PackageMetadata
/// </summary>
[JsonProperty("title")]
public string Title { get; set; }

/// <summary>
/// The dependencies of the package, grouped by target framework.
/// </summary>
[JsonProperty("dependencyGroups")]
public IReadOnlyList<DependencyGroupItem> DependencyGroups { get; set; }
}
}
7 changes: 7 additions & 0 deletions tests/BaGet.Protocol.Tests/RawPackageMetadataClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public async Task GetRegistrationPage()
Assert.Equal("2.0.0+build", firstMetadata.Version);
}

[Fact]
public async Task GetRegistrationPageDeprecated()
{
// TODO
await Task.Yield();
}

[Fact]
public async Task GetsRegistrationLeaf()
{
Expand Down