From e0e1e047b98147b185effc922558a2c5876201de Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 4 Aug 2021 12:23:44 -0700 Subject: [PATCH] Force xunit to display diagnostics for a non-empty collection --- .../PInvokeGeneratorTest.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs index 1e0cd713..948ff4c9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. - using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; +using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using ClangSharp.Interop; @@ -75,7 +75,19 @@ private static async Task ValidateGeneratedBindingsAsync(string inputContents, s if (expectedDiagnostics is null) { - Assert.Empty(pinvokeGenerator.Diagnostics); + var diagnostics = new StringBuilder(); + + foreach (var diagnostic in pinvokeGenerator.Diagnostics) + { + diagnostics = diagnostics.AppendLine(diagnostic.ToString()); + } + + var diagnosticsString = diagnostics.ToString(); + + if (!string.IsNullOrEmpty(diagnosticsString)) + { + throw new System.Exception(diagnosticsString); + } } else {