From b8294daf4bfa75fb2e33d7d732dc6df2cdc78974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 19 Jan 2024 19:25:36 +0100 Subject: [PATCH] Remove xunit-specific Rosyln analyzer testing packages (#97220) Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.Xunit brings in an older xunit reference that is not compatible in some cases, we've hit issues with it while upgrading our xunit reference in the past. As mentioned in https://github.com/dotnet/roslyn-sdk/issues/1099#issuecomment-1723487931 we can use the generic testing package instead. The only difference is the exception type thrown when an assert fails, e.g. the test throws `InvalidOperationException` instead of `Xunit.Sdk.EqualException` but we still get actual vs. expected exception messages so this is enough for us. --- .../CSharpAnalyzerVerifier`1+Test.cs | 3 +-- .../CSharpAnalyzerVerifier`1.cs | 7 +++---- .../IntrinsicsInSystemPrivateCoreLib.Tests.csproj | 6 +++--- .../JSImportGenerator.Unit.Tests.csproj | 4 ++-- .../ComInterfaceGenerator.Unit.Tests.csproj | 6 +++--- .../tests/Common/Verifiers/CSharpAnalyzerVerifier.cs | 8 ++++---- .../tests/Common/Verifiers/CSharpCodeFixVerifier.cs | 10 ++++------ .../Common/Verifiers/CSharpSourceGeneratorVerifier.cs | 3 +-- .../LibraryImportGenerator.Unit.Tests.csproj | 6 +++--- .../tests/FunctionalTests/CSharpCodeFixVerifier`2.cs | 3 +-- .../System.Text.RegularExpressions.Tests.csproj | 2 +- .../ILLink.RoslynAnalyzer.Tests.csproj | 4 ++-- .../Verifiers/CSharpAnalyzerVerifier`1.cs | 9 ++++----- .../Verifiers/CSharpCodeFixVerifier`2.cs | 3 +-- 14 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs index fb8a08a8c4905..73b0db166d8c0 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs @@ -1,14 +1,13 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace IntrinsicsInSystemPrivateCoreLib.Test { public static partial class CSharpAnalyzerVerifier where TAnalyzer : DiagnosticAnalyzer, new() { - public class Test : CSharpAnalyzerTest + public class Test : CSharpAnalyzerTest { public Test() { diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1.cs b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1.cs index 6677ef554399b..03c25089895e1 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1.cs +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1.cs @@ -2,7 +2,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; using System.Threading; using System.Threading.Tasks; @@ -13,15 +12,15 @@ public static partial class CSharpAnalyzerVerifier { /// public static DiagnosticResult Diagnostic() - => CSharpAnalyzerVerifier.Diagnostic(); + => CSharpAnalyzerVerifier.Diagnostic(); /// public static DiagnosticResult Diagnostic(string diagnosticId) - => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); + => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); /// public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => CSharpAnalyzerVerifier.Diagnostic(descriptor); + => CSharpAnalyzerVerifier.Diagnostic(descriptor); /// public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj index 62859b1fbbad0..594def676a1ad 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/JSImportGenerator.Unit.Tests.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/JSImportGenerator.Unit.Tests.csproj index 70e76ba4e5842..076244c304bb8 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/JSImportGenerator.Unit.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/JSImportGenerator.Unit.Tests.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/ComInterfaceGenerator.Unit.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/ComInterfaceGenerator.Unit.Tests.csproj index beda4af3a7228..635669006eb25 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/ComInterfaceGenerator.Unit.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/ComInterfaceGenerator.Unit.Tests.csproj @@ -25,9 +25,9 @@ - - - + + + diff --git a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpAnalyzerVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpAnalyzerVerifier.cs index 08e29e3a5a2fb..79c12e1d0de62 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpAnalyzerVerifier.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Testing.XUnit; +using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; @@ -15,15 +15,15 @@ public static class CSharpAnalyzerVerifier { /// public static DiagnosticResult Diagnostic() - => AnalyzerVerifier.Diagnostic(); + => CSharpAnalyzerVerifier.Diagnostic(); /// public static DiagnosticResult Diagnostic(string diagnosticId) - => AnalyzerVerifier.Diagnostic(diagnosticId); + => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); /// public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => AnalyzerVerifier.Diagnostic(descriptor); + => CSharpAnalyzerVerifier.Diagnostic(descriptor); /// public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) diff --git a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpCodeFixVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpCodeFixVerifier.cs index b63dffca7fa66..cc815fb1c2495 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpCodeFixVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpCodeFixVerifier.cs @@ -10,10 +10,8 @@ using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.CSharp.Testing.XUnit; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace Microsoft.Interop.UnitTests.Verifiers { @@ -23,15 +21,15 @@ public static class CSharpCodeFixVerifier { /// public static DiagnosticResult Diagnostic() - => CodeFixVerifier.Diagnostic(); + => CSharpCodeFixVerifier.Diagnostic(); /// public static DiagnosticResult Diagnostic(string diagnosticId) - => CodeFixVerifier.Diagnostic(diagnosticId); + => CSharpCodeFixVerifier.Diagnostic(diagnosticId); /// public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => CodeFixVerifier.Diagnostic(descriptor); + => CSharpCodeFixVerifier.Diagnostic(descriptor); /// /// Create a with the diagnostic message created with the provided arguments. @@ -109,7 +107,7 @@ public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] ex await test.RunAsync(CancellationToken.None); } - internal class Test : CSharpCodeFixTest + internal class Test : CSharpCodeFixTest { public Test() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpSourceGeneratorVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpSourceGeneratorVerifier.cs index 84bd897adc61f..55b90860b4260 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpSourceGeneratorVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpSourceGeneratorVerifier.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace Microsoft.Interop.UnitTests.Verifiers { @@ -79,7 +78,7 @@ public static async Task VerifySourceGeneratorAsync(string[] sources, params Dia await test.RunAsync(CancellationToken.None); } - internal class Test : CSharpSourceGeneratorTest + internal class Test : CSharpSourceGeneratorTest { public Test(TestTargetFramework targetFramework) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/LibraryImportGenerator.Unit.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/LibraryImportGenerator.Unit.Tests.csproj index 085cea14f2254..7574caa597790 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/LibraryImportGenerator.Unit.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/LibraryImportGenerator.Unit.Tests.csproj @@ -40,9 +40,9 @@ - - - + + + diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/CSharpCodeFixVerifier`2.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/CSharpCodeFixVerifier`2.cs index 1c51e2fc44479..54220dda61244 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/CSharpCodeFixVerifier`2.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/CSharpCodeFixVerifier`2.cs @@ -9,7 +9,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace System.Text.RegularExpressions.Tests { @@ -33,7 +32,7 @@ public static async Task VerifyCodeFixAsync(string source, string fixedSource, R await test.RunAsync(CancellationToken.None); } - public class Test : CSharpCodeFixTest + public class Test : CSharpCodeFixTest { public Test(ReferenceAssemblies? references = null) { diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj index 613d15b7883f1..dd8f9603cd719 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj @@ -72,7 +72,7 @@ - + - - + + diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs index 3f8aa28a86996..d5a520afc2d8e 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs @@ -15,7 +15,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; namespace ILLink.RoslynAnalyzer.Tests @@ -25,18 +24,18 @@ public static partial class CSharpAnalyzerVerifier { /// public static DiagnosticResult Diagnostic () - => CSharpAnalyzerVerifier.Diagnostic (); + => CSharpAnalyzerVerifier.Diagnostic (); /// public static DiagnosticResult Diagnostic (string diagnosticId) - => CSharpAnalyzerVerifier.Diagnostic (diagnosticId); + => CSharpAnalyzerVerifier.Diagnostic (diagnosticId); /// public static DiagnosticResult Diagnostic (DiagnosticDescriptor descriptor) - => CSharpAnalyzerVerifier.Diagnostic (descriptor); + => CSharpAnalyzerVerifier.Diagnostic (descriptor); public static DiagnosticResult Diagnostic (DiagnosticId diagnosticId) - => CSharpAnalyzerVerifier.Diagnostic (DiagnosticDescriptors.GetDiagnosticDescriptor (diagnosticId)); + => CSharpAnalyzerVerifier.Diagnostic (DiagnosticDescriptors.GetDiagnosticDescriptor (diagnosticId)); /// public static async Task VerifyAnalyzerAsync ( diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs index b541b06db52f6..808fc4b772884 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; namespace ILLink.RoslynAnalyzer.Tests { @@ -25,7 +24,7 @@ public partial class CSharpCodeFixVerifier where TAnalyzer : DiagnosticAnalyzer, new() where TCodeFix : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, new() { - public class Test : CSharpCodeFixTest + public class Test : CSharpCodeFixTest { public Test () {