Skip to content

Commit 241512a

Browse files
authored
Address feedback (loic-sharma#343)
Addresses loic-sharma#341
1 parent 059662e commit 241512a

File tree

119 files changed

+763
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+763
-686
lines changed

src/BaGet.Aws/Configuration/S3StorageOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.ComponentModel.DataAnnotations;
2-
using BaGet.Core.Validation;
2+
using BaGet.Core;
33

44
namespace BaGet.Aws.Configuration
55
{

src/BaGet.Aws/S3StorageService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Amazon.S3;
66
using Amazon.S3.Model;
77
using BaGet.Aws.Configuration;
8-
using BaGet.Core.Storage;
8+
using BaGet.Core;
99
using Microsoft.Extensions.Options;
1010

1111
namespace BaGet.Aws

src/BaGet.Azure/BlobStorageService.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
using System.Net;
44
using System.Threading;
55
using System.Threading.Tasks;
6-
using BaGet.Core.Extensions;
7-
using BaGet.Core.Storage;
6+
using BaGet.Core;
87
using Microsoft.WindowsAzure.Storage;
98
using Microsoft.WindowsAzure.Storage.Blob;
109

src/BaGet.Azure/Configuration/AzureSearchOptions.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
2+
using BaGet.Core;
23

34
namespace BaGet.Azure.Configuration
45
{
5-
public class AzureSearchOptions : Core.Configuration.SearchOptions
6+
public class AzureSearchOptions : SearchOptions
67
{
78
[Required]
89
public string AccountName { get; set; }

src/BaGet.Azure/Search/AzureSearchService.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using BaGet.Core;
8-
using BaGet.Core.Entities;
9-
using BaGet.Core.Indexing;
10-
using BaGet.Core.Search;
118
using BaGet.Protocol.Models;
129
using Microsoft.Azure.Search;
1310
using NuGet.Versioning;
@@ -17,7 +14,7 @@ namespace BaGet.Azure.Search
1714
using QueryType = Microsoft.Azure.Search.Models.QueryType;
1815
using SearchParameters = Microsoft.Azure.Search.Models.SearchParameters;
1916

20-
public class AzureSearchService : IBaGetSearchResource
17+
public class AzureSearchService : ISearchService
2118
{
2219
private readonly BatchIndexer _indexer;
2320
private readonly SearchIndexClient _searchClient;

src/BaGet.Azure/Search/BatchIndexer.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6-
using BaGet.Core.Entities;
7-
using BaGet.Core.Metadata;
6+
using BaGet.Core;
87
using Microsoft.Azure.Search;
98
using Microsoft.Azure.Search.Models;
109
using Microsoft.Extensions.Logging;

src/BaGet.Core.Server/Controllers/PackageContentController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace BaGet.Controllers
1414
/// </summary>
1515
public class PackageContentController : Controller
1616
{
17-
private readonly IBaGetPackageContentService _content;
17+
private readonly IPackageContentService _content;
1818

19-
public PackageContentController(IBaGetPackageContentService content)
19+
public PackageContentController(IPackageContentService content)
2020
{
2121
_content = content ?? throw new ArgumentNullException(nameof(content));
2222
}

src/BaGet.Core.Server/Controllers/PackageMetadataController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.Metadata;
4+
using BaGet.Core;
55
using BaGet.Protocol.Models;
66
using Microsoft.AspNetCore.Mvc;
77
using NuGet.Versioning;
@@ -14,9 +14,9 @@ namespace BaGet.Controllers
1414
/// </summary>
1515
public class PackageMetadataController : Controller
1616
{
17-
private readonly IBaGetPackageMetadataService _metadata;
17+
private readonly IPackageMetadataService _metadata;
1818

19-
public PackageMetadataController(IBaGetPackageMetadataService metadata)
19+
public PackageMetadataController(IPackageMetadataService metadata)
2020
{
2121
_metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
2222
}

src/BaGet.Core.Server/Controllers/PackagePublishController.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.Authentication;
5-
using BaGet.Core.Configuration;
6-
using BaGet.Core.Indexing;
7-
using BaGet.Core.Metadata;
4+
using BaGet.Core;
85
using BaGet.Extensions;
96
using Microsoft.AspNetCore.Mvc;
107
using Microsoft.Extensions.Logging;

src/BaGet.Core.Server/Controllers/SearchController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.Search;
4+
using BaGet.Core;
55
using BaGet.Protocol.Models;
66
using Microsoft.AspNetCore.Mvc;
77

88
namespace BaGet.Controllers
99
{
1010
public class SearchController : Controller
1111
{
12-
private readonly IBaGetSearchResource _searchService;
12+
private readonly ISearchService _searchService;
1313

14-
public SearchController(IBaGetSearchResource searchService)
14+
public SearchController(ISearchService searchService)
1515
{
1616
_searchService = searchService ?? throw new ArgumentNullException(nameof(searchService));
1717
}

src/BaGet.Core.Server/Controllers/ServiceIndexController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.ServiceIndex;
4+
using BaGet.Core;
55
using BaGet.Protocol.Models;
66
using Microsoft.AspNetCore.Mvc;
77

@@ -12,9 +12,9 @@ namespace BaGet.Controllers
1212
/// </summary>
1313
public class ServiceIndexController : Controller
1414
{
15-
private readonly IBaGetServiceIndex _serviceIndex;
15+
private readonly IServiceIndexService _serviceIndex;
1616

17-
public ServiceIndexController(IBaGetServiceIndex serviceIndex)
17+
public ServiceIndexController(IServiceIndexService serviceIndex)
1818
{
1919
_serviceIndex = serviceIndex ?? throw new ArgumentNullException(nameof(serviceIndex));
2020
}

src/BaGet.Core.Server/Controllers/SymbolController.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.Authentication;
5-
using BaGet.Core.Configuration;
6-
using BaGet.Core.Indexing;
7-
using BaGet.Core.Storage;
4+
using BaGet.Core;
85
using BaGet.Extensions;
96
using Microsoft.AspNetCore.Mvc;
107
using Microsoft.Extensions.Logging;

src/BaGet.Core.Server/Extensions/HttpRequestExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using BaGet.Core.Extensions;
4+
using BaGet.Core;
55
using Microsoft.AspNetCore.Http;
66

77
namespace BaGet.Extensions

src/BaGet.Core/Authentication/ApiKeyAuthenticationService.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
22
using System.Threading.Tasks;
3-
using BaGet.Core.Configuration;
43
using Microsoft.Extensions.Options;
54

6-
namespace BaGet.Core.Authentication
5+
namespace BaGet.Core
76
{
87
public class ApiKeyAuthenticationService : IAuthenticationService
98
{

src/BaGet.Core/Authentication/IAuthenticationService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Threading.Tasks;
22

3-
namespace BaGet.Core.Authentication
3+
namespace BaGet.Core
44
{
55
public interface IAuthenticationService
66
{

src/BaGet.Core/Configuration/BaGetOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22

3-
namespace BaGet.Core.Configuration
3+
namespace BaGet.Core
44
{
55
public class BaGetOptions
66
{

src/BaGet.Core/Configuration/DatabaseOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22

3-
namespace BaGet.Core.Configuration
3+
namespace BaGet.Core
44
{
55
public class DatabaseOptions
66
{

src/BaGet.Core/Configuration/FileSystemStorageOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.IO;
44
using System.Linq;
55

6-
namespace BaGet.Core.Configuration
6+
namespace BaGet.Core
77
{
88
public class FileSystemStorageOptions : StorageOptions, IValidatableObject
99
{

src/BaGet.Core/Configuration/MirrorOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel.DataAnnotations;
44

5-
namespace BaGet.Core.Configuration
5+
namespace BaGet.Core
66
{
77
public class MirrorOptions : IValidatableObject
88
{

src/BaGet.Core/Configuration/PackageDeletionBehavior.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BaGet.Core.Configuration
1+
namespace BaGet.Core
22
{
33
/// <summary>
44
/// How BaGet should interpret package deletion requests.

src/BaGet.Core/Configuration/SearchOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BaGet.Core.Configuration
1+
namespace BaGet.Core
22
{
33
public class SearchOptions
44
{

src/BaGet.Core/Configuration/StorageOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BaGet.Core.Configuration
1+
namespace BaGet.Core
22
{
33
public class StorageOptions
44
{

src/BaGet.Core/Content/DatabasePackageContentService.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
using System.Linq;
44
using System.Threading;
55
using System.Threading.Tasks;
6-
using BaGet.Core.Metadata;
7-
using BaGet.Core.Mirror;
8-
using BaGet.Core.Storage;
9-
using BaGet.Protocol;
106
using BaGet.Protocol.Models;
117
using NuGet.Versioning;
128

@@ -17,20 +13,25 @@ namespace BaGet.Core.Content
1713
/// Tracks state in a database (<see cref="IPackageService"/>) and stores packages
1814
/// using <see cref="IPackageStorageService"/>.
1915
/// </summary>
20-
public class DatabasePackageContentService : IBaGetPackageContentService
16+
public class DatabasePackageContentService : IPackageContentService
2117
{
2218
private readonly IMirrorService _mirror;
2319
private readonly IPackageService _packages;
2420
private readonly IPackageStorageService _storage;
2521

26-
public DatabasePackageContentService(IMirrorService mirror, IPackageService packages, IPackageStorageService storage)
22+
public DatabasePackageContentService(
23+
IMirrorService mirror,
24+
IPackageService packages,
25+
IPackageStorageService storage)
2726
{
2827
_mirror = mirror ?? throw new ArgumentNullException(nameof(mirror));
2928
_packages = packages ?? throw new ArgumentNullException(nameof(packages));
3029
_storage = storage ?? throw new ArgumentNullException(nameof(storage));
3130
}
3231

33-
public async Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(string id, CancellationToken cancellationToken = default)
32+
public async Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(
33+
string id,
34+
CancellationToken cancellationToken = default)
3435
{
3536
// First, attempt to find all package versions using the upstream source.
3637
var versions = await _mirror.FindPackageVersionsOrNullAsync(id, cancellationToken);

src/BaGet.Core/Content/IBaGetPackageContentService.cs

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System.IO;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using BaGet.Protocol.Models;
5+
using NuGet.Versioning;
6+
7+
namespace BaGet.Core.Content
8+
{
9+
/// <summary>
10+
/// The Package Content resource, used to download NuGet packages and to fetch other metadata.
11+
///
12+
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource
13+
/// </summary>
14+
public interface IPackageContentService
15+
{
16+
/// <summary>
17+
/// Get a package's versions, or null if the package does not exist.
18+
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions
19+
/// </summary>
20+
/// <param name="packageId">The package ID.</param>
21+
/// <param name="cancellationToken">A token to cancel the task.</param>
22+
/// <returns>The package's versions, or null if the package does not exist.</returns>
23+
Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(
24+
string packageId,
25+
CancellationToken cancellationToken = default);
26+
27+
/// <summary>
28+
/// Download a package, or null if the package does not exist.
29+
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg
30+
/// </summary>
31+
/// <param name="packageId">The package ID.</param>
32+
/// <param name="packageVersion">The package's version.</param>
33+
/// <param name="cancellationToken">A token to cancel the task.</param>
34+
/// <returns>
35+
/// The package's content stream, or null if the package does not exist. The stream may not be seekable.
36+
/// </returns>
37+
Task<Stream> GetPackageContentStreamOrNullAsync(
38+
string packageId,
39+
NuGetVersion packageVersion,
40+
CancellationToken cancellationToken = default);
41+
42+
/// <summary>
43+
/// Download a package's manifest (nuspec), or null if the package does not exist.
44+
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec
45+
/// </summary>
46+
/// <param name="packageId">The package id.</param>
47+
/// <param name="packageVersion">The package's version.</param>
48+
/// <param name="cancellationToken">A token to cancel the task.</param>
49+
/// <returns>
50+
/// The package's manifest stream, or null if the package does not exist. The stream may not be seekable.
51+
/// </returns>
52+
Task<Stream> GetPackageManifestStreamOrNullAsync(
53+
string packageId,
54+
NuGetVersion packageVersion,
55+
CancellationToken cancellationToken = default);
56+
57+
/// <summary>
58+
/// Download a package's readme, or null if the package or readme does not exist.
59+
/// </summary>
60+
/// <param name="id">The package id.</param>
61+
/// <param name="version">The package's version.</param>
62+
/// <param name="cancellationToken">A token to cancel the task.</param>
63+
/// <returns>
64+
/// The package's readme stream, or null if the package or readme does not exist. The stream may not be seekable.
65+
/// </returns>
66+
Task<Stream> GetPackageReadmeStreamOrNullAsync(
67+
string id,
68+
NuGetVersion version,
69+
CancellationToken cancellationToken = default);
70+
}
71+
}

src/BaGet.Core/Entities/AbstractContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.Metadata.Builders;
44

5-
namespace BaGet.Core.Entities
5+
namespace BaGet.Core
66
{
77
public abstract class AbstractContext<TContext> : DbContext, IContext where TContext : DbContext
88
{

0 commit comments

Comments
 (0)