public override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false); if (!TryFindFirstAncestorOrSelf(root, context.Span, out BlockSyntax block)) { return; } Document document = context.Document; Diagnostic diagnostic = context.Diagnostics[0]; switch (diagnostic.Id) { case DiagnosticIdentifiers.AddNewLineAfterOpeningBraceOfBlock: case DiagnosticIdentifiers.AddNewLineAfterOpeningBraceOfEmptyBlock: case DiagnosticIdentifiers.AddNewLineAfterOpeningBraceOfAccessor: { CodeAction codeAction = CodeAction.Create( CodeFixTitles.AddNewLine, ct => CodeFixHelpers.AddNewLineAfterOpeningBraceAsync(document, block, ct), GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } } }