Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Particular.LicensingComponent.UnitTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

# Justification: Test project
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.PS0018.severity = none
8 changes: 0 additions & 8 deletions src/ServiceControl.AcceptanceTesting/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,3 @@

# Justification: Usage is from test projects
dotnet_diagnostic.CA2007.severity = none

# 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
4 changes: 4 additions & 0 deletions src/ServiceControl.AcceptanceTesting/DispatchRawMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using NServiceBus.Features;
using NServiceBus.Transport;

#pragma warning disable PS0013
#pragma warning disable PS0018
public abstract class DispatchRawMessages<TContext> : Feature
where TContext : ScenarioContext
{
Expand Down Expand Up @@ -79,4 +81,6 @@ protected override Task OnStop(IMessageSession session, CancellationToken cancel
ScenarioContext scenarioContext;
}
}
#pragma warning restore PS0018
#pragma warning restore PS0013
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ protected DefaultServerBase() : this(new ConfigureEndpointLearningTransport())
{
}

#pragma warning disable PS0013
#pragma warning disable PS0018
public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizations, Func<EndpointConfiguration, Task> configurationBuilderCustomization)
#pragma warning restore PS0018
#pragma warning restore PS0013
{
var endpointConfiguration = new EndpointConfiguration(endpointCustomizations.EndpointName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/// Provide a mechanism in acceptance tests for transports and persistences
/// to configure an endpoint for a test and then clean up afterwards.
/// </summary>
#pragma warning disable PS0018
public interface IConfigureEndpointTestExecution
{
/// <summary>
Expand All @@ -32,4 +33,5 @@ public interface IConfigureEndpointTestExecution
/// <returns>An async Task.</returns>
Task Cleanup();
}
#pragma warning restore PS0018
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NServiceBus;
using NServiceBus.AcceptanceTesting.Support;

#pragma warning disable PS0018
public class ConfigureEndpointInMemoryPersistence : IConfigureEndpointTestExecution
{
public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
Expand All @@ -17,4 +18,5 @@ public Task Cleanup() =>
// Nothing required for in-memory persistence
Task.CompletedTask;
}
#pragma warning restore PS0018
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NServiceBus.AcceptanceTesting.Support;
using NUnit.Framework;

#pragma warning disable PS0018
public class ConfigureEndpointLearningTransport : ITransportIntegration
{
public ConfigureEndpointLearningTransport()
Expand Down Expand Up @@ -48,4 +49,5 @@ public Task Cleanup()

public string TypeName => "LearningTransport";
}
#pragma warning restore PS0018
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Support;

#pragma warning disable PS0013
#pragma warning disable PS0018
public static class ScenarioWithEndpointBehaviorExtensions
{
public static IScenarioWithEndpointBehavior<TContext> Done<TContext>(this IScenarioWithEndpointBehavior<TContext> endpointBehavior, Func<TContext, Task<bool>> func) where TContext : ScenarioContext
Expand Down Expand Up @@ -158,4 +160,6 @@ public override async Task Stop(CancellationToken cancellationToken = default)
CancellationTokenSource tokenSource;
}
}
#pragma warning restore PS0018
#pragma warning restore PS0013
}
4 changes: 4 additions & 0 deletions src/ServiceControl.AcceptanceTesting/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;

#pragma warning disable PS0013
#pragma warning disable PS0018
class Sequence<TContext>
where TContext : ISequenceContext
{
Expand Down Expand Up @@ -55,4 +57,6 @@ public async Task<bool> Continue(TContext context)
List<Func<TContext, Task<bool>>> steps = [];
List<string> stepNames = [];
}
#pragma warning restore PS0018
#pragma warning restore PS0013
}
10 changes: 0 additions & 10 deletions src/ServiceControl.AcceptanceTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,5 @@

# Justification: Test project
dotnet_diagnostic.CA2007.severity = none

# Timezone debt: these DateTime values are Kind=Unspecified or Local, so the implicit cast to
# DateTimeOffset uses the build agent's offset. Each needs individual review before removing.
dotnet_diagnostic.PS0022.severity = none

# Justification: these are the test helpers the NServiceBus.AcceptanceTesting scenario API drives.
# It calls Done/When callbacks and IComponentBehavior/ComponentRunner without a CancellationToken,
# so a token added here could only ever be CancellationToken.None at every call site, which tests
# nothing. Tests that genuinely exercise cancellation use [Test, CancelAfter(...)] with the token
# NUnit injects, and forward that. Helpers reachable with a real token do take one.
dotnet_diagnostic.PS0013.severity = none
dotnet_diagnostic.PS0018.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override TransportOperations CreateMessage(Context context)

