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
2 changes: 0 additions & 2 deletions src/Custom.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<EnableDefaultArtifacts>false</EnableDefaultArtifacts>
<PowerShellModuleName>Particular.ServiceControl.Management</PowerShellModuleName>
<PowerShellModuleArtifactsPath>$(ArtifactsPath)PowerShellModules\$(PowerShellModuleName)\</PowerShellModuleArtifactsPath>
<!-- Remove after upgrading to NServiceBus 8.x -->
<ParticularAnalyzersVersion>0.9.0</ParticularAnalyzersVersion>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ dotnet_diagnostic.CA2007.severity = none
# Justification: Rider displays an error to do with "Accessibility modifiers required (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0040)"
dotnet_diagnostic.IDE0040.severity = none

csharp_style_var_elsewhere = true:error
csharp_style_var_elsewhere = 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
5 changes: 5 additions & 0 deletions src/Particular.LicensingComponent.Persistence/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

# Justification: ServiceControl app has no synchronization context
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
8 changes: 8 additions & 0 deletions src/Particular.LicensingComponent.UnitTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@

# 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.PS0003.severity = none
dotnet_diagnostic.PS0006.severity = none
dotnet_diagnostic.PS0017.severity = none
dotnet_diagnostic.PS0018.severity = none
10 changes: 9 additions & 1 deletion src/Particular.LicensingComponent/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ dotnet_diagnostic.IDE0040.severity = none
dotnet_diagnostic.IDE0010.severity = suggestion

csharp_style_var_elsewhere = true:error
csharp_style_var_for_built_in_types = 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
7 changes: 7 additions & 0 deletions src/ServiceControl.AcceptanceTesting/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,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.
dotnet_diagnostic.PS0013.severity = none
dotnet_diagnostic.PS0018.severity = none
dotnet_diagnostic.PS0019.severity = none
8 changes: 7 additions & 1 deletion src/ServiceControl.AcceptanceTests.RavenDB/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[*.cs]

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

# 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.PS0003.severity = none
dotnet_diagnostic.PS0013.severity = none
dotnet_diagnostic.PS0017.severity = none
dotnet_diagnostic.PS0018.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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected override TransportOperations CreateMessage(TestContext context)
{
var endpointName = NServiceBus.AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(AnEndpoint));
var messageId = Guid.NewGuid().ToString();
var earliestTimeOfFailure = DateTime.UtcNow;
var earliestTimeOfFailure = DateTimeOffset.UtcNow;

context.UniqueMessageId = DeterministicGuid.MakeId(messageId, endpointName).ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected override TransportOperations CreateMessage(TestContext context)

headers["NServiceBus.FailedQ"] = Conventions.EndpointNamingConvention(typeof(VerifyHeader));
headers["$.diagnostics.hostid"] = Guid.NewGuid().ToString();
headers["NServiceBus.TimeOfFailure"] = DateTimeOffsetHelper.ToWireFormattedString(DateTime.UtcNow);
headers["NServiceBus.TimeOfFailure"] = DateTimeOffsetHelper.ToWireFormattedString(DateTimeOffset.UtcNow);

var outgoingMessage = new OutgoingMessage(messageId, headers, context.BodyToSend);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override TransportOperations CreateMessage(MyContext context)
[Headers.MessageId] = i == 2 ? context.MessageId : Guid.NewGuid().ToString(),
["NServiceBus.FailedQ"] = Conventions.EndpointNamingConvention(typeof(Sendonly)),
["$.diagnostics.hostid"] = Guid.NewGuid().ToString(),
["NServiceBus.TimeOfFailure"] = DateTimeOffsetHelper.ToWireFormattedString(DateTime.UtcNow)
["NServiceBus.TimeOfFailure"] = DateTimeOffsetHelper.ToWireFormattedString(DateTimeOffset.UtcNow)

};

Expand Down
7 changes: 7 additions & 0 deletions src/ServiceControl.Api/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# 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.PS0017.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

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

