Xunit.DependencyInjection.Analyzer.XunitDependencyInjectionCodeFixProvider.GetIdentifierName(string)

Here are the examples of the csharp api Xunit.DependencyInjection.Analyzer.XunitDependencyInjectionCodeFixProvider.GetIdentifierName(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : XunitDependencyInjectionCodeFixProvider.cs
with MIT License
from pengweiqhca

public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
    {
        var diagnostic = context.Diagnostics[0];
        if (diagnostic.Id != Rules.ReturnTypereplacedignableTo.Id &&
            diagnostic.Id != Rules.NoReturnType.Id) return;

        var root = await context.Doreplacedent.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

        if (root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true)
            is not MethodDeclarationSyntax method) return;

        if (diagnostic.Id == Rules.NoReturnType.Id)
            context.RegisterCodeFix(CodeAction.Create(
                    CodeFixResources.ModifyReturnType,
                    c => ChangeReturnType(context.Doreplacedent, method, SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.VoidKeyword, "void", "void", SyntaxTriviaList.Create(SyntaxFactory.Whitespace(" ")))), c),
                    nameof(CodeFixResources.ModifyReturnType)),
                diagnostic);
        else if (diagnostic.Id == Rules.ReturnTypereplacedignableTo.Id)
        {
            if (method.Identifier.Text == "CreateHostBuilder")
                context.RegisterCodeFix(CodeAction.Create(
                        CodeFixResources.ModifyReturnType,
                        c => ChangeReturnType(
                            context.Doreplacedent, method, SyntaxFactory.QualifiedName(
                                SyntaxFactory.QualifiedName(
                                    SyntaxFactory.QualifiedName(
                                        GetIdentifierName("Microsoft"),
                                        SyntaxFactory.Token(SyntaxKind.DotToken),
                                        GetIdentifierName("Extensions")),
                                    SyntaxFactory.Token(SyntaxKind.DotToken),
                                    GetIdentifierName("Hosting")),
                                SyntaxFactory.Token(SyntaxKind.DotToken),
                                GetIdentifierName("IHostBuilder")), c),
                        nameof(CodeFixResources.ModifyReturnType)),
                    diagnostic);
        }
    }