diff --git a/Directory.Build.props b/Directory.Build.props
index 1f563b299..36a7b07fc 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,6 +16,6 @@
https://github.com/NuKeeperDotNet/NuKeeper.git
-
+
-
+
\ No newline at end of file
diff --git a/NuKeeper.Abstractions.Tests/Configuration/FileSettingsReaderTests.cs b/NuKeeper.Abstractions.Tests/Configuration/FileSettingsReaderTests.cs
index f5103169a..01a5aaa1d 100644
--- a/NuKeeper.Abstractions.Tests/Configuration/FileSettingsReaderTests.cs
+++ b/NuKeeper.Abstractions.Tests/Configuration/FileSettingsReaderTests.cs
@@ -13,7 +13,7 @@ namespace NuKeeper.Abstractions.Tests.Configuration
[TestFixture]
public class FileSettingsReaderTests
{
- private string _uniqueTemporaryFolder = null;
+ private string _uniqueTemporaryFolder;
[SetUp]
public void Setup()
diff --git a/NuKeeper.Abstractions.Tests/NuKeeper.Abstractions.Tests.csproj b/NuKeeper.Abstractions.Tests/NuKeeper.Abstractions.Tests.csproj
index 380599bca..6c263e3ab 100644
--- a/NuKeeper.Abstractions.Tests/NuKeeper.Abstractions.Tests.csproj
+++ b/NuKeeper.Abstractions.Tests/NuKeeper.Abstractions.Tests.csproj
@@ -14,10 +14,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Abstractions/Configuration/FileSettingsCache.cs b/NuKeeper.Abstractions/Configuration/FileSettingsCache.cs
index 7f6f2ee34..c22d57cb6 100644
--- a/NuKeeper.Abstractions/Configuration/FileSettingsCache.cs
+++ b/NuKeeper.Abstractions/Configuration/FileSettingsCache.cs
@@ -4,10 +4,10 @@ namespace NuKeeper.Abstractions.Configuration
{
public class FileSettingsCache : IFileSettingsCache
{
- private readonly FileSettingsReader _reader;
+ private readonly IFileSettingsReader _reader;
private FileSettings _settings;
- public FileSettingsCache(FileSettingsReader reader)
+ public FileSettingsCache(IFileSettingsReader reader)
{
_reader = reader;
}
diff --git a/NuKeeper.Abstractions/Configuration/FileSettingsReader.cs b/NuKeeper.Abstractions/Configuration/FileSettingsReader.cs
index cb0595e45..f4f70efa1 100644
--- a/NuKeeper.Abstractions/Configuration/FileSettingsReader.cs
+++ b/NuKeeper.Abstractions/Configuration/FileSettingsReader.cs
@@ -4,7 +4,7 @@
namespace NuKeeper.Abstractions.Configuration
{
- public class FileSettingsReader
+ public class FileSettingsReader : IFileSettingsReader
{
private readonly INuKeeperLogger _logger;
diff --git a/NuKeeper.Abstractions/Configuration/IFileSettingsReader.cs b/NuKeeper.Abstractions/Configuration/IFileSettingsReader.cs
new file mode 100644
index 000000000..552b4f703
--- /dev/null
+++ b/NuKeeper.Abstractions/Configuration/IFileSettingsReader.cs
@@ -0,0 +1,7 @@
+namespace NuKeeper.Abstractions.Configuration
+{
+ public interface IFileSettingsReader
+ {
+ FileSettings Read(string folder);
+ }
+}
diff --git a/NuKeeper.Abstractions/NuKeeper.Abstractions.csproj b/NuKeeper.Abstractions/NuKeeper.Abstractions.csproj
index 9aa04b520..4897a7636 100644
--- a/NuKeeper.Abstractions/NuKeeper.Abstractions.csproj
+++ b/NuKeeper.Abstractions/NuKeeper.Abstractions.csproj
@@ -10,7 +10,8 @@
-
+
+
diff --git a/NuKeeper.AzureDevOps/AzureDevOpsRestClient.cs b/NuKeeper.AzureDevOps/AzureDevOpsRestClient.cs
index c033f063d..afae707d1 100644
--- a/NuKeeper.AzureDevOps/AzureDevOpsRestClient.cs
+++ b/NuKeeper.AzureDevOps/AzureDevOpsRestClient.cs
@@ -19,10 +19,13 @@ public class AzureDevOpsRestClient
private readonly HttpClient _client;
private readonly INuKeeperLogger _logger;
- public AzureDevOpsRestClient(HttpClient client, INuKeeperLogger logger, string personalAccessToken)
+ public AzureDevOpsRestClient(IHttpClientFactory clientFactory, INuKeeperLogger logger,
+ string personalAccessToken, Uri apiBaseAddress)
{
- _client = client ?? throw new ArgumentNullException(nameof(client));
_logger = logger;
+
+ _client = clientFactory.CreateClient();
+ _client.BaseAddress = apiBaseAddress;
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
_client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{string.Empty}:{personalAccessToken}")));
diff --git a/NuKeeper.AzureDevOps/AzureDevopsPlatform.cs b/NuKeeper.AzureDevOps/AzureDevopsPlatform.cs
index 3398fd743..9c0d2e75a 100644
--- a/NuKeeper.AzureDevOps/AzureDevopsPlatform.cs
+++ b/NuKeeper.AzureDevOps/AzureDevopsPlatform.cs
@@ -13,11 +13,13 @@ namespace NuKeeper.AzureDevOps
public class AzureDevOpsPlatform : ICollaborationPlatform
{
private readonly INuKeeperLogger _logger;
+ private readonly IHttpClientFactory _clientFactory;
private AzureDevOpsRestClient _client;
- public AzureDevOpsPlatform(INuKeeperLogger logger)
+ public AzureDevOpsPlatform(INuKeeperLogger logger, IHttpClientFactory clientFactory)
{
_logger = logger;
+ _clientFactory = clientFactory;
}
public void Initialise(AuthSettings settings)
@@ -27,11 +29,7 @@ public void Initialise(AuthSettings settings)
throw new ArgumentNullException(nameof(settings));
}
- var httpClient = new HttpClient
- {
- BaseAddress = settings.ApiBase
- };
- _client = new AzureDevOpsRestClient(httpClient, _logger, settings.Token);
+ _client = new AzureDevOpsRestClient(_clientFactory, _logger, settings.Token, settings.ApiBase);
}
public Task GetCurrentUser()
diff --git a/NuKeeper.BitBucket/BitbucketPlatform.cs b/NuKeeper.BitBucket/BitbucketPlatform.cs
index bc28ff21b..40a98834a 100644
--- a/NuKeeper.BitBucket/BitbucketPlatform.cs
+++ b/NuKeeper.BitBucket/BitbucketPlatform.cs
@@ -16,22 +16,20 @@ namespace NuKeeper.BitBucket
public class BitbucketPlatform : ICollaborationPlatform
{
private readonly INuKeeperLogger _logger;
+ private readonly IHttpClientFactory _clientFactory;
private BitbucketRestClient _client;
private AuthSettings _settings;
- public BitbucketPlatform(INuKeeperLogger logger)
+ public BitbucketPlatform(INuKeeperLogger logger, IHttpClientFactory clientFactory)
{
_logger = logger;
+ _clientFactory = clientFactory;
}
public void Initialise(AuthSettings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
- var httpClient = new HttpClient
- {
- BaseAddress = settings.ApiBase
- };
- _client = new BitbucketRestClient(httpClient, _logger, settings.Username, settings.Token);
+ _client = new BitbucketRestClient(_clientFactory, _logger, settings.Username, settings.Token, settings.ApiBase);
}
public Task GetCurrentUser()
diff --git a/NuKeeper.BitBucket/BitbucketRestClient.cs b/NuKeeper.BitBucket/BitbucketRestClient.cs
index 668f273c4..00253fb79 100644
--- a/NuKeeper.BitBucket/BitbucketRestClient.cs
+++ b/NuKeeper.BitBucket/BitbucketRestClient.cs
@@ -21,11 +21,13 @@ public class BitbucketRestClient
private readonly HttpClient _client;
private readonly INuKeeperLogger _logger;
- public BitbucketRestClient(HttpClient client, INuKeeperLogger logger, string username, string appPassword)
+ public BitbucketRestClient(IHttpClientFactory clientFactory, INuKeeperLogger logger, string username,
+ string appPassword, Uri apiBaseAddress)
{
- _client = client ?? throw new ArgumentNullException(nameof(client));
_logger = logger;
+ _client = clientFactory.CreateClient();
+ _client.BaseAddress = apiBaseAddress;
var byteArray = Encoding.ASCII.GetBytes($"{username}:{appPassword}");
_client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
diff --git a/NuKeeper.Git.Tests/GitCmdDiscoveryDriverTest.cs b/NuKeeper.Git.Tests/GitCmdDiscoveryDriverTest.cs
index aa6db6992..fe3627c6b 100644
--- a/NuKeeper.Git.Tests/GitCmdDiscoveryDriverTest.cs
+++ b/NuKeeper.Git.Tests/GitCmdDiscoveryDriverTest.cs
@@ -1,5 +1,4 @@
using NuKeeper.Abstractions.Logging;
-using NuKeeper.Git;
using NuKeeper.Inspection.Files;
using NuKeeper.Inspection.Logging;
using NUnit.Framework;
diff --git a/NuKeeper.Git.Tests/GitCmdDriverTest.cs b/NuKeeper.Git.Tests/GitCmdDriverTest.cs
index e772b9528..6c379d94e 100644
--- a/NuKeeper.Git.Tests/GitCmdDriverTest.cs
+++ b/NuKeeper.Git.Tests/GitCmdDriverTest.cs
@@ -3,11 +3,9 @@
using NuKeeper.Inspection.Logging;
using NUnit.Framework;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
diff --git a/NuKeeper.Git.Tests/NuKeeper.Git.Tests.csproj b/NuKeeper.Git.Tests/NuKeeper.Git.Tests.csproj
index 6ef51bb59..fb7f4714b 100644
--- a/NuKeeper.Git.Tests/NuKeeper.Git.Tests.csproj
+++ b/NuKeeper.Git.Tests/NuKeeper.Git.Tests.csproj
@@ -15,10 +15,10 @@
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Git/GitCmdDiscoveryDriver.cs b/NuKeeper.Git/GitCmdDiscoveryDriver.cs
index 5bbeaa59c..2d247dcf0 100644
--- a/NuKeeper.Git/GitCmdDiscoveryDriver.cs
+++ b/NuKeeper.Git/GitCmdDiscoveryDriver.cs
@@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
diff --git a/NuKeeper.Git/GitCmdDriver.cs b/NuKeeper.Git/GitCmdDriver.cs
index 2b6a0fcd7..fc262ff70 100644
--- a/NuKeeper.Git/GitCmdDriver.cs
+++ b/NuKeeper.Git/GitCmdDriver.cs
@@ -3,7 +3,6 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using NuKeeper.Abstractions.CollaborationModels;
using NuKeeper.Abstractions.Git;
using NuKeeper.Abstractions.Inspections.Files;
using NuKeeper.Abstractions.Logging;
diff --git a/NuKeeper.Git/LibGit2SharpDiscoveryDriver.cs b/NuKeeper.Git/LibGit2SharpDiscoveryDriver.cs
index eef04aa15..2f9844e40 100644
--- a/NuKeeper.Git/LibGit2SharpDiscoveryDriver.cs
+++ b/NuKeeper.Git/LibGit2SharpDiscoveryDriver.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using LibGit2Sharp;
diff --git a/NuKeeper.Git/LibGit2SharpDriver.cs b/NuKeeper.Git/LibGit2SharpDriver.cs
index 9cde62010..2b0e07b9c 100644
--- a/NuKeeper.Git/LibGit2SharpDriver.cs
+++ b/NuKeeper.Git/LibGit2SharpDriver.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using LibGit2Sharp;
diff --git a/NuKeeper.Git/NuKeeper.Git.csproj b/NuKeeper.Git/NuKeeper.Git.csproj
index 013b2fa97..03e1a2eec 100644
--- a/NuKeeper.Git/NuKeeper.Git.csproj
+++ b/NuKeeper.Git/NuKeeper.Git.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/NuKeeper.GitHub.Tests/NuKeeper.GitHub.Tests.csproj b/NuKeeper.GitHub.Tests/NuKeeper.GitHub.Tests.csproj
index 7a7de7be1..194eb3d6a 100644
--- a/NuKeeper.GitHub.Tests/NuKeeper.GitHub.Tests.csproj
+++ b/NuKeeper.GitHub.Tests/NuKeeper.GitHub.Tests.csproj
@@ -13,10 +13,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Gitea.Tests/GiteaSettingsReaderTests.cs b/NuKeeper.Gitea.Tests/GiteaSettingsReaderTests.cs
index 92b1db61d..f80262223 100644
--- a/NuKeeper.Gitea.Tests/GiteaSettingsReaderTests.cs
+++ b/NuKeeper.Gitea.Tests/GiteaSettingsReaderTests.cs
@@ -1,10 +1,10 @@
using System;
+using System.Net.Http;
using System.Threading.Tasks;
using NSubstitute;
using NuKeeper.Abstractions.CollaborationPlatform;
using NuKeeper.Abstractions.Configuration;
using NuKeeper.Abstractions.Git;
-using NuKeeper.Gitea;
using NUnit.Framework;
namespace NuKeeper.Gitea.Tests
@@ -21,7 +21,9 @@ public void Setup()
{
_environmentVariablesProvider = Substitute.For();
_gitDiscovery = Substitute.For();
- _giteaSettingsReader = new GiteaSettingsReader(_gitDiscovery, _environmentVariablesProvider);
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(new HttpClient());
+ _giteaSettingsReader = new GiteaSettingsReader(_gitDiscovery, _environmentVariablesProvider, httpClientFactory);
}
[Test]
diff --git a/NuKeeper.Gitea.Tests/NuKeeper.Gitea.Tests.csproj b/NuKeeper.Gitea.Tests/NuKeeper.Gitea.Tests.csproj
index 8f33043bb..8157f95c2 100644
--- a/NuKeeper.Gitea.Tests/NuKeeper.Gitea.Tests.csproj
+++ b/NuKeeper.Gitea.Tests/NuKeeper.Gitea.Tests.csproj
@@ -13,10 +13,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Gitea/GiteaPlatform.cs b/NuKeeper.Gitea/GiteaPlatform.cs
index 09a8c5e9c..7ef4946ea 100644
--- a/NuKeeper.Gitea/GiteaPlatform.cs
+++ b/NuKeeper.Gitea/GiteaPlatform.cs
@@ -14,11 +14,13 @@ namespace NuKeeper.Gitea
public class GiteaPlatform : ICollaborationPlatform
{
private readonly INuKeeperLogger _logger;
+ private readonly IHttpClientFactory _clientFactory;
private GiteaRestClient _client;
- public GiteaPlatform(INuKeeperLogger logger)
+ public GiteaPlatform(INuKeeperLogger logger, IHttpClientFactory clientFactory)
{
_logger = logger;
+ _clientFactory = clientFactory;
}
public void Initialise(AuthSettings settings)
@@ -28,12 +30,7 @@ public void Initialise(AuthSettings settings)
throw new ArgumentNullException(nameof(settings));
}
- var httpClient = new HttpClient
- {
- BaseAddress = settings.ApiBase
- };
-
- _client = new GiteaRestClient(httpClient, settings.Token, _logger);
+ _client = new GiteaRestClient(_clientFactory, settings.Token, _logger, settings.ApiBase);
}
public async Task GetCurrentUser()
diff --git a/NuKeeper.Gitea/GiteaRestClient.cs b/NuKeeper.Gitea/GiteaRestClient.cs
index 83c253d94..4057bdf77 100644
--- a/NuKeeper.Gitea/GiteaRestClient.cs
+++ b/NuKeeper.Gitea/GiteaRestClient.cs
@@ -20,11 +20,13 @@ public class GiteaRestClient
private readonly HttpClient _client;
private readonly INuKeeperLogger _logger;
- public GiteaRestClient(HttpClient client, string token, INuKeeperLogger logger)
+ public GiteaRestClient(IHttpClientFactory clientFactory, string token, INuKeeperLogger logger,
+ Uri apiBaseAddress)
{
- _client = client ?? throw new ArgumentNullException(nameof(client));
_logger = logger;
+ _client = clientFactory.CreateClient();
+ _client.BaseAddress = apiBaseAddress;
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("token", token);
}
diff --git a/NuKeeper.Gitea/GiteaSettingsReader.cs b/NuKeeper.Gitea/GiteaSettingsReader.cs
index 16155ef0b..5bdaf2462 100644
--- a/NuKeeper.Gitea/GiteaSettingsReader.cs
+++ b/NuKeeper.Gitea/GiteaSettingsReader.cs
@@ -17,10 +17,13 @@ public class GiteaSettingsReader : ISettingsReader
private const string UrlPattern = "https://yourgiteaserver/{owner}/{repo}.git";
private const string ApiBaseAdress = "api/v1/";
private readonly IGitDiscoveryDriver _gitDriver;
+ private readonly IHttpClientFactory _clientFactory;
- public GiteaSettingsReader(IGitDiscoveryDriver gitDiscoveryDriver, IEnvironmentVariablesProvider environmentVariablesProvider)
+ public GiteaSettingsReader(IGitDiscoveryDriver gitDiscoveryDriver, IEnvironmentVariablesProvider environmentVariablesProvider,
+ IHttpClientFactory clientFactory)
{
_environmentVariablesProvider = environmentVariablesProvider;
+ _clientFactory = clientFactory;
_gitDriver = gitDiscoveryDriver;
}
@@ -34,11 +37,8 @@ public async Task CanRead(Uri repositoryUri)
try
{
// There is no real identifier for gitea repos so try to get the gitea swagger json
- var client = new HttpClient()
- {
- BaseAddress = GetBaseAddress(repositoryUri)
- };
-
+ var client = _clientFactory.CreateClient();
+ client.BaseAddress = GetBaseAddress(repositoryUri);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
diff --git a/NuKeeper.Gitea/Model/PullRequest.cs b/NuKeeper.Gitea/Model/PullRequest.cs
index 99937a757..b3064123f 100644
--- a/NuKeeper.Gitea/Model/PullRequest.cs
+++ b/NuKeeper.Gitea/Model/PullRequest.cs
@@ -1,6 +1,5 @@
using Newtonsoft.Json;
using System;
-using System.Collections;
using System.Collections.Generic;
namespace NuKeeper.Gitea.Model
diff --git a/NuKeeper.Gitlab.Tests/NuKeeper.Gitlab.Tests.csproj b/NuKeeper.Gitlab.Tests/NuKeeper.Gitlab.Tests.csproj
index e9ce87a5f..33dd0e1e4 100644
--- a/NuKeeper.Gitlab.Tests/NuKeeper.Gitlab.Tests.csproj
+++ b/NuKeeper.Gitlab.Tests/NuKeeper.Gitlab.Tests.csproj
@@ -15,10 +15,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Gitlab/GitlabPlatform.cs b/NuKeeper.Gitlab/GitlabPlatform.cs
index ef3c31e57..bc6e20399 100644
--- a/NuKeeper.Gitlab/GitlabPlatform.cs
+++ b/NuKeeper.Gitlab/GitlabPlatform.cs
@@ -16,11 +16,13 @@ namespace NuKeeper.Gitlab
public class GitlabPlatform : ICollaborationPlatform
{
private readonly INuKeeperLogger _logger;
+ private readonly IHttpClientFactory _clientFactory;
private GitlabRestClient _client;
- public GitlabPlatform(INuKeeperLogger logger)
+ public GitlabPlatform(INuKeeperLogger logger, IHttpClientFactory clientFactory)
{
_logger = logger;
+ _clientFactory = clientFactory;
}
public void Initialise(AuthSettings settings)
@@ -30,11 +32,7 @@ public void Initialise(AuthSettings settings)
throw new ArgumentNullException(nameof(settings));
}
- var httpClient = new HttpClient
- {
- BaseAddress = settings.ApiBase
- };
- _client = new GitlabRestClient(httpClient, settings.Token, _logger);
+ _client = new GitlabRestClient(_clientFactory, settings.Token, _logger, settings.ApiBase);
}
public async Task GetCurrentUser()
diff --git a/NuKeeper.Gitlab/GitlabRepositoryDiscovery.cs b/NuKeeper.Gitlab/GitlabRepositoryDiscovery.cs
index d44fc8df8..a399ab836 100644
--- a/NuKeeper.Gitlab/GitlabRepositoryDiscovery.cs
+++ b/NuKeeper.Gitlab/GitlabRepositoryDiscovery.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using NuKeeper.Abstractions.CollaborationPlatform;
using NuKeeper.Abstractions.Configuration;
diff --git a/NuKeeper.Gitlab/GitlabRestClient.cs b/NuKeeper.Gitlab/GitlabRestClient.cs
index 080f5939d..15bb855ad 100644
--- a/NuKeeper.Gitlab/GitlabRestClient.cs
+++ b/NuKeeper.Gitlab/GitlabRestClient.cs
@@ -18,11 +18,12 @@ public class GitlabRestClient
private readonly HttpClient _client;
private readonly INuKeeperLogger _logger;
- public GitlabRestClient(HttpClient client, string token, INuKeeperLogger logger)
+ public GitlabRestClient(IHttpClientFactory clientFactory, string token, INuKeeperLogger logger, Uri apiBaseAddress)
{
- _client = client ?? throw new ArgumentNullException(nameof(client));
_logger = logger;
+ _client = clientFactory.CreateClient();
+ _client.BaseAddress = apiBaseAddress;
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
_client.DefaultRequestHeaders.Add("Private-Token", token);
}
diff --git a/NuKeeper.Inspection.Tests/NuKeeper.Inspection.Tests.csproj b/NuKeeper.Inspection.Tests/NuKeeper.Inspection.Tests.csproj
index 675d6f56f..f43a6e50a 100644
--- a/NuKeeper.Inspection.Tests/NuKeeper.Inspection.Tests.csproj
+++ b/NuKeeper.Inspection.Tests/NuKeeper.Inspection.Tests.csproj
@@ -11,10 +11,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Inspection.Tests/Report/Formats/CsvReportFormatTests.cs b/NuKeeper.Inspection.Tests/Report/Formats/CsvReportFormatTests.cs
index bf4f98c9e..72798521f 100644
--- a/NuKeeper.Inspection.Tests/Report/Formats/CsvReportFormatTests.cs
+++ b/NuKeeper.Inspection.Tests/Report/Formats/CsvReportFormatTests.cs
@@ -4,7 +4,6 @@
using NuKeeper.Abstractions.NuGet;
using NuKeeper.Abstractions.RepositoryInspection;
using NuKeeper.Inspection.Report.Formats;
-using NuKeeper.Inspection.RepositoryInspection;
using NUnit.Framework;
namespace NuKeeper.Inspection.Tests.Report.Formats
diff --git a/NuKeeper.Inspection.Tests/Report/Formats/ReportFormatTests.cs b/NuKeeper.Inspection.Tests/Report/Formats/ReportFormatTests.cs
index 3d0c5a384..bdddfc3c5 100644
--- a/NuKeeper.Inspection.Tests/Report/Formats/ReportFormatTests.cs
+++ b/NuKeeper.Inspection.Tests/Report/Formats/ReportFormatTests.cs
@@ -3,7 +3,6 @@
using NuKeeper.Abstractions.RepositoryInspection;
using NuKeeper.Inspection.Report;
using NuKeeper.Inspection.Report.Formats;
-using NuKeeper.Inspection.RepositoryInspection;
using NUnit.Framework;
namespace NuKeeper.Inspection.Tests.Report.Formats
diff --git a/NuKeeper.Inspection.Tests/Sources/NugetSourcesReaderTests.cs b/NuKeeper.Inspection.Tests/Sources/NugetSourcesReaderTests.cs
index fff84f87b..24929c394 100644
--- a/NuKeeper.Inspection.Tests/Sources/NugetSourcesReaderTests.cs
+++ b/NuKeeper.Inspection.Tests/Sources/NugetSourcesReaderTests.cs
@@ -1,7 +1,5 @@
-using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Threading;
using NSubstitute;
using NuGet.Configuration;
using NuKeeper.Abstractions.Inspections.Files;
@@ -15,7 +13,7 @@ namespace NuKeeper.Inspection.Tests.Sources
{
public class NugetSourcesReaderTests
{
- private IFolder _uniqueTemporaryFolder = null;
+ private IFolder _uniqueTemporaryFolder;
[SetUp]
public void Setup()
diff --git a/NuKeeper.Inspection/Files/Folder.cs b/NuKeeper.Inspection/Files/Folder.cs
index 9f882c31f..93bb47d26 100644
--- a/NuKeeper.Inspection/Files/Folder.cs
+++ b/NuKeeper.Inspection/Files/Folder.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
diff --git a/NuKeeper.Inspection/NuGetApi/BulkPackageLookup.cs b/NuKeeper.Inspection/NuGetApi/BulkPackageLookup.cs
index ca8e704c8..d7dfa166d 100644
--- a/NuKeeper.Inspection/NuGetApi/BulkPackageLookup.cs
+++ b/NuKeeper.Inspection/NuGetApi/BulkPackageLookup.cs
@@ -12,11 +12,11 @@ namespace NuKeeper.Inspection.NuGetApi
public class BulkPackageLookup : IBulkPackageLookup
{
private readonly IApiPackageLookup _packageLookup;
- private readonly PackageLookupResultReporter _lookupReporter;
+ private readonly IPackageLookupResultReporter _lookupReporter;
public BulkPackageLookup(
IApiPackageLookup packageLookup,
- PackageLookupResultReporter lookupReporter)
+ IPackageLookupResultReporter lookupReporter)
{
_packageLookup = packageLookup;
_lookupReporter = lookupReporter;
diff --git a/NuKeeper.Inspection/NuGetApi/ConcurrentSourceRepositoryCache.cs b/NuKeeper.Inspection/NuGetApi/ConcurrentSourceRepositoryCache.cs
index 022ae824b..746421568 100644
--- a/NuKeeper.Inspection/NuGetApi/ConcurrentSourceRepositoryCache.cs
+++ b/NuKeeper.Inspection/NuGetApi/ConcurrentSourceRepositoryCache.cs
@@ -1,6 +1,5 @@
using System.Collections.Concurrent;
using NuGet.Configuration;
-using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
namespace NuKeeper.Inspection.NuGetApi
diff --git a/NuKeeper.Inspection/NuGetApi/IPackageLookupResultReporter.cs b/NuKeeper.Inspection/NuGetApi/IPackageLookupResultReporter.cs
new file mode 100644
index 000000000..88912f81c
--- /dev/null
+++ b/NuKeeper.Inspection/NuGetApi/IPackageLookupResultReporter.cs
@@ -0,0 +1,9 @@
+using NuKeeper.Abstractions.NuGetApi;
+
+namespace NuKeeper.Inspection.NuGetApi
+{
+ public interface IPackageLookupResultReporter
+ {
+ void Report(PackageLookupResult lookupResult);
+ }
+}
diff --git a/NuKeeper.Inspection/NuGetApi/PackageLookupResultReporter.cs b/NuKeeper.Inspection/NuGetApi/PackageLookupResultReporter.cs
index eefb494f9..c4063187e 100644
--- a/NuKeeper.Inspection/NuGetApi/PackageLookupResultReporter.cs
+++ b/NuKeeper.Inspection/NuGetApi/PackageLookupResultReporter.cs
@@ -4,7 +4,7 @@
namespace NuKeeper.Inspection.NuGetApi
{
- public class PackageLookupResultReporter
+ public class PackageLookupResultReporter : IPackageLookupResultReporter
{
private readonly INuKeeperLogger _logger;
diff --git a/NuKeeper.Inspection/NuKeeper.Inspection.csproj b/NuKeeper.Inspection/NuKeeper.Inspection.csproj
index e9284d4ce..ebddbe133 100644
--- a/NuKeeper.Inspection/NuKeeper.Inspection.csproj
+++ b/NuKeeper.Inspection/NuKeeper.Inspection.csproj
@@ -6,7 +6,6 @@
..\CodeAnalysisRules.ruleset
-
diff --git a/NuKeeper.Inspection/Sources/INuGetConfigFileReader.cs b/NuKeeper.Inspection/Sources/INuGetConfigFileReader.cs
new file mode 100644
index 000000000..b9a21c8a4
--- /dev/null
+++ b/NuKeeper.Inspection/Sources/INuGetConfigFileReader.cs
@@ -0,0 +1,10 @@
+using NuKeeper.Abstractions.Inspections.Files;
+using NuKeeper.Abstractions.NuGet;
+
+namespace NuKeeper.Inspection.Sources
+{
+ public interface INuGetConfigFileReader
+ {
+ NuGetSources ReadNugetSources(IFolder workingFolder);
+ }
+}
diff --git a/NuKeeper.Inspection/Sources/NuGetConfigFileReader.cs b/NuKeeper.Inspection/Sources/NuGetConfigFileReader.cs
index f6463b572..fc0bac544 100644
--- a/NuKeeper.Inspection/Sources/NuGetConfigFileReader.cs
+++ b/NuKeeper.Inspection/Sources/NuGetConfigFileReader.cs
@@ -8,7 +8,7 @@
namespace NuKeeper.Inspection.Sources
{
- public class NuGetConfigFileReader
+ public class NuGetConfigFileReader : INuGetConfigFileReader
{
private readonly INuKeeperLogger _logger;
diff --git a/NuKeeper.Inspection/Sources/NuGetSourcesReader.cs b/NuKeeper.Inspection/Sources/NuGetSourcesReader.cs
index c752a776f..26ac1e265 100644
--- a/NuKeeper.Inspection/Sources/NuGetSourcesReader.cs
+++ b/NuKeeper.Inspection/Sources/NuGetSourcesReader.cs
@@ -6,11 +6,11 @@ namespace NuKeeper.Inspection.Sources
{
public class NuGetSourcesReader : INuGetSourcesReader
{
- private readonly NuGetConfigFileReader _reader;
+ private readonly INuGetConfigFileReader _reader;
private readonly INuKeeperLogger _logger;
public NuGetSourcesReader(
- NuGetConfigFileReader reader,
+ INuGetConfigFileReader reader,
INuKeeperLogger logger)
{
_reader = reader;
diff --git a/NuKeeper.Integration.Tests/LogHelpers/NuKeeperTestLogger.cs b/NuKeeper.Integration.Tests/LogHelpers/NuKeeperTestLogger.cs
index 3765216e1..223123553 100644
--- a/NuKeeper.Integration.Tests/LogHelpers/NuKeeperTestLogger.cs
+++ b/NuKeeper.Integration.Tests/LogHelpers/NuKeeperTestLogger.cs
@@ -2,7 +2,6 @@
using NUnit.Framework;
using System;
using System.Collections.Concurrent;
-using System.Collections.Generic;
namespace NuKeeper.Integration.Tests.LogHelpers
{
@@ -26,7 +25,7 @@ public void DumpLogToTestOutput()
{
var test = TestContext.CurrentContext.Test.Name;
- if (_buffer.Count > 0)
+ if (!_buffer.IsEmpty)
{
TestContext.Error.WriteLine($"{test}: NuKeeper Log:");
while (_buffer.TryDequeue(out var line))
diff --git a/NuKeeper.Integration.Tests/LogHelpers/NugetTestLogger.cs b/NuKeeper.Integration.Tests/LogHelpers/NugetTestLogger.cs
index 0dd948d27..f6ee9a811 100644
--- a/NuKeeper.Integration.Tests/LogHelpers/NugetTestLogger.cs
+++ b/NuKeeper.Integration.Tests/LogHelpers/NugetTestLogger.cs
@@ -1,7 +1,6 @@
using NuGet.Common;
using NUnit.Framework;
using System.Collections.Concurrent;
-using System.Collections.Generic;
using System.Threading.Tasks;
namespace NuKeeper.Integration.Tests.LogHelpers
@@ -26,7 +25,7 @@ public void DumpLogToTestOutput()
{
var test = TestContext.CurrentContext.Test.Name;
- if (_buffer.Count > 0)
+ if (!_buffer.IsEmpty)
{
TestContext.Error.WriteLine($"{test}: NuKeeper Log:");
while (_buffer.TryDequeue(out var line))
diff --git a/NuKeeper.Integration.Tests/NuGet/Process/DotNetUpdatePackageCommandTests.cs b/NuKeeper.Integration.Tests/NuGet/Process/DotNetUpdatePackageCommandTests.cs
index b912e70bf..f90b747e5 100644
--- a/NuKeeper.Integration.Tests/NuGet/Process/DotNetUpdatePackageCommandTests.cs
+++ b/NuKeeper.Integration.Tests/NuGet/Process/DotNetUpdatePackageCommandTests.cs
@@ -63,7 +63,7 @@ public class DotNetUpdatePackageCommandTests : TestWithFailureLogging
";
- private IFolder _uniqueTemporaryFolder = null;
+ private IFolder _uniqueTemporaryFolder;
[SetUp]
public void Setup()
diff --git a/NuKeeper.Integration.Tests/NuGet/Process/NuGetUpdatePackageCommandTests.cs b/NuKeeper.Integration.Tests/NuGet/Process/NuGetUpdatePackageCommandTests.cs
index 542fb20f8..f1aa31d36 100644
--- a/NuKeeper.Integration.Tests/NuGet/Process/NuGetUpdatePackageCommandTests.cs
+++ b/NuKeeper.Integration.Tests/NuGet/Process/NuGetUpdatePackageCommandTests.cs
@@ -31,7 +31,7 @@ public class NuGetUpdatePackageCommandTests : TestWithFailureLogging
private readonly string _nugetConfig =
@"";
- private IFolder _uniqueTemporaryFolder = null;
+ private IFolder _uniqueTemporaryFolder;
[SetUp]
public void Setup()
diff --git a/NuKeeper.Integration.Tests/NuKeeper.Integration.Tests.csproj b/NuKeeper.Integration.Tests/NuKeeper.Integration.Tests.csproj
index b2eb6e758..94b9ccd61 100644
--- a/NuKeeper.Integration.Tests/NuKeeper.Integration.Tests.csproj
+++ b/NuKeeper.Integration.Tests/NuKeeper.Integration.Tests.csproj
@@ -8,10 +8,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Integration.Tests/RepositoryInspection/RepositoryScannerTests.cs b/NuKeeper.Integration.Tests/RepositoryInspection/RepositoryScannerTests.cs
index c2f933acc..cafbf1e4f 100644
--- a/NuKeeper.Integration.Tests/RepositoryInspection/RepositoryScannerTests.cs
+++ b/NuKeeper.Integration.Tests/RepositoryInspection/RepositoryScannerTests.cs
@@ -48,7 +48,7 @@ public class RepositoryScannerTests : TestWithFailureLogging
";
- private IFolder _uniqueTemporaryFolder = null;
+ private IFolder _uniqueTemporaryFolder;
[SetUp]
public void Setup()
diff --git a/NuKeeper.Tests/Commands/GlobalCommandTests.cs b/NuKeeper.Tests/Commands/GlobalCommandTests.cs
index 678224f32..79f984376 100644
--- a/NuKeeper.Tests/Commands/GlobalCommandTests.cs
+++ b/NuKeeper.Tests/Commands/GlobalCommandTests.cs
@@ -10,6 +10,7 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
+using System.Net.Http;
using System.Threading.Tasks;
using NuKeeper.Abstractions.Git;
using NuKeeper.AzureDevOps;
@@ -23,9 +24,13 @@ private static CollaborationFactory GetCollaborationFactory(Func();
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(new HttpClient());
+
return new CollaborationFactory(
new ISettingsReader[] { createSettingsReader(new MockedGitDiscoveryDriver(), environmentVariablesProvider) },
- Substitute.For()
+ Substitute.For(),
+ httpClientFactory
);
}
diff --git a/NuKeeper.Tests/Commands/OrganisationCommandTests.cs b/NuKeeper.Tests/Commands/OrganisationCommandTests.cs
index 2de1c16d5..e8ce2ed93 100644
--- a/NuKeeper.Tests/Commands/OrganisationCommandTests.cs
+++ b/NuKeeper.Tests/Commands/OrganisationCommandTests.cs
@@ -10,6 +10,7 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
+using System.Net.Http;
using System.Threading.Tasks;
using NuKeeper.Abstractions.Git;
using NuKeeper.AzureDevOps;
@@ -23,9 +24,13 @@ private static CollaborationFactory GetCollaborationFactory(Func();
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(new HttpClient());
+
return new CollaborationFactory(
new ISettingsReader[] { createSettingsReader(new MockedGitDiscoveryDriver(), environmentVariablesProvider) },
- Substitute.For()
+ Substitute.For(),
+ httpClientFactory
);
}
diff --git a/NuKeeper.Tests/Commands/RepositoryCommandTests.cs b/NuKeeper.Tests/Commands/RepositoryCommandTests.cs
index 7e89b4a86..ddfc24ace 100644
--- a/NuKeeper.Tests/Commands/RepositoryCommandTests.cs
+++ b/NuKeeper.Tests/Commands/RepositoryCommandTests.cs
@@ -548,7 +548,8 @@ private static ICollaborationFactory GetCollaborationFactory(IEnvironmentVariabl
{
return new CollaborationFactory(
settingReaders ?? new ISettingsReader[] { new GitHubSettingsReader(new MockedGitDiscoveryDriver(), environmentVariablesProvider) },
- Substitute.For()
+ Substitute.For(),
+ null
);
}
}
diff --git a/NuKeeper.Tests/ContainerRegistrationTests.cs b/NuKeeper.Tests/ContainerRegistrationTests.cs
index 310f7bc88..3a3497b60 100644
--- a/NuKeeper.Tests/ContainerRegistrationTests.cs
+++ b/NuKeeper.Tests/ContainerRegistrationTests.cs
@@ -14,9 +14,10 @@ public void RootCanBeResolved()
{
var container = ContainerRegistration.Init();
- var engine = container.GetInstance();
+ var engine = container.GetInstance();
Assert.That(engine, Is.Not.Null);
+ Assert.That(engine, Is.TypeOf());
}
[Test]
@@ -24,9 +25,10 @@ public void InspectorCanBeResolved()
{
var container = ContainerRegistration.Init();
- var inspector = container.GetInstance();
+ var inspector = container.GetInstance();
Assert.That(inspector, Is.Not.Null);
+ Assert.That(inspector, Is.TypeOf());
}
[TestCase(typeof(InspectCommand))]
diff --git a/NuKeeper.Tests/Engine/CollaborationFactoryTests.cs b/NuKeeper.Tests/Engine/CollaborationFactoryTests.cs
index ec0da998c..054b9260d 100644
--- a/NuKeeper.Tests/Engine/CollaborationFactoryTests.cs
+++ b/NuKeeper.Tests/Engine/CollaborationFactoryTests.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Net.Http;
using System.Threading.Tasks;
using NSubstitute;
using NuKeeper.Abstractions.CollaborationPlatform;
@@ -31,7 +32,10 @@ private static CollaborationFactory GetCollaborationFactory()
var readers = new List { settingReader1, settingReader2 };
var logger = Substitute.For();
- return new CollaborationFactory(readers, logger);
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(new HttpClient());
+
+ return new CollaborationFactory(readers, logger, httpClientFactory);
}
[Test]
diff --git a/NuKeeper.Tests/Engine/RepositoryUpdaterTests.cs b/NuKeeper.Tests/Engine/RepositoryUpdaterTests.cs
index 2dfa5a041..25f4e1dba 100644
--- a/NuKeeper.Tests/Engine/RepositoryUpdaterTests.cs
+++ b/NuKeeper.Tests/Engine/RepositoryUpdaterTests.cs
@@ -248,7 +248,7 @@ private static
var repoUpdater = new RepositoryUpdater(
sources, updateFinder, updateSelection, packageUpdater,
- Substitute.For(), new SolutionsRestore(fileRestore),
+ Substitute.For(), new SolutionRestore(fileRestore),
reporter);
return (repoUpdater, packageUpdater);
diff --git a/NuKeeper.Tests/Engine/SolutionsRestoreTests.cs b/NuKeeper.Tests/Engine/SolutionsRestoreTests.cs
index c8b27f676..d93ccfc9f 100644
--- a/NuKeeper.Tests/Engine/SolutionsRestoreTests.cs
+++ b/NuKeeper.Tests/Engine/SolutionsRestoreTests.cs
@@ -22,7 +22,7 @@ public async Task WhenThereAreNoSolutionsTheCommandIsNotCalled()
var packages = new List();
- var solutionRestore = new SolutionsRestore(cmd);
+ var solutionRestore = new SolutionRestore(cmd);
await solutionRestore.CheckRestore(packages, folder, NuGetSources.GlobalFeed);
@@ -42,7 +42,7 @@ public async Task WhenThereAreNoMatchingPackagesTheCommandIsNotCalled()
var folder = Substitute.For();
folder.Find(Arg.Any()).Returns(new[] { sln });
- var solutionRestore = new SolutionsRestore(cmd);
+ var solutionRestore = new SolutionRestore(cmd);
await solutionRestore.CheckRestore(packages, folder, NuGetSources.GlobalFeed);
@@ -62,7 +62,7 @@ public async Task WhenThereIsOneSolutionsTheCommandIsCalled()
var folder = Substitute.For();
folder.Find(Arg.Any()).Returns(new[] { sln });
- var solutionRestore = new SolutionsRestore(cmd);
+ var solutionRestore = new SolutionRestore(cmd);
await solutionRestore.CheckRestore(packages, folder, NuGetSources.GlobalFeed);
@@ -83,7 +83,7 @@ public async Task WhenThereAreTwoSolutionsTheCommandIsCalledForEachOfThem()
var folder = Substitute.For();
folder.Find(Arg.Any()).Returns(new[] { sln1, sln2 });
- var solutionRestore = new SolutionsRestore(cmd);
+ var solutionRestore = new SolutionRestore(cmd);
await solutionRestore.CheckRestore(packages, folder, NuGetSources.GlobalFeed);
diff --git a/NuKeeper.Tests/Engine/Sort/PackageUpdateSortDependencyTests.cs b/NuKeeper.Tests/Engine/Sort/PackageUpdateSortDependencyTests.cs
index acb2192d9..8f7b2fb56 100644
--- a/NuKeeper.Tests/Engine/Sort/PackageUpdateSortDependencyTests.cs
+++ b/NuKeeper.Tests/Engine/Sort/PackageUpdateSortDependencyTests.cs
@@ -7,7 +7,6 @@
using NuGet.Versioning;
using NuKeeper.Abstractions.Logging;
using NuKeeper.Inspection.Sort;
-using NuKeeper.Inspection.RepositoryInspection;
using NUnit.Framework;
using NuKeeper.Abstractions.RepositoryInspection;
diff --git a/NuKeeper.Tests/Engine/Sort/PackageUpdateSortTests.cs b/NuKeeper.Tests/Engine/Sort/PackageUpdateSortTests.cs
index 65fd0d319..28c82dbda 100644
--- a/NuKeeper.Tests/Engine/Sort/PackageUpdateSortTests.cs
+++ b/NuKeeper.Tests/Engine/Sort/PackageUpdateSortTests.cs
@@ -9,7 +9,6 @@
using NuKeeper.Abstractions;
using NuKeeper.Abstractions.Logging;
using NuKeeper.Inspection.Sort;
-using NuKeeper.Inspection.RepositoryInspection;
using NuKeeper.Abstractions.RepositoryInspection;
namespace NuKeeper.Tests.Engine.Sort
diff --git a/NuKeeper.Tests/Local/LocalUpdaterTests.cs b/NuKeeper.Tests/Local/LocalUpdaterTests.cs
index 8be132f88..25784ae7c 100644
--- a/NuKeeper.Tests/Local/LocalUpdaterTests.cs
+++ b/NuKeeper.Tests/Local/LocalUpdaterTests.cs
@@ -25,7 +25,7 @@ public async Task EmptyListCase()
var runner = Substitute.For();
var logger = Substitute.For();
var folder = Substitute.For();
- var restorer = new SolutionsRestore(Substitute.For());
+ var restorer = new SolutionRestore(Substitute.For());
var updater = new LocalUpdater(selection, runner, restorer, logger);
@@ -50,7 +50,7 @@ public async Task SingleItemCase()
var runner = Substitute.For();
var logger = Substitute.For();
var folder = Substitute.For();
- var restorer = new SolutionsRestore(Substitute.For());
+ var restorer = new SolutionRestore(Substitute.For());
var updater = new LocalUpdater(selection, runner, restorer, logger);
@@ -76,7 +76,7 @@ public async Task TwoItemsCase()
var runner = Substitute.For();
var logger = Substitute.For();
var folder = Substitute.For();
- var restorer = new SolutionsRestore(Substitute.For());
+ var restorer = new SolutionRestore(Substitute.For());
var updater = new LocalUpdater(selection, runner, restorer, logger);
diff --git a/NuKeeper.Tests/NuKeeper.Tests.csproj b/NuKeeper.Tests/NuKeeper.Tests.csproj
index 967562003..8c20820ec 100644
--- a/NuKeeper.Tests/NuKeeper.Tests.csproj
+++ b/NuKeeper.Tests/NuKeeper.Tests.csproj
@@ -8,14 +8,14 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/NuKeeper.Update.Tests/NuKeeper.Update.Tests.csproj b/NuKeeper.Update.Tests/NuKeeper.Update.Tests.csproj
index 15e62c1fd..ae6c67d0b 100644
--- a/NuKeeper.Update.Tests/NuKeeper.Update.Tests.csproj
+++ b/NuKeeper.Update.Tests/NuKeeper.Update.Tests.csproj
@@ -11,10 +11,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/NuKeeper.Update/Process/ISolutionRestore.cs b/NuKeeper.Update/Process/ISolutionRestore.cs
new file mode 100644
index 000000000..6b5ee261e
--- /dev/null
+++ b/NuKeeper.Update/Process/ISolutionRestore.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using NuKeeper.Abstractions.Inspections.Files;
+using NuKeeper.Abstractions.NuGet;
+using NuKeeper.Abstractions.RepositoryInspection;
+
+namespace NuKeeper.Update.Process
+{
+ public interface ISolutionRestore
+ {
+ Task CheckRestore(IEnumerable targetUpdates, IFolder workingFolder, NuGetSources sources);
+ }
+}
diff --git a/NuKeeper.Update/Process/SolutionsRestore.cs b/NuKeeper.Update/Process/SolutionRestore.cs
similarity index 92%
rename from NuKeeper.Update/Process/SolutionsRestore.cs
rename to NuKeeper.Update/Process/SolutionRestore.cs
index cdcb11fe9..62e899fd6 100644
--- a/NuKeeper.Update/Process/SolutionsRestore.cs
+++ b/NuKeeper.Update/Process/SolutionRestore.cs
@@ -8,11 +8,11 @@
namespace NuKeeper.Update.Process
{
- public class SolutionsRestore
+ public class SolutionRestore : ISolutionRestore
{
private readonly IFileRestoreCommand _fileRestoreCommand;
- public SolutionsRestore(IFileRestoreCommand fileRestoreCommand)
+ public SolutionRestore(IFileRestoreCommand fileRestoreCommand)
{
_fileRestoreCommand = fileRestoreCommand;
}
diff --git a/NuKeeper.Update/Process/UpdateDirectoryBuildTargetsCommand.cs b/NuKeeper.Update/Process/UpdateDirectoryBuildTargetsCommand.cs
index 6fbf73ff3..6fa829821 100644
--- a/NuKeeper.Update/Process/UpdateDirectoryBuildTargetsCommand.cs
+++ b/NuKeeper.Update/Process/UpdateDirectoryBuildTargetsCommand.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
diff --git a/NuKeeper.Update/Selection/IUpdateSelection.cs b/NuKeeper.Update/Selection/IUpdateSelection.cs
index 8acb64001..fcb5a9ec7 100644
--- a/NuKeeper.Update/Selection/IUpdateSelection.cs
+++ b/NuKeeper.Update/Selection/IUpdateSelection.cs
@@ -1,6 +1,4 @@
-using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
using NuKeeper.Abstractions.Configuration;
using NuKeeper.Abstractions.RepositoryInspection;
diff --git a/NuKeeper.Update/Selection/UpdateSelection.cs b/NuKeeper.Update/Selection/UpdateSelection.cs
index c9c75c273..495820cbd 100644
--- a/NuKeeper.Update/Selection/UpdateSelection.cs
+++ b/NuKeeper.Update/Selection/UpdateSelection.cs
@@ -12,7 +12,7 @@ public class UpdateSelection : IUpdateSelection
{
private readonly INuKeeperLogger _logger;
private FilterSettings _settings;
- private DateTime? _maxPublishedDate = null;
+ private DateTime? _maxPublishedDate;
public UpdateSelection(INuKeeperLogger logger)
{
diff --git a/NuKeeper/Collaboration/CollaborationFactory.cs b/NuKeeper/Collaboration/CollaborationFactory.cs
index c29018a56..5443acce4 100644
--- a/NuKeeper/Collaboration/CollaborationFactory.cs
+++ b/NuKeeper/Collaboration/CollaborationFactory.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Threading.Tasks;
using NuKeeper.Abstractions;
using NuKeeper.Abstractions.CollaborationPlatform;
@@ -21,6 +22,7 @@ public class CollaborationFactory : ICollaborationFactory
{
private readonly IEnumerable _settingReaders;
private readonly INuKeeperLogger _nuKeeperLogger;
+ private readonly IHttpClientFactory _httpClientFactory;
private Platform? _platform;
public IForkFinder ForkFinder { get; private set; }
@@ -34,10 +36,11 @@ public class CollaborationFactory : ICollaborationFactory
public CollaborationPlatformSettings Settings { get; }
public CollaborationFactory(IEnumerable settingReaders,
- INuKeeperLogger nuKeeperLogger)
+ INuKeeperLogger nuKeeperLogger, IHttpClientFactory httpClientFactory)
{
_settingReaders = settingReaders;
_nuKeeperLogger = nuKeeperLogger;
+ _httpClientFactory = httpClientFactory;
Settings = new CollaborationPlatformSettings();
}
@@ -133,7 +136,7 @@ private void CreateForPlatform()
switch (_platform.Value)
{
case Platform.AzureDevOps:
- CollaborationPlatform = new AzureDevOpsPlatform(_nuKeeperLogger);
+ CollaborationPlatform = new AzureDevOpsPlatform(_nuKeeperLogger, _httpClientFactory);
RepositoryDiscovery = new AzureDevOpsRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform, Settings.Token);
ForkFinder = new AzureDevOpsForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
@@ -150,28 +153,28 @@ private void CreateForPlatform()
break;
case Platform.Bitbucket:
- CollaborationPlatform = new BitbucketPlatform(_nuKeeperLogger);
+ CollaborationPlatform = new BitbucketPlatform(_nuKeeperLogger, _httpClientFactory);
RepositoryDiscovery = new BitbucketRepositoryDiscovery(_nuKeeperLogger);
ForkFinder = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
CommitWorder = new BitbucketCommitWorder();
break;
case Platform.BitbucketLocal:
- CollaborationPlatform = new BitBucketLocalPlatform(_nuKeeperLogger);
+ CollaborationPlatform = new BitBucketLocalPlatform(_nuKeeperLogger, _httpClientFactory);
RepositoryDiscovery = new BitbucketLocalRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform, Settings);
ForkFinder = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
CommitWorder = new DefaultCommitWorder();
break;
case Platform.GitLab:
- CollaborationPlatform = new GitlabPlatform(_nuKeeperLogger);
+ CollaborationPlatform = new GitlabPlatform(_nuKeeperLogger, _httpClientFactory);
RepositoryDiscovery = new GitlabRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
ForkFinder = new GitlabForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
CommitWorder = new DefaultCommitWorder();
break;
case Platform.Gitea:
- CollaborationPlatform = new GiteaPlatform(_nuKeeperLogger);
+ CollaborationPlatform = new GiteaPlatform(_nuKeeperLogger, _httpClientFactory);
RepositoryDiscovery = new GiteaRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
ForkFinder = new GiteaForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
CommitWorder = new DefaultCommitWorder();
diff --git a/NuKeeper/ContainerInspectionRegistration.cs b/NuKeeper/ContainerInspectionRegistration.cs
index b5e421dac..83f6462b1 100644
--- a/NuKeeper/ContainerInspectionRegistration.cs
+++ b/NuKeeper/ContainerInspectionRegistration.cs
@@ -24,17 +24,23 @@ internal static void Register(Container container)
container.Register();
container.Register();
- container.Register();
container.Register();
container.Register();
container.Register();
+ container.Register();
container.Register();
container.Register();
container.Register();
+ container.Register();
+ container.Register();
+ container.Register();
+ container.Register();
+
container.Register();
container.Register();
+ container.Register();
container.Register();
container.Register();
diff --git a/NuKeeper/ContainerRegistration.cs b/NuKeeper/ContainerRegistration.cs
index cbf5d759a..1167a49bf 100644
--- a/NuKeeper/ContainerRegistration.cs
+++ b/NuKeeper/ContainerRegistration.cs
@@ -15,7 +15,13 @@
using NuKeeper.Update.Selection;
using SimpleInjector;
using System.Linq;
+using System.Net;
+using System.Net.Http;
using System.Reflection;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using NuKeeper.Commands;
+using NuKeeper.Update.Process;
namespace NuKeeper
{
@@ -25,13 +31,49 @@ public static Container Init()
{
var container = new Container();
+ RegisterHttpClient(container);
+
Register(container);
+ RegisterCommands(container);
ContainerInspectionRegistration.Register(container);
ContainerUpdateRegistration.Register(container);
+ container.Verify();
+
return container;
}
+ private static void RegisterHttpClient(Container container)
+ {
+ var services = new ServiceCollection();
+ services.AddHttpClient(Options.DefaultName)
+ .ConfigurePrimaryHttpMessageHandler(serviceProvider =>
+ {
+ var httpMessageHandler = new HttpClientHandler();
+ if (httpMessageHandler.SupportsAutomaticDecompression)
+ {
+ // TODO: change to All when moving to .NET 5.0
+ httpMessageHandler.AutomaticDecompression =
+ DecompressionMethods.GZip | DecompressionMethods.Deflate;
+ }
+
+ return httpMessageHandler;
+ });
+ services
+ .AddSimpleInjector(container)
+ .BuildServiceProvider(validateScopes: true)
+ .UseSimpleInjector(container);
+ }
+
+ private static void RegisterCommands(Container container)
+ {
+ container.Register();
+ container.Register();
+ container.Register();
+ container.Register();
+ container.Register();
+ }
+
private static void Register(Container container)
{
container.Register();
@@ -42,10 +84,12 @@ private static void Register(Container container)
container.Register();
container.Register();
container.Register();
+ container.Register();
container.Register();
container.Register();
container.Register();
+ container.Register();
container.RegisterSingleton();
diff --git a/NuKeeper/Engine/RepositoryUpdater.cs b/NuKeeper/Engine/RepositoryUpdater.cs
index 6d83275bf..4d6be81a6 100644
--- a/NuKeeper/Engine/RepositoryUpdater.cs
+++ b/NuKeeper/Engine/RepositoryUpdater.cs
@@ -21,7 +21,7 @@ public class RepositoryUpdater : IRepositoryUpdater
private readonly IPackageUpdateSelection _updateSelection;
private readonly IPackageUpdater _packageUpdater;
private readonly INuKeeperLogger _logger;
- private readonly SolutionsRestore _solutionsRestore;
+ private readonly ISolutionRestore _solutionRestore;
private readonly IReporter _reporter;
public RepositoryUpdater(
@@ -30,7 +30,7 @@ public RepositoryUpdater(
IPackageUpdateSelection updateSelection,
IPackageUpdater packageUpdater,
INuKeeperLogger logger,
- SolutionsRestore solutionsRestore,
+ ISolutionRestore solutionRestore,
IReporter reporter)
{
_nugetSourcesReader = nugetSourcesReader;
@@ -38,7 +38,7 @@ public RepositoryUpdater(
_updateSelection = updateSelection;
_packageUpdater = packageUpdater;
_logger = logger;
- _solutionsRestore = solutionsRestore;
+ _solutionRestore = solutionRestore;
_reporter = reporter;
}
@@ -113,7 +113,7 @@ private async Task DoTargetUpdates(
return 0;
}
- await _solutionsRestore.CheckRestore(targetUpdates, settings.WorkingFolder ?? git.WorkingFolder, sources);
+ await _solutionRestore.CheckRestore(targetUpdates, settings.WorkingFolder ?? git.WorkingFolder, sources);
var updatesDone = await _packageUpdater.MakeUpdatePullRequests(git, repository, targetUpdates, sources, settings);
diff --git a/NuKeeper/Local/LocalUpdater.cs b/NuKeeper/Local/LocalUpdater.cs
index 390fce697..f05f23f8b 100644
--- a/NuKeeper/Local/LocalUpdater.cs
+++ b/NuKeeper/Local/LocalUpdater.cs
@@ -18,18 +18,18 @@ public class LocalUpdater : ILocalUpdater
{
private readonly IUpdateSelection _selection;
private readonly IUpdateRunner _updateRunner;
- private readonly SolutionsRestore _solutionsRestore;
+ private readonly ISolutionRestore _solutionRestore;
private readonly INuKeeperLogger _logger;
public LocalUpdater(
IUpdateSelection selection,
IUpdateRunner updateRunner,
- SolutionsRestore solutionsRestore,
+ ISolutionRestore solutionRestore,
INuKeeperLogger logger)
{
_selection = selection;
_updateRunner = updateRunner;
- _solutionsRestore = solutionsRestore;
+ _solutionRestore = solutionRestore;
_logger = logger;
}
@@ -63,7 +63,7 @@ public async Task ApplyUpdates(
private async Task ApplyUpdates(IReadOnlyCollection updates, IFolder workingFolder, NuGetSources sources)
{
- await _solutionsRestore.CheckRestore(updates, workingFolder, sources);
+ await _solutionRestore.CheckRestore(updates, workingFolder, sources);
foreach (var update in updates)
{
diff --git a/NuKeeper/NuKeeper.csproj b/NuKeeper/NuKeeper.csproj
index a52f233ef..b759f90e1 100644
--- a/NuKeeper/NuKeeper.csproj
+++ b/NuKeeper/NuKeeper.csproj
@@ -1,4 +1,4 @@
-
+
netcoreapp2.1;netcoreapp3.1
Exe
@@ -11,14 +11,16 @@
..\CodeAnalysisRules.ruleset
+
-
+
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
+
@@ -38,7 +40,7 @@
-
+
true
tools\$(TargetFramework)\any\NuGet.exe
diff --git a/Nukeeper.AzureDevOps.Tests/AzureDevOpsRestClientTests.cs b/Nukeeper.AzureDevOps.Tests/AzureDevOpsRestClientTests.cs
index cd9d93fb3..6074fcbd2 100644
--- a/Nukeeper.AzureDevOps.Tests/AzureDevOpsRestClientTests.cs
+++ b/Nukeeper.AzureDevOps.Tests/AzureDevOpsRestClientTests.cs
@@ -21,7 +21,9 @@ public class AzureDevOpsRestClientTests
public void InitializesCorrectly()
{
var httpClient = new HttpClient();
- var restClient = new AzureDevOpsRestClient(httpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(httpClient);
+ var restClient = new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", null);
var encodedToken = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{string.Empty}:PAT"));
Assert.IsTrue(httpClient.DefaultRequestHeaders.Accept.Contains(new MediaTypeWithQualityHeaderValue("application/json")));
@@ -37,7 +39,9 @@ public void ThrowsWithBadJson()
Content = new StringContent(JsonConvert.SerializeObject("Login Page"), Encoding.UTF8, "application/json")
});
var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("https://fakebaseAddress.com/") };
- var restClient = new AzureDevOpsRestClient(fakeHttpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(fakeHttpClient);
+ var restClient = new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", fakeHttpClient.BaseAddress);
var exception = Assert.ThrowsAsync(async () => await restClient.GetGitRepositories("Project"));
}
@@ -50,7 +54,9 @@ public void ThrowsWithUnauthorized()
Content = new StringContent("", Encoding.UTF8, "application/json")
});
var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("https://fakebaseAddress.com/") };
- var restClient = new AzureDevOpsRestClient(fakeHttpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(fakeHttpClient);
+ var restClient = new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", fakeHttpClient.BaseAddress);
var exception = Assert.ThrowsAsync(async () => await restClient.GetGitRepositories("Project"));
Assert.IsTrue(exception.Message.Contains("Unauthorised", StringComparison.InvariantCultureIgnoreCase));
}
@@ -64,7 +70,9 @@ public void ThrowsWithForbidden()
Content = new StringContent("", Encoding.UTF8, "application/json")
});
var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("https://fakebaseAddress.com/") };
- var restClient = new AzureDevOpsRestClient(fakeHttpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(fakeHttpClient);
+ var restClient = new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", fakeHttpClient.BaseAddress);
var exception = Assert.ThrowsAsync(async () => await restClient.GetGitRepositories("Project"));
Assert.IsTrue(exception.Message.Contains("Forbidden", StringComparison.InvariantCultureIgnoreCase));
}
@@ -78,7 +86,9 @@ public void ThrowsWithBadStatusCode()
Content = new StringContent("", Encoding.UTF8, "application/json")
});
var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("https://fakebaseAddress.com/") };
- var restClient = new AzureDevOpsRestClient(fakeHttpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(fakeHttpClient);
+ var restClient = new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", fakeHttpClient.BaseAddress);
var exception = Assert.ThrowsAsync(async () => await restClient.GetGitRepositories("Project"));
Assert.IsTrue(exception.Message.Contains("Error", StringComparison.InvariantCultureIgnoreCase));
}
@@ -381,7 +391,9 @@ private static AzureDevOpsRestClient GetFakeClient(object returnObject)
});
var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("https://fakebaseAddress.com/") };
- return new AzureDevOpsRestClient(fakeHttpClient, Substitute.For(), "PAT");
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(fakeHttpClient);
+ return new AzureDevOpsRestClient(httpClientFactory, Substitute.For(), "PAT", fakeHttpClient.BaseAddress);
}
}
}
diff --git a/Nukeeper.AzureDevOps.Tests/AzureDevopsPlatformTests.cs b/Nukeeper.AzureDevOps.Tests/AzureDevopsPlatformTests.cs
index 450f72848..bbcf75d35 100644
--- a/Nukeeper.AzureDevOps.Tests/AzureDevopsPlatformTests.cs
+++ b/Nukeeper.AzureDevOps.Tests/AzureDevopsPlatformTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Net.Http;
using NUnit.Framework;
using NSubstitute;
using NuKeeper.Abstractions.Configuration;
@@ -12,7 +13,10 @@ public class AzureDevOpsPlatformTests
[Test]
public void Initialise()
{
- var platform = new AzureDevOpsPlatform(Substitute.For());
+ var httpClientFactory = Substitute.For();
+ httpClientFactory.CreateClient().Returns(new HttpClient());
+
+ var platform = new AzureDevOpsPlatform(Substitute.For(), httpClientFactory);
platform.Initialise(new AuthSettings(new Uri("https://uri.com"), "token"));
}
}
diff --git a/Nukeeper.AzureDevOps.Tests/Nukeeper.AzureDevOps.Tests.csproj b/Nukeeper.AzureDevOps.Tests/Nukeeper.AzureDevOps.Tests.csproj
index f4af5e29a..0db095181 100644
--- a/Nukeeper.AzureDevOps.Tests/Nukeeper.AzureDevOps.Tests.csproj
+++ b/Nukeeper.AzureDevOps.Tests/Nukeeper.AzureDevOps.Tests.csproj
@@ -14,10 +14,10 @@
runtime; build; native; contentfiles; analyzers
all
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/Nukeeper.BitBucketLocal/BitBucketLocalPlatform.cs b/Nukeeper.BitBucketLocal/BitBucketLocalPlatform.cs
index 244604972..b2e8f271b 100644
--- a/Nukeeper.BitBucketLocal/BitBucketLocalPlatform.cs
+++ b/Nukeeper.BitBucketLocal/BitBucketLocalPlatform.cs
@@ -15,23 +15,20 @@ namespace NuKeeper.BitBucketLocal
public class BitBucketLocalPlatform : ICollaborationPlatform
{
private readonly INuKeeperLogger _logger;
+ private readonly IHttpClientFactory _clientFactory;
private AuthSettings _settings;
private BitbucketLocalRestClient _client;
- public BitBucketLocalPlatform(INuKeeperLogger nuKeeperLogger)
+ public BitBucketLocalPlatform(INuKeeperLogger nuKeeperLogger, IHttpClientFactory clientFactory)
{
_logger = nuKeeperLogger;
+ _clientFactory = clientFactory;
}
public void Initialise(AuthSettings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
- var httpClient = new HttpClient
- {
- BaseAddress = new Uri($"{settings.ApiBase.Scheme}://{settings.ApiBase.Authority}")
- };
-
- _client = new BitbucketLocalRestClient(httpClient, _logger, settings.Username, settings.Token);
+ _client = new BitbucketLocalRestClient(_clientFactory, _logger, settings.Username, settings.Token, settings.ApiBase);
}
public Task GetCurrentUser()
diff --git a/Nukeeper.BitBucketLocal/BitbucketLocalRestClient.cs b/Nukeeper.BitBucketLocal/BitbucketLocalRestClient.cs
index 24f79974c..98d3faeaa 100644
--- a/Nukeeper.BitBucketLocal/BitbucketLocalRestClient.cs
+++ b/Nukeeper.BitBucketLocal/BitbucketLocalRestClient.cs
@@ -14,7 +14,7 @@
namespace NuKeeper.BitBucketLocal
{
- public class BitbucketLocalRestClient
+ internal class BitbucketLocalRestClient
{
private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings
{
@@ -27,11 +27,13 @@ public class BitbucketLocalRestClient
private const string ApiPath = @"rest/api/1.0";
private const string ApiReviewersPath = @"rest/default-reviewers/1.0";
- public BitbucketLocalRestClient(HttpClient client, INuKeeperLogger logger, string username, string appPassword)
+ public BitbucketLocalRestClient(IHttpClientFactory clientFactory, INuKeeperLogger logger, string username,
+ string appPassword, Uri apiBaseAddress)
{
- _client = client ?? throw new ArgumentNullException(nameof(client));
_logger = logger;
+ _client = clientFactory.CreateClient();
+ _client.BaseAddress = new Uri($"{apiBaseAddress.Scheme}://{apiBaseAddress.Authority}");
var byteArray = Encoding.ASCII.GetBytes($"{username}:{appPassword}");
_client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));