# 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
6 changes: 6 additions & 0 deletions src/ServiceControl.Audit.Persistence.InMemory/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

# Justification: ServiceControl app has no synchronization context
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.PS0018.severity = none
7 changes: 7 additions & 0 deletions src/ServiceControl.Audit.Persistence.RavenDB/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

# Justification: ServiceControl app has no synchronization context
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.PS0018.severity = none
dotnet_diagnostic.PS0020.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

# 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
dotnet_diagnostic.PS0020.severity = none
6 changes: 5 additions & 1 deletion src/ServiceControl.Audit.Persistence.Tests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ dotnet_diagnostic.PS0004.severity = none # A parameter of type CancellationToke
dotnet_diagnostic.PS0018.severity = none # Add a CancellationToken parameter

# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
dotnet_diagnostic.NSB0002.severity = suggestion
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
6 changes: 6 additions & 0 deletions src/ServiceControl.Audit.Persistence/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

# Justification: ServiceControl app has no synchronization context
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.PS0018.severity = none
7 changes: 7 additions & 0 deletions src/ServiceControl.Audit.UnitTests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

# 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.PS0003.severity = none
dotnet_diagnostic.PS0013.severity = none
dotnet_diagnostic.PS0018.severity = none
11 changes: 11 additions & 0 deletions src/ServiceControl.Audit/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@

# Justification: ServiceControl app has no synchronization context
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.PS0013.severity = none
dotnet_diagnostic.PS0017.severity = none
dotnet_diagnostic.PS0018.severity = none
dotnet_diagnostic.PS0019.severity = none
dotnet_diagnostic.PS0020.severity = none
dotnet_diagnostic.PS0021.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Enrich(AuditEnricherContext context)
//and did not send the acknowledgment. We send it here to the acknowledgment queue.
var ackMessage = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>
{
["ServiceControl.Retry.Successful"] = DateTimeOffsetHelper.ToWireFormattedString(DateTime.UtcNow),
["ServiceControl.Retry.Successful"] = DateTimeOffsetHelper.ToWireFormattedString(DateTimeOffset.UtcNow),
["ServiceControl.Retry.UniqueMessageId"] = newRetryMessageId
}, Array.Empty<byte>());
var ackOperation = new TransportOperation(ackMessage, new UnicastAddressTag(ackQueue));
Expand Down
6 changes: 6 additions & 0 deletions src/ServiceControl.Config.Tests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ dotnet_diagnostic.CA2007.severity = none
# Justification: Executable specifications intentionally assign properties after the
# object initializer to mirror user interaction order (e.g. typing a name after load)
dotnet_diagnostic.IDE0017.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.PS0013.severity = none
2 changes: 2 additions & 0 deletions src/ServiceControl.Config/AppBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected override void BuildUp(object instance)
container.InjectProperties(instance);
}

#pragma warning disable PS0027 // Overrides BootstrapperBase.OnStartup, a void-returning Application.Startup handler
protected override async void OnStartup(object sender, StartupEventArgs e)
{
ValidatorOptions.Global.DefaultRuleLevelCascadeMode = CascadeMode.Stop;
Expand All @@ -99,6 +100,7 @@ protected override async void OnStartup(object sender, StartupEventArgs e)
Application.Current.Shutdown(-1);
}
}
#pragma warning restore PS0027

IContainer container;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bool System.Windows.Input.ICommand.CanExecute(object parameter)
return CanExecute((T)parameter);
}

#pragma warning disable PS0027 // ICommand.Execute returns void, so there is nothing to return the task to
async void ICommand<T>.Execute(T obj)
{
using (StartExecuting())
Expand All @@ -23,6 +24,7 @@ async void ICommand<T>.Execute(T obj)

}
}
#pragma warning restore PS0027

void System.Windows.Input.ICommand.Execute(object parameter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ bool System.Windows.Input.ICommand.CanExecute(object parameter)
return CanExecute((T)parameter);
}

