diff --git a/src/NuGet.Services.AzureSearch/AsDisposable.cs b/src/NuGet.Services.AzureSearch/AsDisposable.cs deleted file mode 100644 index f04373bf7..000000000 --- a/src/NuGet.Services.AzureSearch/AsDisposable.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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; - -namespace NuGet.Services.AzureSearch -{ - public static class AsDisposable - { - public static AsDisposable Create(T value) where T : class - { - return new AsDisposable(value); - } - } - - /// - /// This is invented because does not implement but - /// the primary implementation is disposable. - /// - public class AsDisposable : IDisposable where T : class - { - public AsDisposable(T value) - { - Value = value ?? throw new ArgumentNullException(nameof(value)); - } - - public T Value { get; } - - public void Dispose() - { - (Value as IDisposable)?.Dispose(); - } - } -} diff --git a/src/NuGet.Services.AzureSearch/DatabaseOwnerFetcher.cs b/src/NuGet.Services.AzureSearch/DatabaseOwnerFetcher.cs index 1bd6dab27..3e3cb8abd 100644 --- a/src/NuGet.Services.AzureSearch/DatabaseOwnerFetcher.cs +++ b/src/NuGet.Services.AzureSearch/DatabaseOwnerFetcher.cs @@ -41,11 +41,10 @@ public DatabaseOwnerFetcher( public async Task GetOwnersOrEmptyAsync(string id) { - using (var entitiesContext = AsDisposable.Create(await _entitiesContextFactory.CreateAsync(readOnly: true))) + using (var entitiesContext = await _entitiesContextFactory.CreateAsync(readOnly: true)) { _logger.LogInformation("Fetching owners for package registration with ID {PackageId}.", id); var owners = await entitiesContext - .Value .PackageRegistrations .Where(pr => pr.Id == id) .Select(pr => pr.Owners.Select(u => u.Username).ToList()) diff --git a/src/NuGet.Services.AzureSearch/Db2AzureSearch/NewPackageRegistrationProducer.cs b/src/NuGet.Services.AzureSearch/Db2AzureSearch/NewPackageRegistrationProducer.cs index ab6e28a8f..5da957ed2 100644 --- a/src/NuGet.Services.AzureSearch/Db2AzureSearch/NewPackageRegistrationProducer.cs +++ b/src/NuGet.Services.AzureSearch/Db2AzureSearch/NewPackageRegistrationProducer.cs @@ -105,7 +105,6 @@ private async Task> GetPackagesAsync(PackageRegistrationR { var minKey = range.MinKey; var query = context - .Value .Set() .Include(x => x.PackageRegistration) .Where(p => p.PackageStatusKey == PackageStatus.Available) @@ -148,7 +147,6 @@ private async Task> GetPackageRegistratio { var minKey = range.MinKey; var query = context - .Value .Set() .Include(x => x.Owners) .Where(pr => pr.Key >= minKey); @@ -183,7 +181,6 @@ private async Task> GetPackageRegistrati // Get the number of packages per package registration key, in ascending order. var stopwatch = Stopwatch.StartNew(); var packageCounts = await context - .Value .Set() .OrderBy(pr => pr.Key) .Select(pr => new @@ -241,9 +238,9 @@ private async Task> GetPackageRegistrati } } - private async Task> CreateContextAsync() + private async Task CreateContextAsync() { - return AsDisposable.Create(await _contextFactory.CreateAsync(readOnly: true)); + return await _contextFactory.CreateAsync(readOnly: true); } private class PackageRegistrationRange diff --git a/src/NuGet.Services.AzureSearch/NuGet.Services.AzureSearch.csproj b/src/NuGet.Services.AzureSearch/NuGet.Services.AzureSearch.csproj index c08b61f2d..b17d5ffaa 100644 --- a/src/NuGet.Services.AzureSearch/NuGet.Services.AzureSearch.csproj +++ b/src/NuGet.Services.AzureSearch/NuGet.Services.AzureSearch.csproj @@ -48,7 +48,6 @@ - diff --git a/tests/NuGet.Services.AzureSearch.Tests/Catalog2AzureSearch/Catalog2AzureSearchCommandFacts.cs b/tests/NuGet.Services.AzureSearch.Tests/Catalog2AzureSearch/Catalog2AzureSearchCommandFacts.cs index 9742241f0..4d158a8f2 100644 --- a/tests/NuGet.Services.AzureSearch.Tests/Catalog2AzureSearch/Catalog2AzureSearchCommandFacts.cs +++ b/tests/NuGet.Services.AzureSearch.Tests/Catalog2AzureSearch/Catalog2AzureSearchCommandFacts.cs @@ -70,7 +70,7 @@ public async Task UsesMaxForCursorWithNoDependencies() _collector.Verify( x => x.RunAsync( It.IsAny(), - It.Is(c => c.Value == DateTime.MaxValue), + It.Is(c => c.Value == DateTime.MaxValue.ToUniversalTime()), It.IsAny()), Times.Once); }