-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace JObjects in PackageMetadataResourceV3 with strong type for be…
…tter performance, lower memory consumption (#3462) * No need dictionary, same thing can be with HashSet which takes lower overhead and space. * Replacing slugish JsonObject with strong type. * Revert back unneccessary change. * Add descriptions for new methods added. * Add back MetadataReferenceCache cache just in case. * Replace get single package version method too. * Minor code readability change. * Improve MetadataReferenceCache implementation. * Address code comment by Donnie. * Address after Andy's code review. * Address more code review comments. * Git push minor comment text change. * Address code review by Nkolche * Fix space * Address more code review comments. * Address comment by Andy. * Address more comments by Nkolche. * Address new comment by Andy. * Address another comment by Andy for ValueTuple. * Forgot to delete file RegistrationIndexResult.cs which no longer need. Co-authored-by: Erick Yondon <eryondon@microsoft.com>
- Loading branch information
1 parent
84554f6
commit 7532d57
Showing
10 changed files
with
363 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/NuGet.Core/NuGet.Protocol/Extensions/VersionRangeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using NuGet.Versioning; | ||
|
||
namespace NuGet.Protocol.Extensions | ||
{ | ||
internal static class VersionRangeExtensions | ||
{ | ||
public static bool DoesRangeSatisfy(this VersionRange dependencyRange, NuGetVersion catalogItemLower, NuGetVersion catalogItemUpper) | ||
{ | ||
if (dependencyRange.HasLowerAndUpperBounds) // Mainly to cover the '!dependencyRange.IsMaxInclusive && !dependencyRange.IsMinInclusive' case | ||
{ | ||
var catalogItemVersionRange = new VersionRange(minVersion: catalogItemLower, includeMinVersion: true, | ||
maxVersion: catalogItemUpper, includeMaxVersion: true); | ||
|
||
return catalogItemVersionRange.Satisfies(dependencyRange.MinVersion) || catalogItemVersionRange.Satisfies(dependencyRange.MaxVersion); | ||
} | ||
else | ||
{ | ||
return dependencyRange.Satisfies(catalogItemLower) || dependencyRange.Satisfies(catalogItemUpper); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace NuGet.Protocol.Model | ||
{ | ||
/// <summary> | ||
/// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-index | ||
/// </summary> | ||
internal class RegistrationIndex | ||
{ | ||
[JsonProperty("items")] | ||
public List<RegistrationPage> Items { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/NuGet.Core/NuGet.Protocol/Model/RegistrationLeafItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace NuGet.Protocol.Model | ||
{ | ||
/// <summary> | ||
/// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-leaf-object-in-a-page | ||
/// </summary> | ||
internal class RegistrationLeafItem | ||
{ | ||
[JsonProperty("catalogEntry")] | ||
public PackageSearchMetadataRegistration CatalogEntry { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
namespace NuGet.Protocol.Model | ||
{ | ||
/// <summary> | ||
/// This model is used for both the registration page item (found in a registration index) and for a registration | ||
/// page fetched on its own. | ||
/// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-page | ||
/// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-page-object | ||
/// </summary> | ||
internal class RegistrationPage | ||
{ | ||
[JsonProperty("@id")] | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// This property can be null when this model is used as an item in <see cref="RegistrationIndex.Items"/> when | ||
/// the server decided not to inline the leaf items. In this case, the <see cref="Url"/> property can be used | ||
/// fetch another <see cref="RegistrationPage"/> instance with the <see cref="Items"/> property filled in. | ||
/// </summary> | ||
[JsonProperty("items")] | ||
public List<RegistrationLeafItem> Items { get; set; } | ||
|
||
[JsonProperty("lower")] | ||
public string Lower { get; set; } | ||
|
||
[JsonProperty("upper")] | ||
public string Upper { get; set; } | ||
} | ||
} |
Oops, something went wrong.