Skip to content
Closed
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
3 changes: 1 addition & 2 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ insert_final_newline = false
dotnet_diagnostic.CA1068.severity = error
dotnet_diagnostic.CA1710.severity = error
dotnet_diagnostic.CA1711.severity = error
dotnet_diagnostic.CA2007.severity = error
dotnet_diagnostic.CA2007.severity = none
Copy link
Member

Choose a reason for hiding this comment

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

Won't this be reset by repo sync?

Copy link
Member Author

Choose a reason for hiding this comment

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

ugh, didn't think about that, is there a workaround for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@bording is there some way to override this on the /src level?

Copy link
Member

Choose a reason for hiding this comment

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

No there isn't. If want to make this change, you need to add an .editorconfig file to every project to disable it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it so the only (future) option would be to have different editor configs for "library" repos vs "non-library" repos where that setting could be different?

Copy link
Member

Choose a reason for hiding this comment

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

There's no way to have that sort of variation given the way RepoSync is implemented.

dotnet_diagnostic.CA2016.severity = error


#### .NET Coding Conventions ####

# this. and Me. preferences
Expand Down
2 changes: 1 addition & 1 deletion src/HealthCheckApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
throw new Exception("Missing URL");
}

var response = await http.GetAsync(url).ConfigureAwait(false);
var response = await http.GetAsync(url);
response.EnsureSuccessStatusCode();

if (response.Content.Headers.ContentType?.MediaType != "application/json" || response.Content.Headers.ContentLength == 0)
Expand Down
3 changes: 0 additions & 3 deletions src/ServiceControl.Config/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[*.cs]

# Justification: Application synchronization contexts don't require ConfigureAwait(false)
dotnet_diagnostic.CA2007.severity = none

