Skip to content

Commit

Permalink
Remove GetDeprecationMetadataAsync from Search Service (#5503)
Browse files Browse the repository at this point in the history
  • Loading branch information
donnie-msft authored and Nigusu-Allehu committed Nov 21, 2023
1 parent 67271ef commit c72fbab
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,6 @@ public IEnumerable<PackageItemViewModel> GetCurrent()
return listItemViewModels.ToArray();
}

private async Task<PackageDeprecationMetadataContextInfo> GetDeprecationMetadataAsync(PackageIdentity identity)
{
Assumes.NotNull(identity);

return await _searchService.GetDeprecationMetadataAsync(identity, _packageSources, _includePrerelease, CancellationToken.None);
}

private async Task<IReadOnlyCollection<VersionInfoContextInfo>> GetVersionInfoAsync(PackageIdentity identity)
{
Assumes.NotNull(identity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ public ValueTask<IReadOnlyCollection<PackageSearchMetadataContextInfo>> GetAllPa
return _parent._service.GetAllPackagesAsync(projectContextInfos, packageSources, targetFrameworks, searchFilter, itemFilter, isSolution, cancellationToken);
}

public ValueTask<PackageDeprecationMetadataContextInfo> GetDeprecationMetadataAsync(PackageIdentity identity, IReadOnlyCollection<PackageSourceContextInfo> packageSources, bool includePrerelease, CancellationToken cancellationToken)
{
return _parent._service.GetDeprecationMetadataAsync(identity, packageSources, includePrerelease, cancellationToken);
}

public ValueTask<(PackageSearchMetadataContextInfo, PackageDeprecationMetadataContextInfo)> GetPackageMetadataAsync(PackageIdentity identity, IReadOnlyCollection<PackageSourceContextInfo> packageSources, bool includePrerelease, CancellationToken cancellationToken)
{
return _parent._service.GetPackageMetadataAsync(identity, packageSources, includePrerelease, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,34 +235,6 @@ public async ValueTask<IReadOnlyCollection<VersionInfoContextInfo>> GetPackageVe
return await cacheEntry.AllVersionsContextInfo;
}


public async ValueTask<PackageDeprecationMetadataContextInfo?> GetDeprecationMetadataAsync(
PackageIdentity identity,
IReadOnlyCollection<PackageSourceContextInfo> packageSources,
bool includePrerelease,
CancellationToken cancellationToken)
{
Assumes.NotNull(identity);
Assumes.NotNullOrEmpty(packageSources);

string cacheId = PackageSearchMetadataCacheItem.GetCacheId(identity.Id, includePrerelease, packageSources);
PackageSearchMetadataCacheItem? backgroundDataCache = PackageSearchMetadataMemoryCache.Get(cacheId) as PackageSearchMetadataCacheItem;
if (backgroundDataCache != null)
{
PackageSearchMetadataCacheItemEntry cacheItem = await backgroundDataCache.GetPackageSearchMetadataCacheVersionedItemAsync(identity, cancellationToken);
return await cacheItem.PackageDeprecationMetadataContextInfo;
}

IPackageMetadataProvider packageMetadataProvider = await GetPackageMetadataProviderAsync(packageSources, cancellationToken);
IPackageSearchMetadata packageMetadata = await packageMetadataProvider.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken);
PackageDeprecationMetadata deprecationMetadata = await packageMetadata.GetDeprecationMetadataAsync();
if (deprecationMetadata == null)
{
return null;
}
return PackageDeprecationMetadataContextInfo.Create(deprecationMetadata);
}

public async ValueTask<SearchResultContextInfo> RefreshSearchAsync(CancellationToken cancellationToken)
{
Assumes.NotNull(_searchObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ ValueTask<IReadOnlyCollection<VersionInfoContextInfo>> GetPackageVersionsAsync(
bool isTransitive,
CancellationToken cancellationToken);

ValueTask<PackageDeprecationMetadataContextInfo?> GetDeprecationMetadataAsync(
PackageIdentity identity,
IReadOnlyCollection<PackageSourceContextInfo> packageSources,
bool includePrerelease,
CancellationToken cancellationToken);

ValueTask<IReadOnlyCollection<PackageSearchMetadataContextInfo>> GetPackageMetadataListAsync(
string id,
IReadOnlyCollection<PackageSourceContextInfo> packageSources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ public V3DetailControlModelTestBase(GlobalServiceProvider sp, V3PackageSearchMet
It.IsAny<CancellationToken>()))
.Returns(new ValueTask<IReadOnlyCollection<PackageSearchMetadataContextInfo>>(packageSearchMetadata));

mockSearchService.Setup(x =>
x.GetDeprecationMetadataAsync(
It.IsAny<PackageIdentity>(),
It.IsAny<IReadOnlyCollection<PackageSourceContextInfo>>(),
It.IsAny<bool>(),
It.IsAny<CancellationToken>()))
.Returns(null);

mockSearchService.Setup(x => x.GetPackageMetadataAsync(
It.IsAny<PackageIdentity>(),
It.IsAny<IReadOnlyCollection<PackageSourceContextInfo>>(),
Expand Down Expand Up @@ -163,14 +155,6 @@ public V3PackageDetailControlModelTests(GlobalServiceProvider sp, V3PackageSearc
It.IsAny<CancellationToken>()))
.Returns(new ValueTask<IReadOnlyCollection<PackageSearchMetadataContextInfo>>(packageSearchMetadata));

mockSearchService.Setup(x =>
x.GetDeprecationMetadataAsync(
It.IsAny<PackageIdentity>(),
It.IsAny<IReadOnlyCollection<PackageSourceContextInfo>>(),
It.IsAny<bool>(),
It.IsAny<CancellationToken>()))
.Returns(null);

mockSearchService.Setup(x => x.GetPackageMetadataAsync(
It.IsAny<PackageIdentity>(),
It.IsAny<IReadOnlyCollection<PackageSourceContextInfo>>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,6 @@ public async Task GetPackageMetadataListAsync_WithValidArguments_ReturnsMatching
}
}

[Fact]
public async Task GetDeprecationMetadataAsync_WhenDeprecationMetadataExists_ReturnsDeprecationMetadata()
{
using (NuGetPackageSearchService searchService = SetupSearchService())
{
PackageDeprecationMetadataContextInfo deprecationMetadata = await searchService.GetDeprecationMetadataAsync(
new PackageIdentity("microsoft.extensions.logging.abstractions", new Versioning.NuGetVersion("5.0.0-rc.2.20475.5")),
new List<PackageSourceContextInfo> { PackageSourceContextInfo.Create(_sourceRepository.PackageSource) },
includePrerelease: true,
CancellationToken.None);

Assert.NotNull(deprecationMetadata);
Assert.Equal("This is deprecated.", deprecationMetadata.Message);
Assert.Equal("Legacy", deprecationMetadata.Reasons.First());
}
}

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

0 comments on commit c72fbab

Please sign in to comment.