Skip to content

Commit

Permalink
Respect diagnostic RCS0062 for RCS1016 and RR0169
Browse files Browse the repository at this point in the history
  • Loading branch information
cbersch committed Jan 8, 2025
1 parent 392c421 commit d016f62
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 73 deletions.
23 changes: 23 additions & 0 deletions src/Common/CSharp/Analysis/ConvertExpressionBodyAnalysis.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.CodeAnalysis.CSharp;

namespace Roslynator.CSharp.Analysis;

internal static class ConvertExpressionBodyAnalysis
{
public static bool BreakExpressionOnNewLine(SyntaxKind syntaxKind)
{
switch (syntaxKind)
{
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.DestructorDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.IndexerDeclaration:
case SyntaxKind.OperatorDeclaration:
case SyntaxKind.ConversionOperatorDeclaration:
return true;
default:
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslynator.CSharp;
using Roslynator.CSharp.Analysis;
using Roslynator.CSharp.CodeStyle;

namespace Roslynator.Formatting.CSharp;
Expand Down Expand Up @@ -37,17 +38,9 @@ private static void AnalyzeArrowExpressionClause(SyntaxNodeAnalysisContext conte
{
var arrowExpressionClause = (ArrowExpressionClauseSyntax)context.Node;

switch (arrowExpressionClause.Parent.Kind())
if (ConvertExpressionBodyAnalysis.BreakExpressionOnNewLine(arrowExpressionClause.Parent.Kind()))
{
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.DestructorDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.IndexerDeclaration:
case SyntaxKind.OperatorDeclaration:
case SyntaxKind.ConversionOperatorDeclaration:
AnalyzeArrowExpressionClause(arrowExpressionClause.ArrowToken, context);
break;
AnalyzeArrowExpressionClause(arrowExpressionClause.ArrowToken, context);
}
}

Expand Down
Loading

0 comments on commit d016f62

Please sign in to comment.