#pragma warning disable PS0027 // ICommand.Execute returns void, so there is nothing to return the task to
async void System.Windows.Input.ICommand.Execute(object parameter)
{
await ExecuteAsync((T)parameter);
}
#pragma warning restore PS0027

public async Task ExecuteAsync(T parameter)
{
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceControl.Config/Framework/Rx/RxViewAware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public RxViewAware()
/// <summary>
/// The view chache for this instance.
/// </summary>
#pragma warning disable PS0025 // Keyed by view context identity, so reference equality is what is wanted
protected IDictionary<object, object> Views { get; }
#pragma warning restore PS0025

/// <summary>
/// Raised when a view is attached.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public async Task HandleAsync(ResetInstances message, CancellationToken cancella
NotifyOfPropertyChange(nameof(Instances));
}

// TODO: this is a genuine async void, not an event handler. Because it returns at the first

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my other comment, could you make this async Task and discard the task at the caller?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it should be async Task, but discarding at the call sites would keep the bug the TODO describes. HandleAsync(RefreshInstances) needs to genuinely await it, otherwise PostRefreshInstances is published before the removals have finished, which is the exact ordering that method's own remarks say must not happen.

The blocker is the other call site in the constructor. The clean fix is to move that call into RxScreen.OnInitialize(), which is awaited properly, and then await at both sites. That's a real behaviour change, so I'd rather not fold it into an analyzer-upgrade PR. I will do a standalone PR to fix it.

// await, HandleAsync(RefreshInstances) publishes PostRefreshInstances before the removals have
// finished, which is the ordering that method's own remarks say must not happen. Converting it
// to async Task needs the constructor call site at the top of this class restructured first.
#pragma warning disable PS0027
async void AddAndRemoveInstances()
{
// Remove instances that no longer exist on disk
Expand Down Expand Up @@ -164,6 +169,7 @@ async void AddAndRemoveInstances()
NotifyOfPropertyChange(nameof(HasConfigurationErrors));
NotifyOfPropertyChange(nameof(ConfigurationErrorMessage));
}
#pragma warning restore PS0027

readonly Func<BaseService, InstanceDetailsViewModel> instanceDetailsFunc;
readonly Func<IEnumerable<BaseService>> getAllInstances;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public static void SetDocumentXaml(DependencyObject obj, string value)
obj.SetValue(DocumentXamlProperty, value);
}

#pragma warning disable PS0025 // Tracks which threads are already inside the callback, so reference equality is what is wanted
static HashSet<Thread> recursionProtection = [];
#pragma warning restore PS0025

static readonly Regex doubleNewlineRegex = new Regex(@"\r?\n\r?\n", RegexOptions.Compiled);
static readonly Regex singleNewlineRegex = new Regex(@"\r?\n", RegexOptions.Compiled);
Expand Down
7 changes: 7 additions & 0 deletions src/ServiceControl.DomainEvents/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# 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.PS0019.severity = none
6 changes: 6 additions & 0 deletions src/ServiceControl.Hosting/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*.cs]

# 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 @@ -4,7 +4,7 @@ namespace ServiceControl.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.WindowsServices;

public static class IHostApplicationBuilderExtensions
public static class HostApplicationBuilderExtensions
{
public static void AddWindowsServiceWithRequestTimeout(this IHostApplicationBuilder builder)
{
Expand Down
7 changes: 7 additions & 0 deletions src/ServiceControl.Infrastructure.Metrics/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# 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
dotnet_diagnostic.PS0020.severity = none
5 changes: 5 additions & 0 deletions src/ServiceControl.Infrastructure.Tests/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

# 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.PS0019.severity = none
10 changes: 10 additions & 0 deletions src/ServiceControl.Infrastructure/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.cs]

# 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.PS0013.severity = none
dotnet_diagnostic.PS0018.severity = none
dotnet_diagnostic.PS0020.severity = none
dotnet_diagnostic.PS0021.severity = none
6 changes: 6 additions & 0 deletions src/ServiceControl.Management.PowerShell/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*.cs]

# 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
Loading