protected override bool IsFixable(StatementSyntax statement, BlockSyntax block, SyntaxKind parentKind) { if (!parentKind.Is( SyntaxKind.MethodDeclaration, SyntaxKind.LocalFunctionStatement)) { return(false); } if (object.ReferenceEquals(block.Statements.SingleOrDefault(ignoreLocalFunctions: true, shouldThrow: false), statement)) { return(false); } TextSpan span = TextSpan.FromBounds(block.SpanStart, statement.FullSpan.Start); return(block.ContainsYield(span)); }