public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            if (!Settings.IsCodeFixEnabled(CodeFixIdentifiers.ChangeAccessibility))
            {
                return;
            }

            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            if (!TryFindFirstAncestorOrSelf(
                    root,
                    context.Span,
                    out SyntaxNode node,
                    predicate: OverriddenSymbolInfo.CanCreate))
            {
                return;
            }

            Diagnostic diagnostic = context.Diagnostics[0];

            SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

            OverriddenSymbolInfo overrideInfo = OverriddenSymbolInfo.Create(node, semanticModel, context.CancellationToken);

            if (!overrideInfo.Success)
            {
                return;
            }

            Accessibility newAccessibility = overrideInfo.OverriddenSymbol.DeclaredAccessibility;

            CodeAction codeAction = CodeAction.Create(
                $"Change accessibility to '{SyntaxFacts.GetText(newAccessibility)}'",
                cancellationToken =>
            {
                if (node.Kind() == SyntaxKind.VariableDeclarator)
                {
                    node = node.Parent.Parent;
                }

                SyntaxNode newNode;

                if (newAccessibility == Accessibility.Public &&
                    node is AccessorDeclarationSyntax)
                {
                    newNode = SyntaxAccessibility.WithoutExplicitAccessibility(node);
                }
                else
                {
                    newNode = SyntaxAccessibility.WithExplicitAccessibility(node, newAccessibility);
                }

                return(context.Document.ReplaceNodeAsync(node, newNode, cancellationToken));
            },
                GetEquivalenceKey(diagnostic));

            context.RegisterCodeFix(codeAction, diagnostic);
        }
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            if (!Settings.IsCodeFixEnabled(CodeFixIdentifiers.ChangeAccessibility))
            {
                return;
            }

            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            if (!TryFindFirstAncestorOrSelf(
                    root,
                    context.Span,
                    out SyntaxNode node,
                    predicate: f => OverriddenSymbolInfo.CanCreate(f)))
            {
                return;
            }

            foreach (Diagnostic diagnostic in context.Diagnostics)
            {
                switch (diagnostic.Id)
                {
                case CompilerDiagnosticIdentifiers.CannotChangeAccessModifiersWhenOverridingInheritedMember:
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    OverriddenSymbolInfo overrideInfo = OverriddenSymbolInfo.Create(node, semanticModel, context.CancellationToken);

                    if (!overrideInfo.Success)
                    {
                        break;
                    }

                    Accessibility newAccessibility = overrideInfo.OverriddenSymbol.DeclaredAccessibility;

                    CodeAction codeAction = CodeAction.Create(
                        $"Change accessibility to '{SyntaxFacts.GetText(newAccessibility)}'",
                        cancellationToken =>
                        {
                            if (node.Kind() == SyntaxKind.VariableDeclarator)
                            {
                                node = node.Parent.Parent;
                            }

                            SyntaxNode newNode = SyntaxAccessibility.WithExplicitAccessibility(node, newAccessibility);

                            return(context.Document.ReplaceNodeAsync(node, newNode, cancellationToken));
                        },
                        GetEquivalenceKey(diagnostic));

                    context.RegisterCodeFix(codeAction, diagnostic);
                    break;
                }
                }
            }
        }