Skip to content

Commit

Permalink
Code style formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Aug 16, 2023
1 parent a6065bd commit 7f120f9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
9 changes: 5 additions & 4 deletions src/xunit.analyzers.fixes/Utility/CodeAnalysisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ public static async Task<Document> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using Xunit.Analyzers;
using Verify = CSharpVerifier<Xunit.Analyzers.TestClassCannotBeNestedInGenericClass>;

public class TestClassCannotBeNestedInGenericClassTests
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using Xunit.Analyzers;
using Xunit.Analyzers.Fixes;
using Verify = CSharpVerifier<Xunit.Analyzers.TestClassCannotBeNestedInGenericClass>;

Expand All @@ -12,7 +10,7 @@ public async void MovesTestClassOutOfGenericParent()
const string before = @"
public abstract class OpenGenericType<T>
{
public class NestedTestClass
public class [|NestedTestClass|]
{
[Xunit.Fact]
public void TestMethod() { }
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMethodSymbol>()
.Any(m => m.GetAttributes().Any(a => xunitContext.Core.FactAttributeType.IsAssignableFrom(a.AttributeClass)));
var doesClassContainTests =
classSymbol
.GetMembers()
.OfType<IMethodSymbol>()
.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;
}
Expand Down

0 comments on commit 7f120f9

Please sign in to comment.