private PropertyDeclarationSyntax GetPropertyNodeWithDiagnostic(SyntaxNode root, TextSpan diagnosticSpan) { SyntaxNode node = root?.FindNode(diagnosticSpan); return(node switch { PropertyDeclarationSyntax propertyDeclaration => propertyDeclaration, IdentifierNameSyntax propertyTypeDeclaration when propertyTypeDeclaration.Parent is PropertyDeclarationSyntax propertyDeclaration => propertyDeclaration, TypeSyntax propertyTypeDeclaration => propertyTypeDeclaration.Parent <PropertyDeclarationSyntax>(), AttributeListSyntax attributeListNode when attributeListNode.Parent is PropertyDeclarationSyntax propertyDeclaration => propertyDeclaration, AttributeSyntax attributeNode => attributeNode.Parent <PropertyDeclarationSyntax>(), _ => null, });