Skip to content

Commit

Permalink
Move .WithAdditionalAnnotations(Formatter.Annotation) to the extendio…
Browse files Browse the repository at this point in the history
…n method WithArguments
  • Loading branch information
Bartleby2718 committed Jun 16, 2024
1 parent a613e4c commit 3f976ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Formatting;
using NUnit.Analyzers.Extensions;
using NUnit.Analyzers.Helpers;
using static NUnit.Analyzers.Constants.NUnitFrameworkConstants;
Expand Down Expand Up @@ -144,9 +143,7 @@ protected virtual (ExpressionSyntax? actual, ExpressionSyntax? constraintExpress
constraintArgumentWithRightTrivia
}.Union(remainingArguments);

var newArgumentsList = assertNode.ArgumentList
.WithArguments(newArguments)
.WithAdditionalAnnotations(Formatter.Annotation);
var newArgumentsList = assertNode.ArgumentList.WithArguments(newArguments);

return newAssertNode.WithArgumentList(newArgumentsList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Formatting;

namespace NUnit.Analyzers.Extensions
{
Expand All @@ -18,7 +19,8 @@ public static ArgumentListSyntax WithArguments(
// To match the old style as closely as possible, do not attempt anything if the number of arguments stayed the same
if (originalArguments.Count == newArguments.Count())
{
return @this.WithArguments(SyntaxFactory.SeparatedList(newArguments, originalSeparators));
return @this.WithArguments(SyntaxFactory.SeparatedList(newArguments, originalSeparators))
.WithAdditionalAnnotations(Formatter.Annotation);
}

// Otherwise, the number of arguments has either increased or decreased, in which case
Expand Down Expand Up @@ -49,7 +51,8 @@ public static ArgumentListSyntax WithArguments(

var newSeparatedList = SyntaxFactory.SeparatedList<ArgumentSyntax>(nodesAndTokens);

return @this.WithArguments(newSeparatedList);
return @this.WithArguments(newSeparatedList)
.WithAdditionalAnnotations(Formatter.Annotation);
}

private static bool TryGetFirstEndOfLineTrivia(SyntaxToken openParenToken, SyntaxToken[] separators, out SyntaxTrivia trailingTrivia)
Expand Down

0 comments on commit 3f976ae

Please sign in to comment.