private static StatementSyntax CreateStatement(MethodDeclarationSyntax methodNode, IMethodSymbol methodSymbol)
        {
            var methodParameters = methodSymbol.Parameters;
            var arguments        = new string[methodParameters.Length];

            for (var i = 0; i < methodParameters.Length; i++)
            {
                var parameter = methodParameters[i];
                var argument  = parameter.Name;

                if (parameter.RefKind.HasFlag(RefKind.Ref))
                {
                    argument = $"ref {argument}";
                }
                else if (parameter.RefKind.HasFlag(RefKind.Out))
                {
                    argument = $"out {argument}";
                }

                arguments[i] = argument;
            }

            var methodCall = $"base.{methodSymbol.Name}({string.Join(", ", arguments)});{Environment.NewLine}";

            if (!methodSymbol.ReturnsVoid)
            {
                var variableName = MustInvokeBaseMethodCallMethodCodeFix.CreateSafeLocalVariableName(
                    methodNode, methodSymbol);
                methodCall = $"var {variableName} = {methodCall}";
            }

            return(SyntaxFactory.ParseStatement(methodCall).WithAdditionalAnnotations(Formatter.Annotation));
        }
        public override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var root = await context.Document.GetSyntaxRootAsync(
                context.CancellationToken).ConfigureAwait(false);

            context.CancellationToken.ThrowIfCancellationRequested();

            var diagnostic = context.Diagnostics[0];
            var methodNode = root.FindNode(diagnostic.Location.SourceSpan) as MethodDeclarationSyntax;

            var model = await context.Document.GetSemanticModelAsync(context.CancellationToken);

            var methodSymbol = model.GetDeclaredSymbol(methodNode) as IMethodSymbol;

            // Syntax tree way.
            //var invocation = MustInvokeBaseMethodCallMethodCodeFix.CreateInvocation(
            //	methodSymbol);
            //invocation = MustInvokeBaseMethodCallMethodCodeFix.AddArguments(
            //	context, methodSymbol, invocation);
            //var statement = MustInvokeBaseMethodCallMethodCodeFix.CreateStatement(
            //	context, methodNode, methodSymbol, invocation);

            // Code parsing way
            var statement = MustInvokeBaseMethodCallMethodCodeFix.CreateStatement(
                methodNode, methodSymbol);

            var newRoot = MustInvokeBaseMethodCallMethodCodeFix.CreateNewRoot(
                root, methodNode, statement);

            const string codeFixDescription = "Add base invocation";

            context.RegisterCodeFix(
                CodeAction.Create(codeFixDescription,
                                  _ => Task.FromResult(context.Document.WithSyntaxRoot(newRoot)),
                                  codeFixDescription), diagnostic);
        }