public override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            if (!TryFindFirstAncestorOrSelf(root, context.Span, out LockStatementSyntax lockStatement))
            {
                return;
            }

            CodeAction codeAction = CodeAction.Create(
                "Introduce field to lock on",
                ct => AvoidLockingOnPubliclyAccessibleInstanceRefactoring.RefactorAsync(context.Document, lockStatement, ct),
                GetEquivalenceKey(DiagnosticIdentifiers.AvoidLockingOnPubliclyAccessibleInstance));

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            LockStatementSyntax lockStatement = root
                                                .FindNode(context.Span, getInnermostNodeForTie: true)?
                                                .FirstAncestorOrSelf <LockStatementSyntax>();

            if (lockStatement == null)
            {
                return;
            }

            CodeAction codeAction = CodeAction.Create(
                "Introduce field to lock on",
                cancellationToken => AvoidLockingOnPubliclyAccessibleInstanceRefactoring.RefactorAsync(context.Document, lockStatement, cancellationToken),
                DiagnosticIdentifiers.AvoidLockingOnPubliclyAccessibleInstance + BaseCodeFixProvider.EquivalenceKeySuffix);

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }