From 7f120f9ad443a07bfde5c44041f91b81e4893cf0 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Wed, 16 Aug 2023 10:29:08 -0700 Subject: [PATCH] Code style formatting --- .../Utility/CodeAnalysisExtensions.cs | 9 +++++---- .../TestClassCannotBeNestedInGenericClassTests.cs | 14 ++++++++------ ...ClassCannotBeNestedInGenericClassFixerTests.cs | 10 ++-------- .../TestClassCannotBeNestedInGenericClass.cs | 15 +++++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/xunit.analyzers.fixes/Utility/CodeAnalysisExtensions.cs b/src/xunit.analyzers.fixes/Utility/CodeAnalysisExtensions.cs index e1df12b2..59cea1ac 100644 --- a/src/xunit.analyzers.fixes/Utility/CodeAnalysisExtensions.cs +++ b/src/xunit.analyzers.fixes/Utility/CodeAnalysisExtensions.cs @@ -156,10 +156,11 @@ public static async Task ExtractNodeFromParent( { editor.RemoveNode(node); - var formattedNode = node - .WithLeadingTrivia(SyntaxFactory.ElasticMarker) - .WithTrailingTrivia(SyntaxFactory.ElasticMarker) - .WithAdditionalAnnotations(Formatter.Annotation, Simplifier.Annotation); + var formattedNode = + node + .WithLeadingTrivia(SyntaxFactory.ElasticMarker) + .WithTrailingTrivia(SyntaxFactory.ElasticMarker) + .WithAdditionalAnnotations(Formatter.Annotation, Simplifier.Annotation); editor.InsertAfter(parent, formattedNode); } diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassCannotBeNestedInGenericClassTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassCannotBeNestedInGenericClassTests.cs index b53c9d14..cdc811a2 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassCannotBeNestedInGenericClassTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassCannotBeNestedInGenericClassTests.cs @@ -1,7 +1,5 @@ using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Testing; using Xunit; -using Xunit.Analyzers; using Verify = CSharpVerifier; public class TestClassCannotBeNestedInGenericClassTests @@ -19,8 +17,10 @@ public void TestMethod() { } } }"; - var expected = new DiagnosticResult(Descriptors.X1032_TestClassCannotBeNestedInGenericClass) - .WithLocation(4, 18); + var expected = + Verify + .Diagnostic() + .WithLocation(4, 18); await Verify.VerifyAnalyzer(source, expected); } @@ -42,8 +42,10 @@ public class NestedTestClass : BaseTestClass } }"; - var expected = new DiagnosticResult(Descriptors.X1032_TestClassCannotBeNestedInGenericClass) - .WithLocation(10, 18); + var expected = + Verify + .Diagnostic() + .WithLocation(10, 18); await Verify.VerifyAnalyzer(source, expected); } diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs index 71e5a85a..88eddafe 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs @@ -1,6 +1,4 @@ -using Microsoft.CodeAnalysis.Testing; using Xunit; -using Xunit.Analyzers; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -12,7 +10,7 @@ public async void MovesTestClassOutOfGenericParent() const string before = @" public abstract class OpenGenericType { - public class NestedTestClass + public class [|NestedTestClass|] { [Xunit.Fact] public void TestMethod() { } @@ -29,10 +27,6 @@ public class NestedTestClass public void TestMethod() { } }"; - await Verify.VerifyCodeFix( - before, - after, - TestClassCannotBeNestedInGenericClassFixer.Key_ExtractTestClass, - new DiagnosticResult(Descriptors.X1032_TestClassCannotBeNestedInGenericClass).WithLocation(4, 18)); + await Verify.VerifyCodeFix(before, after, TestClassCannotBeNestedInGenericClassFixer.Key_ExtractTestClass); } } diff --git a/src/xunit.analyzers/X1000/TestClassCannotBeNestedInGenericClass.cs b/src/xunit.analyzers/X1000/TestClassCannotBeNestedInGenericClass.cs index 27899243..8eb39ad0 100644 --- a/src/xunit.analyzers/X1000/TestClassCannotBeNestedInGenericClass.cs +++ b/src/xunit.analyzers/X1000/TestClassCannotBeNestedInGenericClass.cs @@ -40,16 +40,19 @@ public override void AnalyzeCompilation( }, SymbolKind.NamedType); } - private bool DoesInheritenceTreeContainTests(INamedTypeSymbol classSymbol, XunitContext xunitContext, int depth) + private bool DoesInheritenceTreeContainTests( + INamedTypeSymbol classSymbol, + XunitContext xunitContext, + int depth) { - var doesClassContainTests = classSymbol.GetMembers() - .OfType() - .Any(m => m.GetAttributes().Any(a => xunitContext.Core.FactAttributeType.IsAssignableFrom(a.AttributeClass))); + var doesClassContainTests = + classSymbol + .GetMembers() + .OfType() + .Any(m => m.GetAttributes().Any(a => xunitContext.Core.FactAttributeType.IsAssignableFrom(a.AttributeClass))); if (!doesClassContainTests && classSymbol.BaseType is not null && depth > 0) - { return DoesInheritenceTreeContainTests(classSymbol.BaseType, xunitContext, depth - 1); - } return doesClassContainTests; }