diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index a1aa2fd253..fc7ed7ed5d 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -106,6 +106,7 @@
+
diff --git a/src/Particular.LicensingComponent.UnitTests/.editorconfig b/src/Particular.LicensingComponent.UnitTests/.editorconfig
index 474aec5159..0a6ae3dffe 100644
--- a/src/Particular.LicensingComponent.UnitTests/.editorconfig
+++ b/src/Particular.LicensingComponent.UnitTests/.editorconfig
@@ -6,7 +6,4 @@ dotnet_diagnostic.CA2007.severity = none
# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0.
# They are scheduled work, not accepted exceptions: remove a line once this project has no
# violations of that rule left, and never add a rule back to this list.
-dotnet_diagnostic.PS0003.severity = none
-dotnet_diagnostic.PS0006.severity = none
-dotnet_diagnostic.PS0017.severity = none
dotnet_diagnostic.PS0018.severity = none
diff --git a/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs b/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs
index b9318ecc88..0c35b77398 100644
--- a/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs
@@ -34,7 +34,7 @@ public async Task Should_return_known_endpoints_if_any()
var auditQuery = new AuditQuery(NullLogger.Instance, new EndpointsApi_ReturningTwoEndpoints(), new FakeAuditCountApi(), new FakeConfigurationApi());
//Act
- var endpoints = (await auditQuery.GetKnownEndpoints(default)).ToList();
+ var endpoints = (await auditQuery.GetKnownEndpoints()).ToList();
//Assert
Assert.That(endpoints, Is.Not.Null, "Endpoints should be found");
@@ -53,7 +53,7 @@ public async Task Should_return_audit_remotes()
var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), new ConfigurationApi_ReturningOneValidAuditConfig());
//Act
- var remotes = await auditQuery.GetAuditRemotes(default);
+ var remotes = await auditQuery.GetAuditRemotes();
//Assert
Assert.That(remotes, Is.Not.Null, "Remotes should be found");
@@ -81,7 +81,7 @@ public async Task Should_return_successful_audit_connection_if_instances_exist_a
var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), new ConfigurationApi_ReturningOneValidAuditConfig());
//Act
- var connectionSettingsResult = await auditQuery.TestAuditConnection(default);
+ var connectionSettingsResult = await auditQuery.TestAuditConnection();
//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
@@ -103,7 +103,7 @@ public async Task Should_return_diagnostics_and_no_errors_when_no_remotes_define
var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), confiApi);
//Act
- var connectionSettingsResult = await auditQuery.TestAuditConnection(default);
+ var connectionSettingsResult = await auditQuery.TestAuditConnection();
//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
@@ -128,7 +128,7 @@ public async Task Should_always_return_diagnostics_and_relevant_errors_when_inva
var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new FakeAuditCountApi(), confiApi);
//Act
- var connectionSettingsResult = await auditQuery.TestAuditConnection(default);
+ var connectionSettingsResult = await auditQuery.TestAuditConnection();
//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
@@ -148,7 +148,7 @@ public async Task Should_return_correct_audit_count()
var auditQuery = new AuditQuery(NullLogger.Instance, new FakeEndpointApi(), new AuditCountApi_ReturningThreeAuditCounts(), new FakeConfigurationApi());
//Act
- var auditCount = await auditQuery.GetAuditCountForEndpoint("Endpoint1", default);
+ var auditCount = await auditQuery.GetAuditCountForEndpoint("Endpoint1");
Assert.That(auditCount, Is.Not.Null, "AuditCount should be returned");
Assert.That(auditCount.Count, Is.EqualTo(3), "Invalid number of audit counts");
@@ -156,7 +156,7 @@ public async Task Should_return_correct_audit_count()
class ConfigurationApi_ReturningOneValidAuditConfig : IConfigurationApi
{
- public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException();
public Task GetRemoteConfigs(CancellationToken cancellationToken = default)
{
@@ -165,12 +165,12 @@ public Task GetRemoteConfigs(CancellationToken cancellati
return Task.FromResult([remote]);
}
- public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException();
}
class ConfigurationApi_Configurable : IConfigurationApi
{
- public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException();
public Task GetRemoteConfigs(CancellationToken cancellationToken = default)
{
@@ -184,7 +184,7 @@ public Task GetRemoteConfigs(CancellationToken cancellati
return Task.FromResult([remote]);
}
- public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool ReturnAuditConfig { get; set; }
public string RemoteStatus { get; set; }
@@ -194,7 +194,7 @@ public Task GetRemoteConfigs(CancellationToken cancellati
class EndpointsApi_ReturningTwoEndpoints : IEndpointsApi
{
- public Task> GetEndpoints(CancellationToken cancellationToken)
+ public Task> GetEndpoints(CancellationToken cancellationToken = default)
{
return Task.FromResult>([
new Endpoint { Id = Guid.NewGuid(), Name = "Endpoint1" },
@@ -206,7 +206,7 @@ public Task> GetEndpoints(CancellationToken cancellationToken)
class AuditCountApi_ReturningThreeAuditCounts : IAuditCountApi
{
- public async Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken)
+ public async Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default)
{
var auditCounts = new List
{
diff --git a/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs b/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs
index 88a22d2cfd..3c2fdb5474 100644
--- a/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/AuditThroughputCollectorHostedService_Tests.cs
@@ -133,7 +133,7 @@ await Task.Run(async () =>
} while (!token.IsCancellationRequested);
});
- Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit, default);
+ Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit);
//Assert
Assert.That(foundEndpoint, Is.Not.Null, $"Expected endpoint {endpointName} not found.");
@@ -181,9 +181,9 @@ await Task.Run(async () =>
});
await auditThroughputCollectorHostedService.StopAsync(token2);
- Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit, default);
+ Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Audit);
IDictionary> foundEndpointThroughput =
- await DataStore.GetEndpointThroughputByQueueName([endpointName], default);
+ await DataStore.GetEndpointThroughputByQueueName([endpointName]);
ThroughputData[] throughputData = foundEndpointThroughput[endpointName].ToArray();
// Assert
@@ -210,19 +210,19 @@ class AuditQuery_NoAuditRemotes : IAuditQuery
public Func ValidRemoteInstances => r => true;
public Task> GetAuditCountForEndpoint(string endpointUrlName,
- CancellationToken cancellationToken) => Task.FromResult>([]);
+ CancellationToken cancellationToken = default) => Task.FromResult>([]);
- public Task> GetAuditRemotes(CancellationToken cancellationToken) =>
+ public Task> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult>([]);
- public Task> GetKnownEndpoints(CancellationToken cancellationToken)
+ public Task> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
InstanceParameter = true;
return Task.FromResult>([]);
}
- public Task TestAuditConnection(CancellationToken cancellationToken) =>
+ public Task TestAuditConnection(CancellationToken cancellationToken = default) =>
Task.FromResult(
new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] });
@@ -243,23 +243,23 @@ public AuditQuery_WithOneEndpoint(string endpointName, long throughputCount, Dat
public Func ValidRemoteInstances => r => true;
public Task> GetAuditCountForEndpoint(string endpointUrlName,
- CancellationToken cancellationToken)
+ CancellationToken cancellationToken = default)
{
var auditCount = new AuditCount { UtcDate = ThroughputDate, Count = ThroughputCount };
return Task.FromResult(new List { auditCount }.AsEnumerable());
}
- public Task> GetAuditRemotes(CancellationToken cancellationToken) =>
+ public Task> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult>([]);
- public Task> GetKnownEndpoints(CancellationToken cancellationToken)
+ public Task> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
var scEndpoint = new ServiceControlEndpoint { Name = EndpointName, HeartbeatsEnabled = true };
return Task.FromResult>([scEndpoint]);
}
- public Task TestAuditConnection(CancellationToken cancellationToken) =>
+ public Task TestAuditConnection(CancellationToken cancellationToken = default) =>
Task.FromResult(
new ConnectionSettingsTestResult { ConnectionSuccessful = true, ConnectionErrorMessages = [] });
@@ -275,19 +275,19 @@ class AuditQuery_ThrowingAnExceptionOnKnownEndpointsCall : IAuditQuery
public Func ValidRemoteInstances => r => true;
public Task> GetAuditCountForEndpoint(string endpointUrlName,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
- public Task> GetAuditRemotes(CancellationToken cancellationToken) =>
+ public Task> GetAuditRemotes(CancellationToken cancellationToken = default) =>
Task.FromResult>([]);
- public Task> GetKnownEndpoints(CancellationToken cancellationToken)
+ public Task> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
InstanceParameter = true;
throw new Exception("Oops");
}
- public Task TestAuditConnection(CancellationToken cancellationToken) =>
+ public Task TestAuditConnection(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public bool InstanceParameter { get; set; }
@@ -303,17 +303,17 @@ class BrokerThroughputQuery_WithSanitization : IBrokerThroughputQuery
public KeyDescriptionPair[] Settings => throw new NotImplementedException();
- public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) =>
+ public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException();
public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException();
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName)
{
diff --git a/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs b/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs
index 2b5506a498..69ed2e4d8c 100644
--- a/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/BrokerThroughputCollectorHostedServiceTests.cs
@@ -138,7 +138,7 @@ public void Initialize(ReadOnlyDictionary settings)
}
public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
GetGetThroughputPerDay++;
@@ -148,7 +148,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue
}
public async IAsyncEnumerable GetQueueNames(
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (GetQueueNamesCalls++ % 2 == 0)
{
@@ -168,7 +168,7 @@ public async IAsyncEnumerable GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
public string SanitizedEndpointNameCleanser(string endpointName) => endpointName;
@@ -187,7 +187,7 @@ public void Initialize(ReadOnlyDictionary settings)
}
public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await Task.CompletedTask;
@@ -195,7 +195,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue
}
public async IAsyncEnumerable GetQueueNames(
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
yield return new DefaultBrokerQueue("sales@one") { SanitizedName = "sales" };
yield return new DefaultBrokerQueue("sales@two") { SanitizedName = "sales" };
@@ -211,7 +211,7 @@ public async IAsyncEnumerable GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
public string SanitizedEndpointNameCleanser(string endpointName) => endpointName;
@@ -232,7 +232,7 @@ public void Initialize(ReadOnlyDictionary settings)
}
public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await Task.CompletedTask;
@@ -242,7 +242,7 @@ public async IAsyncEnumerable GetThroughputPerDay(IBrokerQueue
}
public async IAsyncEnumerable GetQueueNames(
- [EnumeratorCancellation] CancellationToken cancellationToken)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
yield return new DefaultBrokerQueue("marketing");
yield return new DefaultBrokerQueue("customer");
@@ -256,7 +256,7 @@ public async IAsyncEnumerable GetQueueNames(
public KeyDescriptionPair[] Settings { get; } = [];
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
public string SanitizedEndpointNameCleanser(string endpointName) => endpointName;
diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs
index d2b1b1c93c..e579cf8f9c 100644
--- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs
+++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/DataStoreBuilder.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Contracts;
using Persistence;
@@ -122,7 +123,7 @@ public async Task Build()
{
foreach (Endpoint endpoint in endpoints)
{
- await store.SaveEndpoint(endpoint, default);
+ await store.SaveEndpoint(endpoint);
}
;
@@ -132,7 +133,7 @@ public async Task Build()
foreach (ThroughputData throughput in throughputList)
{
await store.RecordEndpointThroughput(endpointId.Name, throughput.ThroughputSource,
- throughput.Select(entry => new EndpointDailyThroughput(entry.Key, entry.Value)).ToList(), default);
+ throughput.Select(entry => new EndpointDailyThroughput(entry.Key, entry.Value)).ToList());
}
}
}
diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs
index a130d66264..e9c715e857 100644
--- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs
+++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeAuditCountApi.cs
@@ -8,6 +8,6 @@
class FakeAuditCountApi : IAuditCountApi
{
- public Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task> GetEndpointAuditCounts(string endpoint, CancellationToken cancellationToken = default) => throw new NotImplementedException();
}
}
diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs
index 86e97d3c5b..6beb384f0a 100644
--- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs
+++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeBrokerThroughputQuery.cs
@@ -17,17 +17,17 @@ class FakeBrokerThroughputQuery : IBrokerThroughputQuery
public KeyDescriptionPair[] Settings => throw new NotImplementedException();
- public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) =>
+ public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException();
public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException();
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
public string SanitizedEndpointNameCleanser(string endpointName) => endpointName;
diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs
index 9f3a7fc3a0..d7d0893be2 100644
--- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs
+++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeConfigurationApi.cs
@@ -8,8 +8,8 @@
class FakeConfigurationApi : IConfigurationApi
{
- public Task GetConfig(CancellationToken cancellationToken) => throw new NotImplementedException();
- public Task GetRemoteConfigs(CancellationToken cancellationToken) => throw new NotImplementedException();
- public Task GetUrls(string baseUrl, CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task GetConfig(CancellationToken cancellationToken = default) => throw new NotImplementedException();
+ public Task GetRemoteConfigs(CancellationToken cancellationToken = default) => throw new NotImplementedException();
+ public Task GetUrls(string baseUrl, CancellationToken cancellationToken = default) => throw new NotImplementedException();
}
}
diff --git a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs
index 3f2a66a6c0..802db6d5f2 100644
--- a/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs
+++ b/src/Particular.LicensingComponent.UnitTests/Infrastructure/FakeEndpointApi.cs
@@ -9,6 +9,6 @@
class FakeEndpointApi : IEndpointsApi
{
- public Task> GetEndpoints(CancellationToken cancellationToken) => throw new NotImplementedException();
+ public Task> GetEndpoints(CancellationToken cancellationToken = default) => throw new NotImplementedException();
}
}
diff --git a/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs b/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs
index c59a7b63c9..aa13b9852f 100644
--- a/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/MonitoringService_Tests.cs
@@ -37,12 +37,12 @@ public async Task Should_record_new_endpoint_and_throughput()
};
byte[] messageBytes = JsonSerializer.SerializeToUtf8Bytes(message);
- await configuration.MonitoringService.RecordMonitoringThroughput(messageBytes, default);
+ await configuration.MonitoringService.RecordMonitoringThroughput(messageBytes);
// Act
- Endpoint foundEndpoint = await DataStore.GetEndpoint("Endpoint1", ThroughputSource.Monitoring, default);
+ Endpoint foundEndpoint = await DataStore.GetEndpoint("Endpoint1", ThroughputSource.Monitoring);
IDictionary> foundEndpointThroughput =
- await DataStore.GetEndpointThroughputByQueueName(["Endpoint1"], default);
+ await DataStore.GetEndpointThroughputByQueueName(["Endpoint1"]);
ThroughputData[] throughputData = foundEndpointThroughput["Endpoint1"].ToArray();
// Assert
@@ -84,11 +84,11 @@ public async Task Should_sanitize_endpoint_name()
var monitoringService = new MonitoringService(DataStore, new BrokerThroughputQuery_WithSanitization());
byte[] messageBytes = JsonSerializer.SerializeToUtf8Bytes(message);
- await monitoringService.RecordMonitoringThroughput(messageBytes, default);
+ await monitoringService.RecordMonitoringThroughput(messageBytes);
string endpointNameSanitized = "e-ndpoint-1";
// Act
- Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Monitoring, default);
+ Endpoint foundEndpoint = await DataStore.GetEndpoint(endpointName, ThroughputSource.Monitoring);
// Assert
Assert.That(foundEndpoint, Is.Not.Null, $"Expected endpoint {endpointName} not found.");
@@ -109,7 +109,7 @@ public async Task Should_return_successful_monitoring_connection_and_diagnostics
// Act
ConnectionSettingsTestResult connectionSettingsResult =
- await configuration.MonitoringService.TestMonitoringConnection(default);
+ await configuration.MonitoringService.TestMonitoringConnection();
// Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
@@ -139,7 +139,7 @@ public async Task Should_return_error_monitoring_connection_and_diagnostics_if_n
// Act
ConnectionSettingsTestResult connectionSettingsResult =
- await configuration.MonitoringService.TestMonitoringConnection(default);
+ await configuration.MonitoringService.TestMonitoringConnection();
// Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
@@ -169,17 +169,17 @@ class BrokerThroughputQuery_WithSanitization : IBrokerThroughputQuery
public KeyDescriptionPair[] Settings => throw new NotImplementedException();
- public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) =>
+ public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException();
public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException();
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName)
{
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs
index 8d42beea1d..732a6f8122 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_AdditionalEnvironmentDataProvider_Tests.cs
@@ -1,6 +1,7 @@
namespace Particular.LicensingComponent.UnitTests;
using System.Collections.Generic;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
@@ -22,7 +23,7 @@ public async Task Should_include_additional_environment_data_in_throughput_repor
{
// Arrange
// Act
- var report = await ThroughputCollector.GenerateThroughputReport(null, null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport(null, null);
// Assert
Assert.That(report, Is.Not.Null);
Assert.That(report.ReportData, Is.Not.Null);
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs
index 96173bddb8..dc753860ac 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_GenerationStatus_Tests.cs
@@ -1,6 +1,7 @@
namespace Particular.LicensingComponent.UnitTests;
using System;
+using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Particular.LicensingComponent.Contracts;
@@ -25,7 +26,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);
+ var reportGenerationState = await ThroughputCollector.GetReportGenerationState();
// Assert
using (Assert.EnterMultipleScope())
@@ -45,7 +46,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);
+ var reportGenerationState = await ThroughputCollector.GetReportGenerationState();
// Assert
using (Assert.EnterMultipleScope())
@@ -66,7 +67,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);
+ var reportGenerationState = await ThroughputCollector.GetReportGenerationState();
// Assert
using (Assert.EnterMultipleScope())
@@ -87,7 +88,7 @@ await DataStore.CreateBuilder().AddEndpoint()
.Build();
// Act
- var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);
+ var reportGenerationState = await ThroughputCollector.GetReportGenerationState();
// Assert
using (Assert.EnterMultipleScope())
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs
index 096fed9bfe..6978ffa15b 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Dates_Tests.cs
@@ -2,6 +2,7 @@
using System;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Particular.LicensingComponent.Contracts;
@@ -41,7 +42,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
var minDateInReport = new DateTimeOffset(minDate.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs
index c79c987081..200ac65fa8 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs
@@ -1,6 +1,7 @@
namespace Particular.LicensingComponent.UnitTests;
using System.Collections.Generic;
+using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Contracts;
@@ -27,7 +28,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -58,7 +59,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -82,7 +83,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -113,7 +114,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -145,7 +146,7 @@ await DataStore.CreateBuilder()
// Act
var spVersion = "5.1";
- var report = await ThroughputCollector.GenerateThroughputReport(spVersion, null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport(spVersion, null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -170,14 +171,14 @@ await DataStore.CreateBuilder()
var expectedBrokerVersion = "1.2";
var expectedScopeType = "testingScope";
- await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }), default);
+ await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }));
var expectedAuditVersionSummary = new Dictionary { ["4.3.6"] = 2 };
var expectedAuditTransportSummary = new Dictionary { ["AzureServiceBus"] = 2 };
- await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary), default);
+ await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary));
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs
index 68cab4dac4..9082429111 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Indicator_Tests.cs
@@ -1,6 +1,7 @@
namespace Particular.LicensingComponent.UnitTests;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Contracts;
using Infrastructure;
@@ -31,7 +32,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -53,7 +54,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs
index e3bdb7db7a..d589dcaab3 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Masking_Tests.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Particular.LicensingComponent.Contracts;
@@ -28,10 +29,10 @@ await DataStore.CreateBuilder()
.AddEndpoint("Endpoint3", sources: [ThroughputSource.Broker]).WithThroughput(days: 2)
.Build();
var expectedReportMasks = new List { "Endpoint1" };
- await DataStore.SaveReportMasks(expectedReportMasks, default);
+ await DataStore.SaveReportMasks(expectedReportMasks);
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -56,7 +57,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs
index 6603abcad0..ac4503a4ca 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_Throughput_Tests.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Contracts;
using Infrastructure;
@@ -37,7 +38,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -67,7 +68,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -94,7 +95,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -112,7 +113,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -132,7 +133,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -170,7 +171,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -197,7 +198,7 @@ public async Task Should_return_correct_throughput_in_report_when_endpoint_has_n
await DataStore.CreateBuilder().AddEndpoint().Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -224,7 +225,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -258,7 +259,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("", null, default);
+ var report = await ThroughputCollector.GenerateThroughputReport("", null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -298,18 +299,18 @@ await DataStore.CreateBuilder()
.Build();
var expectedReportMasks = new List { "Endpoint1" };
- await DataStore.SaveReportMasks(expectedReportMasks, default);
+ await DataStore.SaveReportMasks(expectedReportMasks);
var expectedBrokerVersion = "1.2";
var expectedScopeType = "testingScope";
- await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }), default);
+ await DataStore.SaveBrokerMetadata(new BrokerMetadata(expectedScopeType, new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = expectedBrokerVersion }));
var expectedAuditVersionSummary = new Dictionary { ["4.3.6"] = 2 };
var expectedAuditTransportSummary = new Dictionary { ["AzureServiceBus"] = 2 };
- await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary), default);
+ await DataStore.SaveAuditServiceMetadata(new AuditServiceMetadata(expectedAuditVersionSummary, expectedAuditTransportSummary));
// Act
- var report = await ThroughputCollector.GenerateThroughputReport("2.3.1", new DateTime(2024, 4, 25), default);
+ var report = await ThroughputCollector.GenerateThroughputReport("2.3.1", new DateTime(2024, 4, 25));
var reportString = System.Text.Json.JsonSerializer.Serialize(report, SerializationOptions.IndentedWithNoEscaping);
// Assert
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs
index 703e842cea..24cc1783b0 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_SanitizedNameGrouping_Tests.cs
@@ -38,7 +38,7 @@ await DataStore.CreateBuilder()
var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse());
// Act
- var summary = await throughputCollector.GetThroughputSummary(default);
+ var summary = await throughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -64,7 +64,7 @@ await DataStore.CreateBuilder()
var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse());
// Act
- var report = await throughputCollector.GenerateThroughputReport(null, null, default);
+ var report = await throughputCollector.GenerateThroughputReport(null, null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -91,7 +91,7 @@ await DataStore.CreateBuilder()
var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithNoSanitizedNameCleanse());
// Act
- var summary = await throughputCollector.GetThroughputSummary(default);
+ var summary = await throughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -117,7 +117,7 @@ await DataStore.CreateBuilder()
var throughputCollector = new ThroughputCollector(DataStore, configuration.ThroughputSettings, configuration.AuditQuery, configuration.MonitoringService, [], new BrokerThroughputQuery_WithNoSanitizedNameCleanse());
// Act
- var report = await throughputCollector.GenerateThroughputReport(null, null, default);
+ var report = await throughputCollector.GenerateThroughputReport(null, null);
// Assert
Assert.That(report, Is.Not.Null);
@@ -136,17 +136,17 @@ class BrokerThroughputQuery_WithLowerCaseSanitizedNameCleanse : IBrokerThroughpu
public KeyDescriptionPair[] Settings => throw new NotImplementedException();
- public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) =>
+ public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException();
public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException();
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
@@ -163,17 +163,17 @@ class BrokerThroughputQuery_WithNoSanitizedNameCleanse : IBrokerThroughputQuery
public KeyDescriptionPair[] Settings => throw new NotImplementedException();
- public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken) =>
+ public IAsyncEnumerable GetQueueNames(CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public IAsyncEnumerable GetThroughputPerDay(IBrokerQueue brokerQueue, DateOnly startDate,
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public bool HasInitialisationErrors(out string errorMessage) => throw new NotImplementedException();
public void Initialize(ReadOnlyDictionary settings) => throw new NotImplementedException();
public Task<(bool Success, List Errors, string Diagnostics)> TestConnection(
- CancellationToken cancellationToken) => throw new NotImplementedException();
+ CancellationToken cancellationToken = default) => throw new NotImplementedException();
public string SanitizeEndpointName(string endpointName) => endpointName;
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs
index ec54124799..a6922f683c 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSumary_Indicator_Tests.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Particular.LicensingComponent.Contracts;
@@ -36,7 +37,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -54,14 +55,14 @@ await DataStore.CreateBuilder()
.AddEndpoint("Endpoint1", sources: [ThroughputSource.Broker]).WithThroughput(days: 2)
.AddEndpoint("Endpoint1", sources: [ThroughputSource.Monitoring]).WithThroughput(days: 2)
.Build();
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Act
List endpointsWithUpdates = [new UpdateUserIndicator() { Name = "Endpoint1", UserIndicator = userIndicator }];
- await ThroughputCollector.UpdateUserIndicatorsOnEndpoints(endpointsWithUpdates, default);
+ await ThroughputCollector.UpdateUserIndicatorsOnEndpoints(endpointsWithUpdates);
// Assert
- var updatedEndpoints = await DataStore.GetAllEndpoints(true, default);
+ var updatedEndpoints = await DataStore.GetAllEndpoints(true);
Assert.That(updatedEndpoints, Is.Not.Null);
Assert.That(updatedEndpoints.Count, Is.EqualTo(2));
diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs
index b3007fe41f..e012779408 100644
--- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs
+++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_ThroughputSummary_Tests.cs
@@ -35,7 +35,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -55,7 +55,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -73,7 +73,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -93,7 +93,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -125,7 +125,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -183,7 +183,7 @@ public async Task Should_return_correct_max_daily_throughput_in_summary_when_end
await DataStore.CreateBuilder().AddEndpoint().Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
@@ -204,7 +204,7 @@ await DataStore.CreateBuilder()
.Build();
// Act
- var summary = await ThroughputCollector.GetThroughputSummary(default);
+ var summary = await ThroughputCollector.GetThroughputSummary();
// Assert
Assert.That(summary, Is.Not.Null);
diff --git a/src/Particular.LicensingComponent/.editorconfig b/src/Particular.LicensingComponent/.editorconfig
index 97adb8c6b7..423278de8e 100644
--- a/src/Particular.LicensingComponent/.editorconfig
+++ b/src/Particular.LicensingComponent/.editorconfig
@@ -12,11 +12,3 @@ dotnet_diagnostic.IDE0010.severity = suggestion
csharp_style_var_elsewhere = true:error
csharp_style_var_for_built_in_types = true:error
-
-# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0.
-# They are scheduled work, not accepted exceptions: remove a line once this project has no
-# violations of that rule left, and never add a rule back to this list.
-dotnet_diagnostic.PS0003.severity = none
-dotnet_diagnostic.PS0008.severity = none
-dotnet_diagnostic.PS0017.severity = none
-dotnet_diagnostic.PS0019.severity = none
diff --git a/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs b/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs
index 7227159665..619a6ebae6 100644
--- a/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs
+++ b/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs
@@ -17,7 +17,7 @@ public class AuditQuery(ILogger logger, IEndpointsApi endpointsApi,
r.SemanticVersion >= MinAuditCountsVersion &&
r.Retention >= TimeSpan.FromDays(2);
- public async Task> GetKnownEndpoints(CancellationToken cancellationToken)
+ public async Task> GetKnownEndpoints(CancellationToken cancellationToken = default)
{
var endpoints = await endpointsApi.GetEndpoints(cancellationToken);
@@ -36,9 +36,9 @@ public async Task> GetKnownEndpoints(Cancell
return scEndpoints ?? [];
}
- public async Task> GetAuditCountForEndpoint(string endpointUrlName, CancellationToken cancellationToken) => (await auditCountApi.GetEndpointAuditCounts(endpointUrlName, cancellationToken)).Select(s => new AuditCount { Count = s.Count, UtcDate = DateOnly.FromDateTime(s.UtcDate) });
+ public async Task> GetAuditCountForEndpoint(string endpointUrlName, CancellationToken cancellationToken = default) => (await auditCountApi.GetEndpointAuditCounts(endpointUrlName, cancellationToken)).Select(s => new AuditCount { Count = s.Count, UtcDate = DateOnly.FromDateTime(s.UtcDate) });
- public async Task> GetAuditRemotes(CancellationToken cancellationToken)
+ public async Task> GetAuditRemotes(CancellationToken cancellationToken = default)
{
try
{
@@ -101,6 +101,10 @@ public async Task> GetAuditRemotes(CancellationT
return remotesInfo;
}
+ catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
+ {
+ throw;
+ }
catch (Exception ex)
{
logger.LogError(ex, "Failed to get Audit Remotes");
@@ -108,7 +112,7 @@ public async Task> GetAuditRemotes(CancellationT
}
}
- public async Task TestAuditConnection(CancellationToken cancellationToken)
+ public async Task TestAuditConnection(CancellationToken cancellationToken = default)
{
var connectionTestResult = new ConnectionSettingsTestResult { ConnectionSuccessful = true };
diff --git a/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs b/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs
index 91c90dbb95..8b50f6cece 100644
--- a/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs
+++ b/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs
@@ -18,7 +18,7 @@ public class AuditThroughputCollectorHostedService(
public TimeSpan DelayStart { get; set; } = TimeSpan.FromSeconds(40);
public static List AuditQueues { get; set; } = [];
- protected override async Task ExecuteAsync(CancellationToken cancellationToken)
+ protected override async Task ExecuteAsync(CancellationToken cancellationToken = default)
{
logger.LogInformation("Starting {ServiceName}", nameof(AuditThroughputCollectorHostedService));
@@ -34,7 +34,11 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
await GatherThroughput(cancellationToken);
}
- catch (Exception ex) when (ex is not OperationCanceledException)
+ catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
+ {
+ throw;
+ }
+ catch (Exception ex)
{
logger.LogError(ex, "Failed to gather throughput from audit");
}
diff --git a/src/Particular.LicensingComponent/AuditThroughput/IAuditQuery.cs b/src/Particular.LicensingComponent/AuditThroughput/IAuditQuery.cs
index ea63076356..66f03b7f35 100644
--- a/src/Particular.LicensingComponent/AuditThroughput/IAuditQuery.cs
+++ b/src/Particular.LicensingComponent/AuditThroughput/IAuditQuery.cs
@@ -8,11 +8,11 @@ public interface IAuditQuery
SemanticVersion MinAuditCountsVersion { get; }
Func ValidRemoteInstances { get; }
- Task> GetKnownEndpoints(CancellationToken cancellationToken);
+ Task> GetKnownEndpoints(CancellationToken cancellationToken = default);
- Task> GetAuditCountForEndpoint(string endpointUrlName, CancellationToken cancellationToken);
- Task> GetAuditRemotes(CancellationToken cancellationToken);
- Task TestAuditConnection(CancellationToken cancellationToken);
+ Task> GetAuditCountForEndpoint(string endpointUrlName, CancellationToken cancellationToken = default);
+ Task> GetAuditRemotes(CancellationToken cancellationToken = default);
+ Task TestAuditConnection(CancellationToken cancellationToken = default);
}
}
diff --git a/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs b/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs
index b8c37d8521..f62b770c1a 100644
--- a/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs
+++ b/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs
@@ -19,7 +19,7 @@ public class BrokerThroughputCollectorHostedService(
{
public TimeSpan DelayStart { get; set; } = TimeSpan.FromSeconds(40);
- protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+ protected override async Task ExecuteAsync(CancellationToken cancellationToken = default)
{
static ReadOnlyDictionary LoadBrokerSettingValues(IEnumerable brokerKeys)
=> new(brokerKeys.Select(pair => KeyValuePair.Create(pair.Key, SettingsReader.Read(ThroughputSettings.SettingsNamespace, pair.Key)))
@@ -37,7 +37,7 @@ static ReadOnlyDictionary LoadBrokerSettingValues(IEnumerable LoadBrokerSettingValues(IEnumerable();
var postfixGenerator = new PostfixGenerator();
- await foreach (var queueName in brokerThroughputQuery.GetQueueNames(stoppingToken))
+ await foreach (var queueName in brokerThroughputQuery.GetQueueNames(cancellationToken))
{
if (PlatformEndpointHelper.IsPlatformEndpoint(queueName.SanitizedName, throughputSettings))
{
@@ -78,13 +82,13 @@ async Task GatherThroughput(CancellationToken stoppingToken)
}
await Task.WhenAll(waitingTasks);
- await dataStore.SaveBrokerMetadata(new BrokerMetadata(brokerThroughputQuery.ScopeType, brokerThroughputQuery.Data), stoppingToken);
+ await dataStore.SaveBrokerMetadata(new BrokerMetadata(brokerThroughputQuery.ScopeType, brokerThroughputQuery.Data), cancellationToken);
return;
async Task Exec(IBrokerQueue queueName, string postfix)
{
var endpointId = new EndpointIdentifier(queueName.QueueName, ThroughputSource.Broker);
- var endpoint = await dataStore.GetEndpoint(endpointId, stoppingToken);
+ var endpoint = await dataStore.GetEndpoint(endpointId, cancellationToken);
if (endpoint == null)
{
@@ -95,14 +99,18 @@ async Task Exec(IBrokerQueue queueName, string postfix)
EndpointIndicators = [.. queueName.EndpointIndicators]
};
- await dataStore.SaveEndpoint(endpoint, stoppingToken);
+ await dataStore.SaveEndpoint(endpoint, cancellationToken);
}
- await foreach (var queueThroughput in brokerThroughputQuery.GetThroughputPerDay(queueName, endpoint.LastCollectedDate.AddDays(1), stoppingToken))
+ await foreach (var queueThroughput in brokerThroughputQuery.GetThroughputPerDay(queueName, endpoint.LastCollectedDate.AddDays(1), cancellationToken))
{
try
{
- await dataStore.RecordEndpointThroughput(queueName.QueueName, ThroughputSource.Broker, queueThroughput.DateUTC, queueThroughput.TotalThroughput, stoppingToken);
+ await dataStore.RecordEndpointThroughput(queueName.QueueName, ThroughputSource.Broker, queueThroughput.DateUTC, queueThroughput.TotalThroughput, cancellationToken);
+ }
+ catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
+ {
+ throw;
}
catch (Exception e)
{
diff --git a/src/Particular.LicensingComponent/IThroughputCollector.cs b/src/Particular.LicensingComponent/IThroughputCollector.cs
index a880f1c37e..6e325dab79 100644
--- a/src/Particular.LicensingComponent/IThroughputCollector.cs
+++ b/src/Particular.LicensingComponent/IThroughputCollector.cs
@@ -5,13 +5,13 @@
public interface IThroughputCollector
{
- Task> GetThroughputSummary(CancellationToken cancellationToken);
- Task UpdateUserIndicatorsOnEndpoints(List userIndicatorUpdates, CancellationToken cancellationToken);
- Task GetThroughputConnectionSettingsInformation(CancellationToken cancellationToken);
- Task TestConnectionSettings(CancellationToken cancellationToken);
- Task GenerateThroughputReport(string spVersion, DateTime? reportEndDate, CancellationToken cancellationToken);
- Task GetReportGenerationState(CancellationToken cancellationToken);
- Task> GetReportMasks(CancellationToken cancellationToken);
- Task UpdateReportMasks(List reportMaskUpdates, CancellationToken cancellationToken);
+ Task> GetThroughputSummary(CancellationToken cancellationToken = default);
+ Task UpdateUserIndicatorsOnEndpoints(List userIndicatorUpdates, CancellationToken cancellationToken = default);
+ Task GetThroughputConnectionSettingsInformation(CancellationToken cancellationToken = default);
+ Task TestConnectionSettings(CancellationToken cancellationToken = default);
+ Task GenerateThroughputReport(string spVersion, DateTime? reportEndDate, CancellationToken cancellationToken = default);
+ Task GetReportGenerationState(CancellationToken cancellationToken = default);
+ Task> GetReportMasks(CancellationToken cancellationToken = default);
+ Task UpdateReportMasks(List reportMaskUpdates, CancellationToken cancellationToken = default);
}
}
diff --git a/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringService.cs b/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringService.cs
index bddab8ab3c..b0dd964a06 100644
--- a/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringService.cs
+++ b/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringService.cs
@@ -10,7 +10,7 @@
public class MonitoringService(ILicensingDataStore dataStore, IBrokerThroughputQuery? brokerThroughputQuery = null)
{
- public async Task RecordMonitoringThroughput(byte[] throughputMessage, CancellationToken cancellationToken)
+ public async Task RecordMonitoringThroughput(byte[] throughputMessage, CancellationToken cancellationToken = default)
{
RecordEndpointThroughputData? message;
using (Stream stream = new MemoryStream(throughputMessage))
@@ -45,7 +45,7 @@ public async Task RecordMonitoringThroughput(byte[] throughputMessage, Cancellat
}
}
- public async Task TestMonitoringConnection(CancellationToken cancellationToken)
+ public async Task TestMonitoringConnection(CancellationToken cancellationToken = default)
{
//NOTE can't actually test the monitoring connection apart from seeing if there has been any throughput recorded from Monitoring
diff --git a/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringThroughputHostedService.cs b/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringThroughputHostedService.cs
index fc5e643bd2..ea8a299e39 100644
--- a/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringThroughputHostedService.cs
+++ b/src/Particular.LicensingComponent/MonitoringThroughput/MonitoringThroughputHostedService.cs
@@ -16,13 +16,17 @@ async Task Handle(MessageContext message, CancellationToken cancellationToken)
{
await monitoringService.RecordMonitoringThroughput(message.Body.ToArray(), cancellationToken);
}
+ catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
+ {
+ throw;
+ }
catch (Exception ex)
{
logger.LogError(ex, "Error receiving throughput data from Monitoring");
}
}
- public async Task StartAsync(CancellationToken cancellationToken)
+ public async Task StartAsync(CancellationToken cancellationToken = default)
{
logger.LogInformation("Starting {ServiceName}", nameof(MonitoringThroughputHostedService));
@@ -30,7 +34,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
await transportInfrastructure.Receivers[ServiceControlSettings.ServiceControlThroughputDataQueue].StartReceive(cancellationToken);
}
- public async Task StopAsync(CancellationToken cancellationToken)
+ public async Task StopAsync(CancellationToken cancellationToken = default)
{
logger.LogInformation("Stopping {ServiceName}", nameof(MonitoringThroughputHostedService));
diff --git a/src/Particular.LicensingComponent/ThroughputCollector.cs b/src/Particular.LicensingComponent/ThroughputCollector.cs
index 32f70aaf40..03f11f2a06 100644
--- a/src/Particular.LicensingComponent/ThroughputCollector.cs
+++ b/src/Particular.LicensingComponent/ThroughputCollector.cs
@@ -16,7 +16,7 @@
public class ThroughputCollector(ILicensingDataStore dataStore, ThroughputSettings throughputSettings, IAuditQuery auditQuery, MonitoringService monitoringService, IEnumerable environmentDataProviders, IBrokerThroughputQuery? throughputQuery = null)
: IThroughputCollector
{
- public async Task GetThroughputConnectionSettingsInformation(CancellationToken cancellationToken)
+ public async Task GetThroughputConnectionSettingsInformation(CancellationToken cancellationToken = default)
{
var throughputConnectionSettings = new ThroughputConnectionSettings
{
@@ -27,7 +27,7 @@ public async Task GetThroughputConnectionSettingsI
return await Task.FromResult(throughputConnectionSettings);
}
- public async Task TestConnectionSettings(CancellationToken cancellationToken)
+ public async Task TestConnectionSettings(CancellationToken cancellationToken = default)
{
var tasks = new List();
var brokerTask = Task.FromResult(new ConnectionSettingsTestResult { ConnectionSuccessful = false, ConnectionErrorMessages = [] });
@@ -55,13 +55,13 @@ public async Task TestConnectionSettings(CancellationToke
return await Task.FromResult(connectionTestResults);
}
- public async Task UpdateUserIndicatorsOnEndpoints(List userIndicatorUpdates, CancellationToken cancellationToken) =>
+ public async Task UpdateUserIndicatorsOnEndpoints(List userIndicatorUpdates, CancellationToken cancellationToken = default) =>
await dataStore.UpdateUserIndicatorOnEndpoints(userIndicatorUpdates, cancellationToken);
- public async Task> GetReportMasks(CancellationToken cancellationToken) => await dataStore.GetReportMasks(cancellationToken);
- public async Task UpdateReportMasks(List reportMaskUpdates, CancellationToken cancellationToken) => await dataStore.SaveReportMasks(reportMaskUpdates, cancellationToken);
+ public async Task> GetReportMasks(CancellationToken cancellationToken = default) => await dataStore.GetReportMasks(cancellationToken);
+ public async Task UpdateReportMasks(List reportMaskUpdates, CancellationToken cancellationToken = default) => await dataStore.SaveReportMasks(reportMaskUpdates, cancellationToken);
- public async Task> GetThroughputSummary(CancellationToken cancellationToken)
+ public async Task> GetThroughputSummary(CancellationToken cancellationToken = default)
{
var endpointSummaries = new List();
@@ -86,7 +86,7 @@ public async Task> GetThroughputSummary(Cancella
return endpointSummaries;
}
- public async Task GetReportGenerationState(CancellationToken cancellationToken) =>
+ public async Task GetReportGenerationState(CancellationToken cancellationToken = default) =>
throughputQuery == null ?
await GetReportGenerationStateForNonBroker(cancellationToken) :
await GetReportGenerationStateForBroker(cancellationToken);
@@ -115,7 +115,7 @@ async Task GetReportGenerationStateForNonBroker(Cancellat
};
}
- public async Task GenerateThroughputReport(string spVersion, DateTime? reportEndDate, CancellationToken cancellationToken)
+ public async Task GenerateThroughputReport(string spVersion, DateTime? reportEndDate, CancellationToken cancellationToken = default)
{
var reportMasks = await dataStore.GetReportMasks(cancellationToken);
var masker = new Masker([.. reportMasks]);
diff --git a/src/Particular.LicensingComponent/WebApi/LicensingController.cs b/src/Particular.LicensingComponent/WebApi/LicensingController.cs
index f898c0cc72..99019ae60c 100644
--- a/src/Particular.LicensingComponent/WebApi/LicensingController.cs
+++ b/src/Particular.LicensingComponent/WebApi/LicensingController.cs
@@ -24,7 +24,7 @@ public LicensingController(IThroughputCollector throughputCollector)
[Authorize(Policy = Permissions.ErrorThroughputView)]
[Route("endpoints")]
[HttpGet]
- public async Task> GetEndpointThroughput(CancellationToken cancellationToken)
+ public async Task> GetEndpointThroughput(CancellationToken cancellationToken = default)
{
return await throughputCollector.GetThroughputSummary(cancellationToken);
}
@@ -32,7 +32,7 @@ public async Task> GetEndpointThroughput(Cancell
[Authorize(Policy = Permissions.ErrorThroughputManage)]
[Route("endpoints/update")]
[HttpPost]
- public async Task UpdateUserSelectionOnEndpointThroughput(List updateUserIndicators, CancellationToken cancellationToken)
+ public async Task UpdateUserSelectionOnEndpointThroughput(List updateUserIndicators, CancellationToken cancellationToken = default)
{
await throughputCollector.UpdateUserIndicatorsOnEndpoints(updateUserIndicators, cancellationToken);
return Ok();
@@ -41,7 +41,7 @@ public async Task UpdateUserSelectionOnEndpointThroughput(List CanThroughputReportBeGenerated(CancellationToken cancellationToken)
+ public async Task CanThroughputReportBeGenerated(CancellationToken cancellationToken = default)
{
return await throughputCollector.GetReportGenerationState(cancellationToken);
}
@@ -49,7 +49,7 @@ public async Task CanThroughputReportBeGenerated(Cancella
[Authorize(Policy = Permissions.ErrorThroughputView)]
[Route("report/file")]
[HttpGet]
- public async Task GetThroughputReportFile([FromQuery(Name = "spVersion")] string? spVersion, CancellationToken cancellationToken)
+ public async Task GetThroughputReportFile([FromQuery(Name = "spVersion")] string? spVersion, CancellationToken cancellationToken = default)
{
var reportStatus = await CanThroughputReportBeGenerated(cancellationToken);
if (!reportStatus.ReportCanBeGenerated)
@@ -86,7 +86,7 @@ public async Task GetThroughputReportFile([FromQuery(Name = "spVersion")] string
[Authorize(Policy = Permissions.ErrorThroughputView)]
[Route("settings/info")]
[HttpGet]
- public async Task GetThroughputSettingsInformation(CancellationToken cancellationToken)
+ public async Task GetThroughputSettingsInformation(CancellationToken cancellationToken = default)
{
return await throughputCollector.GetThroughputConnectionSettingsInformation(cancellationToken);
}
@@ -94,12 +94,12 @@ public async Task GetThroughputSettingsInformation
[Authorize(Policy = Permissions.ErrorThroughputView)]
[Route("settings/test")]
[HttpGet]
- public async Task TestThroughputConnectionSettings(CancellationToken cancellationToken) => await throughputCollector.TestConnectionSettings(cancellationToken);
+ public async Task TestThroughputConnectionSettings(CancellationToken cancellationToken = default) => await throughputCollector.TestConnectionSettings(cancellationToken);
[Authorize(Policy = Permissions.ErrorThroughputView)]
[Route("settings/masks")]
[HttpGet]
- public async Task> GetMasks(CancellationToken cancellationToken)
+ public async Task> GetMasks(CancellationToken cancellationToken = default)
{
return await throughputCollector.GetReportMasks(cancellationToken);
}
@@ -107,7 +107,7 @@ public async Task> GetMasks(CancellationToken cancellationToken)
[Authorize(Policy = Permissions.ErrorThroughputManage)]
[Route("settings/masks/update")]
[HttpPost]
- public async Task UpdateMasks(List updateMasks, CancellationToken cancellationToken)
+ public async Task UpdateMasks(List updateMasks, CancellationToken cancellationToken = default)
{
await throughputCollector.UpdateReportMasks(updateMasks, cancellationToken);
return Ok();
diff --git a/src/ServiceControl.AcceptanceTesting/.editorconfig b/src/ServiceControl.AcceptanceTesting/.editorconfig
index f3c943025f..cc18ee5f5b 100644
--- a/src/ServiceControl.AcceptanceTesting/.editorconfig
+++ b/src/ServiceControl.AcceptanceTesting/.editorconfig
@@ -3,9 +3,10 @@
# Justification: Usage is from test projects
dotnet_diagnostic.CA2007.severity = none
-# Cancellation analyzer debt. These fire because Particular.Analyzers is no longer pinned to 0.9.0.
-# They are scheduled work, not accepted exceptions: remove a line once this project has no
-# violations of that rule left, and never add a rule back to this list.
+# These types sit on NServiceBus.AcceptanceTesting's extension points, which drive them without a
+# CancellationToken: IEndpointSetupTemplate, IComponentBehavior/ComponentRunner, and the scenario
+# Done/When callbacks whose delegate shapes the framework fixes. A token added here could only ever
+# be CancellationToken.None. Everything else in this project takes and forwards one.
+[{EndpointTemplates/*.cs,InfrastructureConfig/*.cs,ScenarioWithEndpointBehaviorExtensions.cs,Sequence.cs,DispatchRawMessages.cs}]
dotnet_diagnostic.PS0013.severity = none
dotnet_diagnostic.PS0018.severity = none
-dotnet_diagnostic.PS0019.severity = none
diff --git a/src/ServiceControl.AcceptanceTesting/Cors/CorsAssertions.cs b/src/ServiceControl.AcceptanceTesting/Cors/CorsAssertions.cs
index d92d55af6d..2c9e4189dc 100644
--- a/src/ServiceControl.AcceptanceTesting/Cors/CorsAssertions.cs
+++ b/src/ServiceControl.AcceptanceTesting/Cors/CorsAssertions.cs
@@ -2,6 +2,7 @@ namespace ServiceControl.AcceptanceTesting.Cors
{
using System.Net;
using System.Net.Http;
+ using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
@@ -22,13 +23,14 @@ public static class CorsAssertions
public static async Task SendPreflightRequest(
HttpClient httpClient,
string origin,
- string requestMethod = "GET")
+ string requestMethod = "GET",
+ CancellationToken cancellationToken = default)
{
using var request = new HttpRequestMessage(HttpMethod.Options, "/api");
request.Headers.Add("Origin", origin);
request.Headers.Add("Access-Control-Request-Method", requestMethod);
- return await httpClient.SendAsync(request);
+ return await httpClient.SendAsync(request, cancellationToken);
}
///
@@ -37,12 +39,13 @@ public static async Task SendPreflightRequest(
public static async Task SendRequestWithOrigin(
HttpClient httpClient,
string origin,
- string endpoint = "/api")
+ string endpoint = "/api",
+ CancellationToken cancellationToken = default)
{
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
request.Headers.Add("Origin", origin);
- return await httpClient.SendAsync(request);
+ return await httpClient.SendAsync(request, cancellationToken);
}
///
diff --git a/src/ServiceControl.AcceptanceTesting/EndpointConfigurationExtensions.cs b/src/ServiceControl.AcceptanceTesting/EndpointConfigurationExtensions.cs
index 8998e768d7..bcce34bc4f 100644
--- a/src/ServiceControl.AcceptanceTesting/EndpointConfigurationExtensions.cs
+++ b/src/ServiceControl.AcceptanceTesting/EndpointConfigurationExtensions.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+ using System.Threading;
using System.Threading.Tasks;
using InfrastructureConfig;
using NServiceBus;
@@ -54,7 +55,7 @@ IEnumerable GetNestedTypeRecursive(Type rootType, Type builderType)
}
}
- public static async Task DefinePersistence(this EndpointConfiguration config, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration)
+ public static async Task DefinePersistence(this EndpointConfiguration config, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration, CancellationToken cancellationToken = default)
{
var persistenceConfiguration = new ConfigureEndpointInMemoryPersistence();
await persistenceConfiguration.Configure(endpointCustomizationConfiguration.EndpointName, config, runDescriptor.Settings, endpointCustomizationConfiguration.PublisherMetadata);
diff --git a/src/ServiceControl.AcceptanceTesting/ForwardedHeaders/ForwardedHeadersAssertions.cs b/src/ServiceControl.AcceptanceTesting/ForwardedHeaders/ForwardedHeadersAssertions.cs
index a8da121863..a4f90a49ba 100644
--- a/src/ServiceControl.AcceptanceTesting/ForwardedHeaders/ForwardedHeadersAssertions.cs
+++ b/src/ServiceControl.AcceptanceTesting/ForwardedHeaders/ForwardedHeadersAssertions.cs
@@ -2,6 +2,7 @@ namespace ServiceControl.AcceptanceTesting.ForwardedHeaders
{
using System.Net.Http;
using System.Text.Json;
+ using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
@@ -20,7 +21,8 @@ public static async Task GetRequestInfo(
string xForwardedFor = null,
string xForwardedProto = null,
string xForwardedHost = null,
- string testRemoteIp = null)
+ string testRemoteIp = null,
+ CancellationToken cancellationToken = default)
{
using var request = new HttpRequestMessage(HttpMethod.Get, "/debug/request-info");
@@ -41,10 +43,10 @@ public static async Task GetRequestInfo(
request.Headers.Add(TestRemoteIpMiddleware.HeaderName, testRemoteIp);
}
- var response = await httpClient.SendAsync(request);
+ var response = await httpClient.SendAsync(request, cancellationToken);
_ = response.EnsureSuccessStatusCode();
- var content = await response.Content.ReadAsStringAsync();
+ var content = await response.Content.ReadAsStringAsync(cancellationToken);
return JsonSerializer.Deserialize(content, serializerOptions);
}
diff --git a/src/ServiceControl.AcceptanceTesting/HttpClientExtensions.cs b/src/ServiceControl.AcceptanceTesting/HttpClientExtensions.cs
index 861fbe4045..f30d41518b 100644
--- a/src/ServiceControl.AcceptanceTesting/HttpClientExtensions.cs
+++ b/src/ServiceControl.AcceptanceTesting/HttpClientExtensions.cs
@@ -1,11 +1,12 @@
namespace ServiceControl.AcceptanceTesting
{
using System.Net.Http;
+ using System.Threading;
using System.Threading.Tasks;
public static class HttpClientExtensions
{
- public static async Task PatchAsync(this HttpClient client, string requestUri, HttpContent iContent)
+ public static async Task PatchAsync(this HttpClient client, string requestUri, HttpContent iContent, CancellationToken cancellationToken = default)
{
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUri)
@@ -13,7 +14,7 @@ public static async Task PatchAsync(this HttpClient client,
Content = iContent
};
- var response = await client.SendAsync(request);
+ var response = await client.SendAsync(request, cancellationToken);
return response;
}
diff --git a/src/ServiceControl.AcceptanceTesting/HttpExtensions.cs b/src/ServiceControl.AcceptanceTesting/HttpExtensions.cs
index 7e5ebde17f..9f8c8ee140 100644
--- a/src/ServiceControl.AcceptanceTesting/HttpExtensions.cs
+++ b/src/ServiceControl.AcceptanceTesting/HttpExtensions.cs
@@ -6,16 +6,17 @@ namespace ServiceControl.AcceptanceTesting
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
+ using System.Threading;
using System.Threading.Tasks;
public static class HttpExtensions
{
- public static async Task Put(this IAcceptanceTestInfrastructureProvider provider, string url, T payload = null, Func requestHasFailed = null) where T : class
+ public static async Task Put(this IAcceptanceTestInfrastructureProvider provider, string url, T payload = null, Func requestHasFailed = null, CancellationToken cancellationToken = default) where T : class
{
requestHasFailed ??= statusCode => statusCode is not HttpStatusCode.OK and not HttpStatusCode.Accepted;
var httpClient = provider.HttpClient;
- var response = await httpClient.PutAsJsonAsync(url, payload, provider.SerializerOptions);
+ var response = await httpClient.PutAsJsonAsync(url, payload, provider.SerializerOptions, cancellationToken);
if (requestHasFailed(response.StatusCode))
{
@@ -23,24 +24,24 @@ public static async Task Put(this IAcceptanceTestInfrastructureProvider provi
}
}
- public static Task GetRaw(this IAcceptanceTestInfrastructureProvider provider, string url)
+ public static Task GetRaw(this IAcceptanceTestInfrastructureProvider provider, string url, CancellationToken cancellationToken = default)
{
var httpClient = provider.HttpClient;
- return httpClient.GetAsync(url);
+ return httpClient.GetAsync(url, cancellationToken);
}
- public static Task Options(this IAcceptanceTestInfrastructureProvider provider, string url)
+ public static Task Options(this IAcceptanceTestInfrastructureProvider provider, string url, CancellationToken cancellationToken = default)
{
var httpClient = provider.HttpClient;
var request = new HttpRequestMessage(HttpMethod.Options, url);
- return httpClient.SendAsync(request);
+ return httpClient.SendAsync(request, cancellationToken);
}
- public static async Task> TryGetMany(this IAcceptanceTestInfrastructureProvider provider, string url, Predicate condition = null) where T : class
+ public static async Task> TryGetMany(this IAcceptanceTestInfrastructureProvider provider, string url, Predicate condition = null, CancellationToken cancellationToken = default) where T : class
{
condition ??= _ => true;
- var response = await provider.GetInternal>(url);
+ var response = await provider.GetInternal>(url, cancellationToken);
if (response == null || !response.Any(m => condition(m)))
{
@@ -50,25 +51,25 @@ public static async Task> TryGetMany(this IAcceptanceTestInfras
return ManyResult.New(true, response.Where(m => condition(m)).ToList());
}
- public static async Task Patch(this IAcceptanceTestInfrastructureProvider provider, string url, T payload = null) where T : class
+ public static async Task Patch