From 965bb34a59f81054c02295d655c813d5b24e1627 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Tue, 10 Dec 2024 15:17:56 -0800 Subject: [PATCH] Move NoAssertContext to Core test utilities This will allow it to be used in WPF as well. --- src/Common/tests/TestUtilities/GlobalUsings.cs | 1 + src/Common/tests/TestUtilities/ModuleInitializer.cs | 1 - .../tests/TestUtilities/NoAssertContext.cs | 2 -- src/Common/tests/TestUtilities/ThrowingTraceListener.cs | 7 +++---- .../tests/TestUtilities/GlobalUsings.cs | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) rename src/{System.Windows.Forms.Primitives => Common}/tests/TestUtilities/NoAssertContext.cs (99%) diff --git a/src/Common/tests/TestUtilities/GlobalUsings.cs b/src/Common/tests/TestUtilities/GlobalUsings.cs index 581f24df927..55d86a67182 100644 --- a/src/Common/tests/TestUtilities/GlobalUsings.cs +++ b/src/Common/tests/TestUtilities/GlobalUsings.cs @@ -1,5 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; global using Xunit; diff --git a/src/Common/tests/TestUtilities/ModuleInitializer.cs b/src/Common/tests/TestUtilities/ModuleInitializer.cs index 2cb757018d6..bad5b308b0d 100644 --- a/src/Common/tests/TestUtilities/ModuleInitializer.cs +++ b/src/Common/tests/TestUtilities/ModuleInitializer.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; using System.Runtime.CompilerServices; namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs b/src/Common/tests/TestUtilities/NoAssertContext.cs similarity index 99% rename from src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs rename to src/Common/tests/TestUtilities/NoAssertContext.cs index dcf564ddf77..67d29efae30 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs +++ b/src/Common/tests/TestUtilities/NoAssertContext.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#nullable enable - using System.Collections.Concurrent; namespace System; diff --git a/src/Common/tests/TestUtilities/ThrowingTraceListener.cs b/src/Common/tests/TestUtilities/ThrowingTraceListener.cs index f85b1a03788..6f9b0a9111c 100644 --- a/src/Common/tests/TestUtilities/ThrowingTraceListener.cs +++ b/src/Common/tests/TestUtilities/ThrowingTraceListener.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; - namespace System; public sealed class ThrowingTraceListener : TraceListener @@ -12,8 +10,9 @@ public sealed class ThrowingTraceListener : TraceListener public override void Fail(string? message, string? detailMessage) { throw new InvalidOperationException( - (string.IsNullOrEmpty(message) ? "Assertion failed" : message) + - (string.IsNullOrEmpty(detailMessage) ? "" : Environment.NewLine + detailMessage)); + $"{(string.IsNullOrEmpty(message) ? "Assertion failed" : message)}{(string.IsNullOrEmpty(detailMessage) + ? "" + : $"{Environment.NewLine}{detailMessage}")}"); } public override void Write(object? o) diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs index f5e1f631fa7..7839656bf50 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; global using Windows.Win32; global using Windows.Win32.Foundation;