From 8094fd321499f8a52ccc36f420ad444391cb11f7 Mon Sep 17 00:00:00 2001 From: Sebastien Lebreton Date: Mon, 23 Feb 2026 16:49:31 +0100 Subject: [PATCH] Move to xunit v3 --- src/Directory.Packages.props | 3 +-- .../ConsistencyTests.cs | 7 +++---- .../GetLocalPositionAndRotationTests.cs | 14 +++++++------- .../GetPositionAndRotationTests.cs | 4 ++-- .../Microsoft.Unity.Analyzers.Tests.csproj | 4 ++-- .../SetLocalPositionAndRotationTests.cs | 12 ++++++------ .../SetPositionAndRotationTests.cs | 4 ++-- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 380da02..9708f20 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -19,9 +19,8 @@ - + - diff --git a/src/Microsoft.Unity.Analyzers.Tests/ConsistencyTests.cs b/src/Microsoft.Unity.Analyzers.Tests/ConsistencyTests.cs index 6674d9d..2db923d 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/ConsistencyTests.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/ConsistencyTests.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Xunit; -using Xunit.Abstractions; namespace Microsoft.Unity.Analyzers.Tests; @@ -124,12 +123,12 @@ public async Task CheckHelpLinks() Assert.NotEmpty(d.HelpLinkUri); Assert.Contains(d.Id, d.HelpLinkUri); - var response = await client.GetAsync(d.HelpLinkUri); + var response = await client.GetAsync(d.HelpLinkUri, TestContext.Current.CancellationToken); Assert.True(response.IsSuccessStatusCode); } } - [SkippableFact] + [Fact] public void CheckCodeFixTestsHaveTriviaTests() { var assembly = typeof(ConsistencyTests).Assembly; @@ -153,7 +152,7 @@ public void CheckCodeFixTestsHaveTriviaTests() missingTriviaTests.Add(testClass.Name); } - Skip.If(missingTriviaTests.Any(), $"The following CodeFix test classes ({(float)missingTriviaTests.Count / codeFixTestClasses.Length:0.00%}) are missing a Trivia test:\n\n{string.Join("\n", missingTriviaTests)}"); + Assert.SkipWhen(missingTriviaTests.Any(), $"The following CodeFix test classes ({(float)missingTriviaTests.Count / codeFixTestClasses.Length:0.00%}) are missing a Trivia test:\n\n{string.Join("\n", missingTriviaTests)}"); } private static bool IsBaseCodeFixVerifierTest(Type type) diff --git a/src/Microsoft.Unity.Analyzers.Tests/GetLocalPositionAndRotationTests.cs b/src/Microsoft.Unity.Analyzers.Tests/GetLocalPositionAndRotationTests.cs index 4cb7c1b..44100aa 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/GetLocalPositionAndRotationTests.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/GetLocalPositionAndRotationTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.Unity.Analyzers.Tests; public class GetLocalPositionAndRotationTests : BaseCodeFixVerifierTest { // For extensive testing, see GetPositionAndRotationTests - [SkippableFact] + [Fact] public async Task UseGetLocalPositionAndRotationMethod() { const string test = @" @@ -31,7 +31,7 @@ void Update() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Transform); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(9, 9); @@ -53,7 +53,7 @@ void Update() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task UseGetLocalPositionAndRotationMethodTransformAccess() { const string test = @" @@ -73,7 +73,7 @@ void Method() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Jobs.TransformAccess); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(9, 9); @@ -95,7 +95,7 @@ void Method() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task NoTypeMismatch() { const string test = @" @@ -116,7 +116,7 @@ void Update() await VerifyCSharpDiagnosticAsync(test); } - [SkippableFact] + [Fact] public async Task UseGetLocalPositionAndRotationMethodTrivia() { const string test = @" @@ -139,7 +139,7 @@ void Update() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Transform); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(10, 9); diff --git a/src/Microsoft.Unity.Analyzers.Tests/GetPositionAndRotationTests.cs b/src/Microsoft.Unity.Analyzers.Tests/GetPositionAndRotationTests.cs index 2d8a6ca..987abb2 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/GetPositionAndRotationTests.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/GetPositionAndRotationTests.cs @@ -49,7 +49,7 @@ void Update() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task UseGetPositionAndRotationMethodTransformAccess() { const string test = @" @@ -72,7 +72,7 @@ void Method() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Jobs.TransformAccess); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(12, 9); diff --git a/src/Microsoft.Unity.Analyzers.Tests/Microsoft.Unity.Analyzers.Tests.csproj b/src/Microsoft.Unity.Analyzers.Tests/Microsoft.Unity.Analyzers.Tests.csproj index ae93f70..60e8bfe 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/Microsoft.Unity.Analyzers.Tests.csproj +++ b/src/Microsoft.Unity.Analyzers.Tests/Microsoft.Unity.Analyzers.Tests.csproj @@ -1,6 +1,7 @@  + Exe net10.0 enable NU1608;VSTHRD200 @@ -12,9 +13,8 @@ - + - diff --git a/src/Microsoft.Unity.Analyzers.Tests/SetLocalPositionAndRotationTests.cs b/src/Microsoft.Unity.Analyzers.Tests/SetLocalPositionAndRotationTests.cs index 1dfc557..26ae727 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/SetLocalPositionAndRotationTests.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/SetLocalPositionAndRotationTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.Unity.Analyzers.Tests; public class SetLocalPositionAndRotationTests : BaseCodeFixVerifierTest { // For extensive testing, see SetPositionAndRotationTests.cs - [SkippableFact] + [Fact] public async Task UpdateLocalPositionAndRotationMethod() { const string test = @" @@ -30,7 +30,7 @@ void Update() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Transform); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(8, 9); @@ -51,7 +51,7 @@ void Update() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task UpdateLocalPositionAndRotationMethodTransformAccess() { const string test = @" @@ -72,7 +72,7 @@ void Method() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Jobs.TransformAccess); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(10, 9); @@ -95,7 +95,7 @@ void Method() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task UpdateLocalPositionAndRotationMethodTrivia() { const string test = @" @@ -116,7 +116,7 @@ void Update() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Transform); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(9, 9); diff --git a/src/Microsoft.Unity.Analyzers.Tests/SetPositionAndRotationTests.cs b/src/Microsoft.Unity.Analyzers.Tests/SetPositionAndRotationTests.cs index 7076a12..31d9f7f 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/SetPositionAndRotationTests.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/SetPositionAndRotationTests.cs @@ -45,7 +45,7 @@ void Update() await VerifyCSharpFixAsync(test, fixedTest); } - [SkippableFact] + [Fact] public async Task UpdatePositionAndRotationMethodTransformAccess() { const string test = @" @@ -66,7 +66,7 @@ void Method() var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName; var type = typeof(UnityEngine.Jobs.TransformAccess); - Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); + Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}"); var diagnostic = ExpectDiagnostic().WithLocation(10, 9);