diff --git a/src/Abstractions/ExecutionContext/BaseExecutionContext.cs b/src/Abstractions/ExecutionContext/BaseExecutionContext.cs index 8432259d..1da02b8b 100644 --- a/src/Abstractions/ExecutionContext/BaseExecutionContext.cs +++ b/src/Abstractions/ExecutionContext/BaseExecutionContext.cs @@ -40,7 +40,7 @@ namespace Microsoft.Omex.Extensions.Abstractions.ExecutionContext BuildVersion = GetBuildVersion(); ClusterIpAddress = GetIpAddress(MachineName); - + RegionName = GetVariable(RegionNameVariableName) ?? DefaultEmptyValue; DeploymentSlice = GetVariable(SliceNameVariableName) ?? DefaultEmptyValue; diff --git a/src/Diagnostics.HealthChecks/DependencyInjection/OmexHealthCheckServiceCollectionExtensions.cs b/src/Diagnostics.HealthChecks/DependencyInjection/OmexHealthCheckServiceCollectionExtensions.cs index 72bf12f8..79a65627 100644 --- a/src/Diagnostics.HealthChecks/DependencyInjection/OmexHealthCheckServiceCollectionExtensions.cs +++ b/src/Diagnostics.HealthChecks/DependencyInjection/OmexHealthCheckServiceCollectionExtensions.cs @@ -46,14 +46,7 @@ public static class OmexHealthCheckServiceCollectionExtensions /// public static bool TryRemoveServiceByPredicate(this IServiceCollection @this, Func predicate) { - - /* Unmerged change from project 'Microsoft.Omex.Extensions.Diagnostics.HealthChecks(netstandard2.0)' - Before: - var descriptorToRemove = @this.SingleOrDefault(predicate); - After: - ServiceDescriptor descriptorToRemove = @this.SingleOrDefault(predicate); - */ - ServiceDescriptor? descriptorToRemove = @this.SingleOrDefault(predicate); + var descriptorToRemove = @this.SingleOrDefault(predicate); if (descriptorToRemove != null) { return @this.Remove(descriptorToRemove); diff --git a/src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs b/src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs index 48763fdb..f8298aba 100644 --- a/src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs +++ b/src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs @@ -83,7 +83,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks } #if !NETCOREAPP3_1 && !NETSTANDARD2_0 - clone.VersionPolicy = message.VersionPolicy; + clone.VersionPolicy = message.VersionPolicy; foreach (KeyValuePair option in message.Options) { diff --git a/src/Diagnostics.HealthChecks/Internal/NonCapturingTimer.cs b/src/Diagnostics.HealthChecks/Internal/NonCapturingTimer.cs index 18c8436a..3ebca955 100644 --- a/src/Diagnostics.HealthChecks/Internal/NonCapturingTimer.cs +++ b/src/Diagnostics.HealthChecks/Internal/NonCapturingTimer.cs @@ -23,7 +23,7 @@ internal static class NonCapturingTimer } // Don't capture the current ExecutionContext and its AsyncLocals onto the timer - bool restoreFlow = false; + var restoreFlow = false; try { if (!ExecutionContext.IsFlowSuppressed()) diff --git a/src/Diagnostics.HealthChecks/Internal/ServiceContextHealthStatusSender.cs b/src/Diagnostics.HealthChecks/Internal/ServiceContextHealthStatusSender.cs index f3160f3a..2e1b36af 100644 --- a/src/Diagnostics.HealthChecks/Internal/ServiceContextHealthStatusSender.cs +++ b/src/Diagnostics.HealthChecks/Internal/ServiceContextHealthStatusSender.cs @@ -3,12 +3,12 @@ using System; using System.Fabric; -using System.Fabric.Health; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; using Microsoft.Omex.Extensions.Abstractions; +using System.Fabric.Health; namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks { diff --git a/src/Diagnostics.HealthChecks/Internal/ValueStopwatch.cs b/src/Diagnostics.HealthChecks/Internal/ValueStopwatch.cs index c3f5f524..fcc65874 100644 --- a/src/Diagnostics.HealthChecks/Internal/ValueStopwatch.cs +++ b/src/Diagnostics.HealthChecks/Internal/ValueStopwatch.cs @@ -34,9 +34,9 @@ internal struct ValueStopwatch throw new InvalidOperationException("An uninitialized, or 'default', ValueStopwatch cannot be used to get elapsed time."); } - long end = Stopwatch.GetTimestamp(); - long timestampDelta = end - _startTimestamp; - long ticks = (long)(TimestampToTicks * timestampDelta); + var end = Stopwatch.GetTimestamp(); + var timestampDelta = end - _startTimestamp; + var ticks = (long)(TimestampToTicks * timestampDelta); return new TimeSpan(ticks); } } diff --git a/src/Diagnostics.HealthChecks/OmexHealthCheckPublisherHostedService.cs b/src/Diagnostics.HealthChecks/OmexHealthCheckPublisherHostedService.cs index 3f571528..ec16ba21 100644 --- a/src/Diagnostics.HealthChecks/OmexHealthCheckPublisherHostedService.cs +++ b/src/Diagnostics.HealthChecks/OmexHealthCheckPublisherHostedService.cs @@ -88,7 +88,7 @@ internal sealed partial class OmexHealthCheckPublisherHostedService : IHostedSer // actually tries to **run** health checks would be real baaaaad. ValidateRegistrations(_healthCheckServiceOptions.Value.Registrations); - _defaultTimerOptions = (_healthCheckPublisherOptions.Value.Delay, _healthCheckPublisherOptions.Value.Period, _healthCheckPublisherOptions.Value.Timeout); + _defaultTimerOptions = (_healthCheckPublisherOptions.Value.Delay, _healthCheckPublisherOptions.Value.Period, _healthCheckPublisherOptions.Value.Timeout); // Group healthcheck registrations by Delay, Period and Timeout, to build a Dictionary<(TimeSpan, TimeSpan, TimeSpan), List> // For HCs with no Delay, Period or Timeout, we default to the publisher values diff --git a/src/Hosting.Services.Web/ApplicationBuilderExtensions.cs b/src/Hosting.Services.Web/ApplicationBuilderExtensions.cs index 6d02938c..2de6de0d 100644 --- a/src/Hosting.Services.Web/ApplicationBuilderExtensions.cs +++ b/src/Hosting.Services.Web/ApplicationBuilderExtensions.cs @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Builder /// public static IApplicationBuilder UseOmexExceptionHandler(this IApplicationBuilder builder, IHostEnvironment environment) => builder.UseOmexExceptionHandler(environment.IsDevelopment()); - + /// /// Adds the default exception handling logic that will display a developer exception page in develop and a short message during deployment /// diff --git a/src/Hosting.Services.Web/Middlewares/ObsoleteCorrelationHeadersMiddleware.cs b/src/Hosting.Services.Web/Middlewares/ObsoleteCorrelationHeadersMiddleware.cs index ca693229..73023679 100644 --- a/src/Hosting.Services.Web/Middlewares/ObsoleteCorrelationHeadersMiddleware.cs +++ b/src/Hosting.Services.Web/Middlewares/ObsoleteCorrelationHeadersMiddleware.cs @@ -125,7 +125,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.Middlewares private static readonly string[] s_officeClientQueryParameters = { "client", // Identifies the client application and platform "av", // Identifies the client application, platform and partial version - "app" }; // Identifies the client application + "app" }; // Identifies the client application private const string CorrelationHeader = "X-CorrelationId"; diff --git a/src/Logging/InitializationLogger.cs b/src/Logging/InitializationLogger.cs index 811d9459..5f82e8dc 100644 --- a/src/Logging/InitializationLogger.cs +++ b/src/Logging/InitializationLogger.cs @@ -19,7 +19,7 @@ namespace Microsoft.Omex.Extensions.Logging /// public static ILogger Instance { get; private set; } = LoggerFactory.Create(builder => { - builder.LoadInitializationLogger(); + builder.LoadInitializationLogger(); }).CreateLogger("Initial-Logging"); private static ILoggingBuilder LoadInitializationLogger(this ILoggingBuilder builder) @@ -56,7 +56,7 @@ namespace Microsoft.Omex.Extensions.Logging /// Service name for logging /// Exception to log /// Message to log - public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "") + public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "") { ServiceInitializationEventSource.Instance.LogHostFailed(ex?.ToString() ?? string.Empty, serviceNameForLogging, message); Instance.LogError(Tag.Create(), ex, message); diff --git a/tests/Activities.UnitTests/Internal/DefaultActivityListenerConfiguratorTests.cs b/tests/Activities.UnitTests/Internal/DefaultActivityListenerConfiguratorTests.cs index 363afebd..fef3aeed 100644 --- a/tests/Activities.UnitTests/Internal/DefaultActivityListenerConfiguratorTests.cs +++ b/tests/Activities.UnitTests/Internal/DefaultActivityListenerConfiguratorTests.cs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Diagnostics; -using Microsoft.Extensions.Options; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; using Moq; +using Microsoft.Extensions.Options; namespace Microsoft.Omex.Extensions.Activities.UnitTests { diff --git a/tests/Activities.UnitTests/ServiceCollectionTests.cs b/tests/Activities.UnitTests/ServiceCollectionTests.cs index 323376da..b5cd0aa4 100644 --- a/tests/Activities.UnitTests/ServiceCollectionTests.cs +++ b/tests/Activities.UnitTests/ServiceCollectionTests.cs @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics; +using System; +using Microsoft.Omex.Extensions.Abstractions.Activities.Processing; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Omex.Extensions.Abstractions.Activities.Processing; using Microsoft.Omex.Extensions.Testing.Helpers; -using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Microsoft.Omex.Extensions.Activities.UnitTests { diff --git a/tests/Diagnostics.HealthChecks.UnitTests/Extensions/TaskExtensions.cs b/tests/Diagnostics.HealthChecks.UnitTests/Extensions/TaskExtensions.cs index 1bb30b36..c707f099 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/Extensions/TaskExtensions.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/Extensions/TaskExtensions.cs @@ -8,8 +8,8 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Threading; using System.Threading.Tasks; +using System.Threading; namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests.Extensions { @@ -41,7 +41,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests.Extension throw new TimeoutException(CreateMessage(timeout, filePath, lineNumber)); } #else - CancellationTokenSource cts = new CancellationTokenSource(); + var cts = new CancellationTokenSource(); if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token)).ConfigureAwait(false)) { cts.Cancel(); diff --git a/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherHostedServiceTests.cs b/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherHostedServiceTests.cs index 69f95c5f..c379be5c 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherHostedServiceTests.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherHostedServiceTests.cs @@ -28,9 +28,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task StartAsync_WithoutPublishers_DoesNotStartTimer() { // Arrange - IHealthCheckPublisher[] publishers = Array.Empty(); + var publishers = Array.Empty(); - OmexHealthCheckPublisherHostedService service = CreateService(publishers); + var service = CreateService(publishers); try { @@ -53,12 +53,12 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task StartAsync_WithPublishers_StartsTimer() { // Arrange - IHealthCheckPublisher[] publishers = new IHealthCheckPublisher[] + var publishers = new IHealthCheckPublisher[] { new TestPublisher(), }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers); + var service = CreateService(publishers); try { @@ -81,11 +81,11 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task StartAsync_WithPublishers_StartsTimer_RunsPublishers() { // Arrange - TaskCompletionSource unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TaskCompletionSource unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TaskCompletionSource unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock0.Task, }, new TestPublisher() { Wait = unblock1.Task, }, @@ -126,9 +126,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task StopAsync_CancelsExecution() { // Arrange - TaskCompletionSource unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock.Task, } }; @@ -140,7 +140,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await service.StartAsync(); // Start execution - Task running = service.RunAsync(); + var running = service.RunAsync(); // Wait for the publisher to see the cancellation token await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); @@ -170,9 +170,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_WaitsForCompletion_Single() { // Arrange - TaskCompletionSource unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock.Task, }, }; @@ -184,7 +184,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await service.StartAsync(); // Act - Task running = service.RunAsync(); + var running = service.RunAsync(); await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); @@ -196,10 +196,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests Assert.IsTrue(service.IsTimerRunning); Assert.IsFalse(service.IsStopping); - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { Assert.IsTrue(publishers[i].Entries.Count == 1); - HealthReport report = publishers[i].Entries.Single().report; + var report = publishers[i].Entries.Single().report; CollectionAssert.AreEqual(new[] { "one", "two", }, report.Entries.Keys.OrderBy(k => k).ToArray()); } } @@ -217,15 +217,15 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests // Arrange const string HealthyMessage = "Everything is A-OK"; - TaskCompletionSource unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TaskCompletionSource unblockDelayedCheck = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblockDelayedCheck = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock.Task, }, }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers, configureBuilder: b => + var service = CreateService(publishers, configureBuilder: b => { b.AddAsyncCheck("CheckDefault", _ => { @@ -264,7 +264,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await service.StartAsync(); // Act - Task running = service.RunAsync(); + var running = service.RunAsync(); await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); @@ -278,10 +278,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests Assert.IsTrue(service.IsTimerRunning); Assert.IsFalse(service.IsStopping); - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { Assert.IsTrue(publishers[i].Entries.Count == 4); - string[] entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray(); + var entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray(); CollectionAssert.AreEqual( new[] { "CheckDefault", "CheckDelay2Period18", "CheckDelay7Period11", "CheckDelay9Period5" }, entries); @@ -299,11 +299,11 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_WaitsForCompletion_Multiple() { // Arrange - TaskCompletionSource unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TaskCompletionSource unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TaskCompletionSource unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock0.Task, }, new TestPublisher() { Wait = unblock1.Task, }, @@ -317,7 +317,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await service.StartAsync(); // Act - Task running = service.RunAsync(); + var running = service.RunAsync(); await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); await publishers[1].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); @@ -333,10 +333,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests Assert.IsTrue(service.IsTimerRunning); Assert.IsFalse(service.IsStopping); - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { Assert.IsTrue(publishers[i].Entries.Count == 1); - HealthReport report = publishers[i].Entries.Single().report; + var report = publishers[i].Entries.Single().report; CollectionAssert.AreEqual(new[] { "one", "two", }, report.Entries.Keys.OrderBy(k => k).ToArray()); } } @@ -352,21 +352,21 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_PublishersCanTimeout() { // Arrange - TaskCompletionSource unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Wait = unblock.Task, }, }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers); + var service = CreateService(publishers); try { await service.StartAsync(); // Act - Task running = service.RunAsync(); + var running = service.RunAsync(); await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10)); @@ -394,13 +394,13 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_CanFilterHealthChecks() { // Arrange - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher(), new TestPublisher(), }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers, configurePublisherOptions: (options) => + var service = CreateService(publishers, configurePublisherOptions: (options) => { options.Predicate = (r) => r.Name == "one"; }); @@ -413,10 +413,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await service.RunAsync().TimeoutAfter(TimeSpan.FromSeconds(10)); // Assert - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { Assert.IsTrue(publishers[i].Entries.Count == 1); - HealthReport report = publishers[i].Entries.Single().report; + var report = publishers[i].Entries.Single().report; CollectionAssert.AreEqual(new[] { "one" }, report.Entries.Keys.OrderBy(k => k).ToArray()); } } @@ -434,15 +434,15 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests // Arrange const string HealthyMessage = "Everything is A-OK"; - TaskCompletionSource unblockDelayedCheck = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblockDelayedCheck = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher(), new TestPublisher(), }; - OmexHealthCheckPublisherHostedService service = CreateService( + var service = CreateService( publishers, configurePublisherOptions: (options) => { @@ -492,9 +492,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests await unblockDelayedCheck.Task; // Assert - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { - string[] entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray(); + var entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray(); Assert.IsTrue(entries.Count() == 3); CollectionAssert.AreEqual( @@ -514,12 +514,12 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_HandlesExceptions() { // Arrange - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Exception = new InvalidTimeZoneException(), }, }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers); + var service = CreateService(publishers); try { @@ -541,14 +541,14 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests public async Task RunAsync_HandlesExceptions_Multiple() { // Arrange - TestPublisher[] publishers = new TestPublisher[] + var publishers = new TestPublisher[] { new TestPublisher() { Exception = new InvalidTimeZoneException(), }, new TestPublisher(), new TestPublisher() { Exception = new InvalidTimeZoneException(), }, }; - OmexHealthCheckPublisherHostedService service = CreateService(publishers); + var service = CreateService(publishers); try { @@ -597,7 +597,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests if (publishers != null) { - for (int i = 0; i < publishers.Length; i++) + for (var i = 0; i < publishers.Length; i++) { serviceCollection.AddSingleton(publishers[i]); } @@ -608,7 +608,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests serviceCollection.Configure(configurePublisherOptions); } - ServiceProvider services = serviceCollection.BuildServiceProvider(); + var services = serviceCollection.BuildServiceProvider(); return services.GetServices().OfType().Single(); } diff --git a/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherTests.cs b/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherTests.cs index d2cf54e1..07d89b08 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherTests.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/OmexHealthCheckPublisherTests.cs @@ -122,19 +122,19 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests private static PublisherContext CreatePublisher(bool canInitizlize = true) { - Dictionary reportedState = new(); - Mock mockSender = new(); + Dictionary reportedState = new (); + Mock mockSender = new (); mockSender.Setup(s => s.IntializeAsync(It.IsAny())).Returns(Task.FromResult(canInitizlize)); mockSender.Setup(s_sendStatusExpression) .Callback((string name, HealthStatus status, string description, CancellationToken token) => reportedState[name] = new HealthStateInfo(status, description)) .Returns(Task.CompletedTask); - OmexHealthCheckPublisher publisher = new( + OmexHealthCheckPublisher publisher = new ( mockSender.Object, new DefaultObjectPoolProvider()); - return new(publisher, mockSender, reportedState); + return new (publisher, mockSender, reportedState); } private record PublisherContext( diff --git a/tests/Diagnostics.HealthChecks.UnitTests/RestHealthStatusSenderTests.cs b/tests/Diagnostics.HealthChecks.UnitTests/RestHealthStatusSenderTests.cs index 5151f2de..e35f0199 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/RestHealthStatusSenderTests.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/RestHealthStatusSenderTests.cs @@ -97,7 +97,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests Mock mockContext = new(); mockContext.SetupGet(c => c.NodeName).Returns("TestNodeName"); - RestHealthStatusSender sender = new(sfClientWrapper.Object, mockContext.Object); + RestHealthStatusSender sender = new (sfClientWrapper.Object, mockContext.Object); return new SenderInfo(sender, sfClientWrapper, reportedState); } diff --git a/tests/Diagnostics.HealthChecks.UnitTests/ServiceContextHealthStatusSenderTests.cs b/tests/Diagnostics.HealthChecks.UnitTests/ServiceContextHealthStatusSenderTests.cs index 35a8f6b2..6a4a046a 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/ServiceContextHealthStatusSenderTests.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/ServiceContextHealthStatusSenderTests.cs @@ -4,13 +4,13 @@ using System; using System.Collections.Generic; using System.Fabric; -using System.Fabric.Health; using System.Threading.Tasks; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Omex.Extensions.Abstractions.Accessors; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; +using System.Fabric.Health; namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests { @@ -171,7 +171,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests reportedState[info.Property] = info; })); - + return new SenderContext(partitionMock, reportedState); } diff --git a/tests/Hosting.UnitTests/CertificateReaderTests.cs b/tests/Hosting.UnitTests/CertificateReaderTests.cs index 91e9687c..c20ec1d4 100644 --- a/tests/Hosting.UnitTests/CertificateReaderTests.cs +++ b/tests/Hosting.UnitTests/CertificateReaderTests.cs @@ -175,8 +175,7 @@ namespace Microsoft.Omex.Extensions.Hosting.UnitTests { storeMock.Verify(expression, times, message); storeMock.Invocations.Clear(); - } - ); + }); } } } diff --git a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs index d8d6cc17..0f622ef5 100644 --- a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs +++ b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs @@ -133,7 +133,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests.Scrubbing public void AddRegexLogScrubbingRule_Scrubs(string input, string expected) { ILoggingBuilder builder2 = new MockLoggingBuilder() - .AddRegexLogScrubbingRule(Regex, "REDACTED&"); + .AddRegexLogScrubbingRule(Regex,"REDACTED&"); ILogScrubbingRule[] logScrubbingRules = GetTypeRegistrations(builder2.Services); diff --git a/tests/Logging.UnitTests/TagExtensionsTests.cs b/tests/Logging.UnitTests/TagExtensionsTests.cs index a5598cea..01d1929d 100644 --- a/tests/Logging.UnitTests/TagExtensionsTests.cs +++ b/tests/Logging.UnitTests/TagExtensionsTests.cs @@ -19,7 +19,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests [DataRow(int.MaxValue, "\u007f???")] public void TagIdAsString_ConvertsProperly(int tagId, string expected) { -#pragma warning disable 618 +# pragma warning disable 618 Assert.AreEqual(expected, new EventId(tagId).ToTagId()); #pragma warning restore 618 }