diff --git a/src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildConsumer.cs b/src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildConsumer.cs index c928b461ad..eef95642b8 100644 --- a/src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildConsumer.cs +++ b/src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildConsumer.cs @@ -200,8 +200,8 @@ private async Task HandleFailuresAsync(string testDisplayName, bool isCanceled, { _totalTests++; _totalFailedTests++; - ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks != null); - ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks.PipeClient != null); + ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks is not null); + ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks.PipeClient is not null); var failedTestInfoRequest = new FailedTestInfoRequest(testDisplayName, isCanceled, duration, errorMessage, errorStackTrace, expected, actual, codeFilePath, lineNumber); await _msBuildTestApplicationLifecycleCallbacks.PipeClient.RequestReplyAsync(failedTestInfoRequest, cancellationToken).ConfigureAwait(false); } @@ -210,8 +210,8 @@ private async Task HandleSummaryAsync(TimeSpan elapsed, CancellationToken cancel { string? duration = ToHumanReadableDuration(elapsed.TotalMilliseconds); - ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks != null); - ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks.PipeClient != null); + ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks is not null); + ApplicationStateGuard.Ensure(_msBuildTestApplicationLifecycleCallbacks.PipeClient is not null); bool allowSkipped = PlatformCommandLineProvider.GetZeroTestsPolicy(_commandLineOptions) == ZeroTestsPolicy.AllowSkipped; var runSummaryInfoRequest = new RunSummaryInfoRequest(_totalTests, _totalFailedTests, _totalPassedTests, _totalSkippedTests, duration, allowSkipped); await _msBuildTestApplicationLifecycleCallbacks.PipeClient.RequestReplyAsync(runSummaryInfoRequest, cancellationToken).ConfigureAwait(false); diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.TestNodeSerializers.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.TestNodeSerializers.cs index b20a8c2ab6..7bb40c5c95 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.TestNodeSerializers.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.TestNodeSerializers.cs @@ -175,7 +175,7 @@ private static void RegisterTestNodeSerializers() properties["execution-state"] = "failed"; properties["error.message"] = failedTestNodeStateProperty.Explanation ?? failedTestNodeStateProperty.Exception?.Message; Exception? exception = failedTestNodeStateProperty.Exception; - if (exception != null) + if (exception is not null) { properties["error.stacktrace"] = exception.StackTrace ?? string.Empty; } @@ -188,7 +188,7 @@ private static void RegisterTestNodeSerializers() properties["assert.actual"] = assertionFailure.Actual ?? string.Empty; properties["assert.expected"] = assertionFailure.Expected ?? string.Empty; } - else if (exception != null) + else if (exception is not null) { properties["assert.actual"] = exception.Data["assert.actual"] ?? string.Empty; properties["assert.expected"] = exception.Data["assert.expected"] ?? string.Empty; @@ -201,7 +201,7 @@ private static void RegisterTestNodeSerializers() { properties["execution-state"] = "timed-out"; properties["error.message"] = timeoutTestNodeStateProperty.Explanation ?? timeoutTestNodeStateProperty.Exception?.Message; - if (timeoutTestNodeStateProperty.Exception != null) + if (timeoutTestNodeStateProperty.Exception is not null) { properties["error.stacktrace"] = timeoutTestNodeStateProperty.Exception.StackTrace ?? string.Empty; } @@ -213,7 +213,7 @@ private static void RegisterTestNodeSerializers() { properties["execution-state"] = "error"; properties["error.message"] = errorTestNodeStateProperty.Explanation ?? errorTestNodeStateProperty.Exception?.Message; - if (errorTestNodeStateProperty.Exception != null) + if (errorTestNodeStateProperty.Exception is not null) { properties["error.stacktrace"] = errorTestNodeStateProperty.Exception.StackTrace ?? string.Empty; } @@ -227,7 +227,7 @@ private static void RegisterTestNodeSerializers() { properties["execution-state"] = "canceled"; properties["error.message"] = canceledTestNodeStateProperty.Explanation ?? canceledTestNodeStateProperty.Exception?.Message; - if (canceledTestNodeStateProperty.Exception != null) + if (canceledTestNodeStateProperty.Exception is not null) { properties["error.stacktrace"] = canceledTestNodeStateProperty.Exception.StackTrace ?? string.Empty; }