# may be enabled in future
dotnet_diagnostic.PS0003.severity = none # A parameter of type CancellationToken on a non-private delegate or method should be optional
dotnet_diagnostic.PS0013.severity = none # A Func used as a method parameter with a Task, ValueTask, or ValueTask<T> return type argument should have at least one CancellationToken parameter type argument unless it has a parameter type argument implementing ICancellableContext
Expand Down
6 changes: 2 additions & 4 deletions src/ServiceControl.DomainEvents/DomainEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public async Task Raise<T>(T domainEvent, CancellationToken cancellationToken) w
{
try
{
await handler.Handle(domainEvent, cancellationToken)
.ConfigureAwait(false);
await handler.Handle(domainEvent, cancellationToken);
}
catch (Exception e)
{
Expand All @@ -35,8 +34,7 @@ await handler.Handle(domainEvent, cancellationToken)
{
try
{
await handler.Handle(domainEvent, cancellationToken)
.ConfigureAwait(false);
await handler.Handle(domainEvent, cancellationToken);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Start()
while (!tokenSource.IsCancellationRequested)
{
Print();
await Task.Delay(interval, tokenSource.Token).ConfigureAwait(false);
await Task.Delay(interval, tokenSource.Token);
}
}
catch (OperationCanceledException) when (tokenSource.IsCancellationRequested)
Expand Down
10 changes: 5 additions & 5 deletions src/ServiceControl.Infrastructure/AsyncTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public TimerJob(Func<CancellationToken, Task<TimerJobExecutionResult>> callback,
{
try
{
await Task.Delay(due, token).ConfigureAwait(false);
await Task.Delay(due, token);

while (!token.IsCancellationRequested)
{
try
{
var result = await callback(token).ConfigureAwait(false);
var result = await callback(token);
if (result == TimerJobExecutionResult.DoNotContinueExecuting)
{
tokenSource.Cancel();
}
else if (result == TimerJobExecutionResult.ScheduleNextExecution)
{
await Task.Delay(interval, token).ConfigureAwait(false);
await Task.Delay(interval, token);
}

//Otherwise execute immediately
Expand Down Expand Up @@ -64,14 +64,14 @@ public async Task Stop()
return;
}

await tokenSource.CancelAsync().ConfigureAwait(false);
await tokenSource.CancelAsync();
tokenSource.Dispose();

if (task != null)
{
try
{
await task.ConfigureAwait(false);
await task;
}
catch (OperationCanceledException) when (tokenSource.IsCancellationRequested)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceControl.Infrastructure/IntegratedSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static async Task<int> Run()
process.BeginOutputReadLine();
process.BeginErrorReadLine();

await process.WaitForExitAsync().ConfigureAwait(false);
await process.WaitForExitAsync();

return process.ExitCode;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceControl.Infrastructure/WaitHandleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static async Task<bool> WaitOneAsync(this WaitHandle handle, int millisec
tokenRegistration = cancellationToken.Register(
state => ((TaskCompletionSource<bool>)state).TrySetCanceled(),
tcs);
return await tcs.Task.ConfigureAwait(false);
return await tcs.Task;
}
finally
{
registeredHandle?.Unregister(null);
await tokenRegistration.DisposeAsync().ConfigureAwait(false);
await tokenRegistration.DisposeAsync();
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/ServiceControl.Infrastructure/Watchdog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Task Start(Action onFailedOnStartup, CancellationToken cancellationToken)
cancellationTokenSource.CancelAfter(MaxStartDurationMs);

log.Debug($"Ensuring {taskName} is running");
await ensureStarted(cancellationTokenSource.Token).ConfigureAwait(false);
await ensureStarted(cancellationTokenSource.Token);
clearFailure();
startup = false;
}
Expand All @@ -85,7 +85,7 @@ public Task Start(Action onFailedOnStartup, CancellationToken cancellationToken)
}
try
{
await Task.Delay(timeToWaitBetweenStartupAttempts, shutdownTokenSource.Token).ConfigureAwait(false);
await Task.Delay(timeToWaitBetweenStartupAttempts, shutdownTokenSource.Token);
}
catch (OperationCanceledException) when (shutdownTokenSource.IsCancellationRequested)
{
Expand All @@ -102,8 +102,8 @@ public async Task Stop(CancellationToken cancellationToken)
try
{
log.Debug($"Stopping watching process {taskName}");
await shutdownTokenSource.CancelAsync().ConfigureAwait(false);
await watchdog.ConfigureAwait(false);
await shutdownTokenSource.CancelAsync();
await watchdog;
}
catch (Exception e)
{
Expand All @@ -112,7 +112,7 @@ public async Task Stop(CancellationToken cancellationToken)
}
finally
{
await ensureStopped(cancellationToken).ConfigureAwait(false);
await ensureStopped(cancellationToken);
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/ServiceControl.Monitoring/.editorconfig

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task Initialize(CancellationToken cancellationToken)
await StartupChecks.EnsureServerVersion(store, cancellationToken);

var databaseSetup = new DatabaseSetup(settings, store);
await databaseSetup.Execute(cancellationToken).ConfigureAwait(false);
await databaseSetup.Execute(cancellationToken);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task CreateInstanceMSMQ()
// constructer of ServiceControlInstanceMetadata extracts version from zip
details.Version = Constants.CurrentVersion;

await details.Validate(s => Task.FromResult(false)).ConfigureAwait(false);
await details.Validate(s => Task.FromResult(false));
if (details.ReportCard.HasErrors)
{
throw new Exception($"Validation errors: {string.Join("\r\n", details.ReportCard.Errors)}");
Expand All @@ -95,27 +95,27 @@ public async Task ChangeConfigTests()
RemoveAltMSMQQueues();

logger.Info("Recreating the MSMQ instance");
await CreateInstanceMSMQ().ConfigureAwait(false);
await CreateInstanceMSMQ();

logger.Info("Changing the URLACL");
var msmqTestInstance = InstanceFinder.ServiceControlInstances().First(p => p.Name.Equals("Test.ServiceControl.MSMQ", StringComparison.OrdinalIgnoreCase));
msmqTestInstance.HostName = Environment.MachineName;
msmqTestInstance.Port = 33338;
msmqTestInstance.DatabaseMaintenancePort = 33339;
await installer.Update(msmqTestInstance, true).ConfigureAwait(false);
await installer.Update(msmqTestInstance, true);
Assert.That(msmqTestInstance.Service.Status, Is.EqualTo(ServiceControllerStatus.Running), "Update URL change failed");

logger.Info("Changing LogPath");
msmqTestInstance = InstanceFinder.ServiceControlInstances().First(p => p.Name.Equals("Test.ServiceControl.MSMQ", StringComparison.OrdinalIgnoreCase));
msmqTestInstance.LogPath = Path.Combine(Path.GetTempPath(), "testloggingchange");
await installer.Update(msmqTestInstance, true).ConfigureAwait(false);
await installer.Update(msmqTestInstance, true);
Assert.That(msmqTestInstance.Service.Status, Is.EqualTo(ServiceControllerStatus.Running), "Update Logging changed failed");

logger.Info("Updating Queue paths");
msmqTestInstance = InstanceFinder.ServiceControlInstances().First(p => p.Name.Equals("Test.ServiceControl.MSMQ", StringComparison.OrdinalIgnoreCase));
msmqTestInstance.AuditQueue = "alternateAudit";
msmqTestInstance.ErrorQueue = "alternateError";
await installer.Update(msmqTestInstance, true).ConfigureAwait(false);
await installer.Update(msmqTestInstance, true);
Assert.That(msmqTestInstance.Service.Status, Is.EqualTo(ServiceControllerStatus.Running), "Update Queues changed failed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task ValidateChanges()
{
try
{
await new PathsValidator(this).RunValidation(false).ConfigureAwait(false);
await new PathsValidator(this).RunValidation(false);
}
catch (EngineValidationException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public async Task Validate(Func<PathInfo, Task<bool>> promptToProceed)

try
{
ReportCard.CancelRequested = await new PathsValidator(this).RunValidation(true, promptToProceed).ConfigureAwait(false);
ReportCard.CancelRequested = await new PathsValidator(this).RunValidation(true, promptToProceed);
}
catch (EngineValidationException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public void SetupInstance()

public async Task ValidateChanges()
{
await ValidatePaths().ConfigureAwait(false);
await ValidatePaths();

ValidateQueueNames();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public async Task Validate(Func<PathInfo, Task<bool>> promptToProceed)

try
{
ReportCard.CancelRequested = await ValidatePaths(promptToProceed).ConfigureAwait(false);
ReportCard.CancelRequested = await ValidatePaths(promptToProceed);
}
catch (EngineValidationException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override async Task ValidatePaths()
{
try
{
await new PathsValidator(this).RunValidation(false).ConfigureAwait(false);
await new PathsValidator(this).RunValidation(false);
}
catch (EngineValidationException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<bool> Add(ServiceControlAuditNewInstance details, Func<PathInf
instanceInstaller.Version = Constants.CurrentVersion;

//Validation
await instanceInstaller.Validate(promptToProceed).ConfigureAwait(false);
await instanceInstaller.Validate(promptToProceed);
if (instanceInstaller.ReportCard.HasErrors)
{
foreach (var error in instanceInstaller.ReportCard.Errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<bool> Add(MonitoringNewInstance details, Func<PathInfo, Task<b
instanceInstaller.ReportCard = new ReportCard();

//Validation
await instanceInstaller.Validate(promptToProceed).ConfigureAwait(false);
await instanceInstaller.Validate(promptToProceed);
if (instanceInstaller.ReportCard.HasErrors)
{
foreach (var error in instanceInstaller.ReportCard.Errors)
Expand Down Expand Up @@ -143,7 +143,7 @@ public bool Upgrade(MonitoringInstance instance)
internal async Task<bool> Update(MonitoringInstance instance, bool startService)
{
instance.ReportCard = new ReportCard();
await instance.ValidateChanges().ConfigureAwait(false);
await instance.ValidateChanges();
if (instance.ReportCard.HasErrors)
{
foreach (var error in instance.ReportCard.Errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<bool> Add(ServiceControlNewInstance details, Func<PathInfo, Ta
instanceInstaller.Version = Constants.CurrentVersion;

//Validation
await instanceInstaller.Validate(promptToProceed).ConfigureAwait(false);
await instanceInstaller.Validate(promptToProceed);

if (instanceInstaller.ReportCard.HasErrors)
{
Expand Down Expand Up @@ -147,7 +147,7 @@ public bool Upgrade(ServiceControlInstance instance, ServiceControlUpgradeOption
internal async Task<bool> Update(ServiceControlInstance instance, bool startService)
{
instance.ReportCard = new ReportCard();
await instance.ValidateChanges().ConfigureAwait(false);
await instance.ValidateChanges();
if (instance.ReportCard.HasErrors)
{
return false;
Expand Down
Loading