traial fix (not working as expected)

This commit is contained in:
Enji Eid 2024-09-10 16:31:36 +02:00
Родитель 77c969e171
Коммит b99f04f33d
2 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -49,7 +49,7 @@ public sealed class PreferTestCleanupOverDisposeFixer : CodeFixProvider
CodeAction.Create(
CodeFixResources.ReplaceWithTestCleanuFix,
c => ReplaceDisposeWithTestCleanupAsync(context.Document, methodDeclaration, c),
nameof(TestMethodShouldBeValidCodeFixProvider)),
nameof(PreferTestCleanupOverDisposeFixer)),
diagnostic);
}
@ -82,8 +82,9 @@ public sealed class PreferTestCleanupOverDisposeFixer : CodeFixProvider
}
else
{
// If no interfaces left, remove the base list entirely
newParent = newParent.WithBaseList(null);
SyntaxTriviaList? trailingTrivia = parentClass.BaseList?.GetTrailingTrivia();
newParent = newParent.WithBaseList(null).WithOpenBraceToken(parentClass.OpenBraceToken.WithLeadingTrivia(SyntaxFactory.TriviaList()).WithLeadingTrivia(trailingTrivia));
newParent = newParent.WithTrailingTrivia(SyntaxFactory.TriviaList());
}
editor.ReplaceNode(parentClass, newParent);

Просмотреть файл

@ -71,7 +71,8 @@ public sealed class PreferTestCleanupOverDisposeAnalyzerTests(ITestExecutionCont
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class MyTestClass {
public class MyTestClass
{
[TestCleanup]
public ValueTask TestCleanup()
{