OutgoingMessage CreateTransportMessage(string messageId)
{
var date = new DateTime(2015, 9, 20, 0, 0, 0);
var date = new DateTimeOffset(2015, 9, 20, 0, 0, 0, TimeSpan.Zero);
var msg = new OutgoingMessage(messageId, new Dictionary<string, string>
{
{Headers.MessageId, messageId},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected override TransportOperations CreateMessage(MyContext context)

OutgoingMessage CreateTransportMessage(int i)
{
var date = new DateTime(2015, 9 + i, 20 + i, 0, 0, 0);
var date = new DateTimeOffset(2015, 9 + i, 20 + i, 0, 0, 0, TimeSpan.Zero);
var messageId = $"{i}{MessageId}";
var msg = new OutgoingMessage(messageId, new Dictionary<string, string>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task The_import_should_deduplicate_on_TimeOfFailure()
using (Assert.EnterMultipleScope())
{
Assert.That(attempts, Has.Count.EqualTo(1));
Assert.That(attempts[^1].AttemptedAt, Is.EqualTo(context.FailureTime));
Assert.That(attempts[^1].AttemptedAt, Is.EqualTo(context.FailureTime.UtcDateTime));
}
}

Expand Down Expand Up @@ -88,12 +88,12 @@ protected override TransportOperations CreateMessage(MyContext context)
{
var messageId = Guid.NewGuid().ToString();
context.UniqueId = DeterministicGuid.MakeId(messageId, "Error.SourceEndpoint").ToString();
context.FailureTime = new DateTime(2020, 09, 05, 13, 20, 00, 0, DateTimeKind.Utc);
context.FailureTime = new DateTimeOffset(2020, 09, 05, 13, 20, 00, 0, TimeSpan.Zero);

return new TransportOperations([.. GetMessages(context.UniqueId, context.FailureTime)]);
}

IEnumerable<TransportOperation> GetMessages(string uniqueId, DateTime failureTime)
IEnumerable<TransportOperation> GetMessages(string uniqueId, DateTimeOffset failureTime)
{
for (var i = 0; i < NumberOfDuplicates; i++)
{
Expand Down Expand Up @@ -125,7 +125,7 @@ class MyContext : ScenarioContext
{
public string UniqueId { get; set; }

public DateTime FailureTime { get; set; }
public DateTimeOffset FailureTime { get; set; }

public int IngestedCount => receivedMessages.Count;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public async Task TimeSent_should_not_be_casted()
var context = await Define<TestContext>(c =>
{
c.AddMinimalRequiredHeaders();
#pragma warning disable PS0022
c.Headers.Add(Headers.TimeSent, DateTimeOffsetHelper.ToWireFormattedString(sentTime));
#pragma warning restore PS0022
})
.WithEndpoint<FailingEndpoint>()
.Done(async c => await TryGetFailureFromApi(c))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

# Justification: Test project
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.PS0018.severity = none
4 changes: 0 additions & 4 deletions src/ServiceControl.Audit.AcceptanceTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

# Justification: Test project
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.PS0018.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public async Task ProcessFailedMessages(
try
{
stream = await session.Advanced.StreamAsync(query, cancellationToken);
while (!cancellationToken.IsCancellationRequested &&
await stream.MoveNextAsync())
while (await stream.MoveNextAsync())
{
cancellationToken.ThrowIfCancellationRequested();

FailedTransportMessage transportMessage = stream.Current.Document.Message;
var localSession = session;

Expand Down
11 changes: 0 additions & 11 deletions src/ServiceControl.Audit.Persistence.Tests.RavenDB/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,4 @@

# Justification: Test project
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.
# The remaining sites are private test helpers that already close over the fixture's
# TestTimeoutCancellationToken, so they need a parameter added rather than a token found.
dotnet_diagnostic.PS0018.severity = none

# Justification: the polling loop swallows OperationCanceledException on purpose, because querying an
# index at the moment it updates throws one. That is not cancellation, so there is no token to filter on.
[IndexSetupTests.cs]
dotnet_diagnostic.PS0020.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ async Task<IndexStats> WaitForIndexDefinitionUpdate(IndexStats oldStats)
return newStats;
}
}
#pragma warning disable PS0020
catch (OperationCanceledException)
{
// keep going since we can get this if we query right when the update happens
}
#pragma warning restore PS0020

await Task.Delay(TimeSpan.FromMilliseconds(100), TestTimeoutCancellationToken);
}
Expand Down
7 changes: 1 addition & 6 deletions src/ServiceControl.Audit.Persistence.Tests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

# Justification: Test project
dotnet_diagnostic.CA2007.severity = none
dotnet_diagnostic.PS0004.severity = none # A parameter of type CancellationToken on a private delegate or method should be required
dotnet_diagnostic.PS0018.severity = none # Add a CancellationToken parameter
dotnet_diagnostic.PS0018.severity = none

# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
dotnet_diagnostic.NSB0002.severity = suggestion

# Timezone debt: these DateTime values are Kind=Unspecified or Local, so the implicit cast to
# DateTimeOffset uses the build agent's offset. Each needs individual review before removing.
dotnet_diagnostic.PS0022.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AuditCountingTests : PersistenceTestFixture
[Test]
public async Task ShouldCountAuditedMessages()
{
var today = DateTime.UtcNow.Date;
var today = new DateTimeOffset(DateTime.UtcNow.Date, TimeSpan.Zero);
var yesterday = today.AddDays(-1);
var weekBefore = yesterday.AddDays(-7);

Expand Down Expand Up @@ -67,7 +67,7 @@ string ScrubDates(string input)
}, ScrubDates);
}

ProcessedMessage MakeMessage(string processingEndpoint, DateTime processedAt, bool systemMessage)
ProcessedMessage MakeMessage(string processingEndpoint, DateTimeOffset processedAt, bool systemMessage)
{
var messageId = Guid.NewGuid().ToString();
var messageType = "MyMessageType";
Expand Down
10 changes: 5 additions & 5 deletions src/ServiceControl.Audit.Persistence.Tests/AuditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public async Task Deduplicates_messages_in_same_batch()
var unitOfWork = await StartAuditUnitOfWork(1);
var messageId = "duplicatedId";
var processingEndpoint = "endpoint";
var processingStarted = DateTime.UtcNow;
var processingStarted = DateTimeOffset.UtcNow;

var processedMessage = MakeMessage(messageId: messageId, processingEndpoint: processingEndpoint, processingStarted: processingStarted);
var duplicatedMessage = MakeMessage(messageId: messageId, processingEndpoint: processingEndpoint, processingStarted: processingStarted);
Expand All @@ -190,7 +190,7 @@ public async Task Deduplicates_messages_in_different_batches()
{
var messageId = "duplicatedId";
var processingEndpoint = "endpoint";
var processingStarted = DateTime.UtcNow;
var processingStarted = DateTimeOffset.UtcNow;

var processedMessage = MakeMessage(messageId: messageId, processingEndpoint: processingEndpoint, processingStarted: processingStarted);
var unitOfWork1 = await StartAuditUnitOfWork(1);
Expand All @@ -215,7 +215,7 @@ public async Task Does_not_deduplicate_with_different_processing_started_header(
var unitOfWork = await StartAuditUnitOfWork(1);
var messageId = "duplicatedId";
var processingEndpoint = "endpoint";
var processingStarted = DateTime.UtcNow;
var processingStarted = DateTimeOffset.UtcNow;
var duplicatedProcessingStarted = processingStarted.AddSeconds(5);

var processedMessage = MakeMessage(messageId: messageId, processingEndpoint: processingEndpoint, processingStarted: processingStarted);
Expand Down Expand Up @@ -255,7 +255,7 @@ ProcessedMessage MakeMessage(
MessageIntent intent = MessageIntent.Send,
string conversationId = null,
string processingEndpoint = null,
DateTime? processingStarted = null,
DateTimeOffset? processingStarted = null,
string messageType = null
)
{
Expand Down Expand Up @@ -284,7 +284,7 @@ ProcessedMessage MakeMessage(
{ Headers.ProcessingEndpoint, processingEndpoint },
{ Headers.MessageIntent, intent.ToString() },
{ Headers.ConversationId, conversationId },
{ Headers.ProcessingStarted, DateTimeOffsetHelper.ToWireFormattedString(processingStarted ?? DateTime.UtcNow) },
{ Headers.ProcessingStarted, DateTimeOffsetHelper.ToWireFormattedString(processingStarted ?? DateTimeOffset.UtcNow) },
{ Headers.EnclosedMessageTypes, messageType }
};

Expand Down
Loading