Open
Description
I'm currently writing a source generator where I have some multiline pattern matches with direct variable assignment, that wrongly triggers SA1513:
switch (syntaxNode)
{
case MethodDeclarationSyntax
{
Parent: ClassDeclarationSyntax { Identifier: { ValueText: "ResultExtensions" } },
Modifiers: var modifiers,
ParameterList: { Parameters: var parameters },
} methodDeclarationSyntax: // SA1513 triggers here, but probably shouldnt
// do stuff here
break;
}
}
The same is the case when i have the same assignment in an if statement:
if (syntaxNode is MethodDeclarationSyntax
{
Parent: ClassDeclarationSyntax { Identifier: { ValueText: "ResultExtensions" } },
Modifiers: var modifiers,
ParameterList: { Parameters: var parameters },
} methodDeclarationSyntax) // SA1513 triggers here, but probably shouldnt
{
// do stuff here
}
IMHO SA1513 shouldn't trigger in this case. There might be case to force a newline after the pattern, but even that seems to not enhance readability, on the contrary. Having to seperate the variable assignment from the pattern itself as it is now hurts even more. Not having a variable assignment after the pattern works fine and does not trigger the rule, neither in the switch nor the if statement.