diff --git a/src/Test/Utilities/Desktop/TestUtilities.Desktop.csproj b/src/Test/Utilities/Desktop/TestUtilities.Desktop.csproj index 51356bacd247d34fef9e586f2814b935c3b80e30..598b6a17f8479958a5ec5abf32f1d885ae17095d 100644 --- a/src/Test/Utilities/Desktop/TestUtilities.Desktop.csproj +++ b/src/Test/Utilities/Desktop/TestUtilities.Desktop.csproj @@ -124,7 +124,7 @@ True TestResource.resx - + diff --git a/src/Test/Utilities/Desktop/ThrowingTraceListener.cs b/src/Test/Utilities/Desktop/ThrowingTraceListener.cs new file mode 100644 index 0000000000000000000000000000000000000000..89b10efd94d38857f178c52fd539aa1913de5c3c --- /dev/null +++ b/src/Test/Utilities/Desktop/ThrowingTraceListener.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Diagnostics; +using Xunit; + +namespace Microsoft.CodeAnalysis +{ + // To enable this for a process, add the following to the app.config for the project: + // + // + // + // + // + // + // + // + // + // + // + public sealed class ThrowingTraceListener : TraceListener + { + public override void Fail(string message, string detailMessage) + { + throw new DebugAssertFailureException(message + Environment.NewLine + detailMessage); + } + + public override void Write(string message) + { + } + + public override void WriteLine(string message) + { + } + + [Serializable] + public class DebugAssertFailureException : Exception + { + public DebugAssertFailureException() { } + public DebugAssertFailureException(string message) : base(message) { } + public DebugAssertFailureException(string message, Exception inner) : base(message, inner) { } + protected DebugAssertFailureException( + System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext context) : base(info, context) + { } + } + } +} diff --git a/src/Test/Utilities/Desktop/TraceListener.cs b/src/Test/Utilities/Desktop/TraceListener.cs deleted file mode 100644 index 8935f64af26080e8c6c8ad675a9013cdad46bdbb..0000000000000000000000000000000000000000 --- a/src/Test/Utilities/Desktop/TraceListener.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Diagnostics; - -namespace Microsoft.CodeAnalysis -{ -#if DEBUG - // To enable, add to in *.exe.config, specifying the assembly-qualified - // type name with optional initializeData="..." for .ctor args. For instance: - // - // - // - // - // - // - // - // - // - // - public sealed class TraceListener : System.Diagnostics.TraceListener - { - private readonly bool _continueOnFailure; - - public TraceListener() - { - } - - public TraceListener(bool continueOnFailure) - { - _continueOnFailure = continueOnFailure; - } - - public override void Fail(string message, string detailMessage) - { - // Tools currently depend on the prefix appearing as an exception. - WriteLine(new AssertFailureException(string.Format("{0}\r\n{1}", message, detailMessage))); - WriteLine(new StackTrace(fNeedFileInfo: true)); - if (!_continueOnFailure) - { - Environment.Exit(-1); - } - } - - public override void Write(string message) - { - Console.Write(message); - } - - public override void WriteLine(string message) - { - Console.WriteLine(message); - } - } - - public sealed class ThrowingTraceListener : System.Diagnostics.TraceListener - { - public override void Fail(string message, string detailMessage) - { - throw new AssertFailureException(string.Format("{0}\r\n{1}", message, detailMessage)); - } - - public override void Write(string message) - { - Console.Write(message); - } - - public override void WriteLine(string message) - { - Console.WriteLine(message); - } - } - - public sealed class AssertFailureException : Exception - { - public AssertFailureException(string message) : base(message) { } - } -#endif -}