public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            var diagnostic     = context.Diagnostics.First();
            var diagnosticSpan = diagnostic.Location.SourceSpan;

            var expression = root.FindNode(diagnosticSpan);

            if (SyntaxNodeUtils.IsInsideOrchestrationTrigger(expression))
            {
                if (CodeFixProviderUtils.TryGetDurableOrchestrationContextVariableName(expression, out string variableName))
                {
                    context.RegisterCodeFix(
                        CodeAction.Create(FixDateTimeInOrchestrator.ToString(), c => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, expression, c, variableName + ".CurrentUtcDateTime"), nameof(DateTimeCodeFixProvider)), diagnostic);
                }
            }
        }
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            var diagnostic     = context.Diagnostics.First();
            var diagnosticSpan = diagnostic.Location.SourceSpan;

            var identifierNode = root.FindNode(diagnosticSpan);

            SemanticModel semanticModel = await context.Document.GetSemanticModelAsync();

            var durableVersion = SyntaxNodeUtils.GetDurableVersion(semanticModel);

            if (durableVersion.Equals(DurableVersion.V1))
            {
                context.RegisterCodeFix(
                    CodeAction.Create(FixDurableOrchestrationClient.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, "DurableOrchestrationClient"), nameof(ClientCodeFixProvider) + nameof(FixDurableOrchestrationClient)),
                    diagnostic);
            }
            else if (durableVersion.Equals(DurableVersion.V2))
            {
                context.RegisterCodeFix(
                    CodeAction.Create(FixIDurableClient.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, "IDurableClient"), nameof(ClientCodeFixProvider) + nameof(FixIDurableClient)),
                    diagnostic);

                context.RegisterCodeFix(
                    CodeAction.Create(FixIDurableEntityClient.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, "IDurableEntityClient"), nameof(ClientCodeFixProvider) + nameof(FixIDurableEntityClient)),
                    diagnostic);

                context.RegisterCodeFix(
                    CodeAction.Create(FixIDurableOrchestrationClient.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, "IDurableOrchestrationClient"), nameof(ClientCodeFixProvider) + nameof(FixIDurableOrchestrationClient)),
                    diagnostic);
            }
        }
Ejemplo n.º 3
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            var diagnostic     = context.Diagnostics.First();
            var diagnosticSpan = diagnostic.Location.SourceSpan;

            var identifierNode = root.FindNode(diagnosticSpan);

            context.RegisterCodeFix(
                CodeAction.Create(FixIDurableEntityContext.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, "IDurableEntityContext"), nameof(EntityContextCodeFixProvider)),
                diagnostic);
        }
Ejemplo n.º 4
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

            var diagnostic     = context.Diagnostics.First();
            var diagnosticSpan = diagnostic.Location.SourceSpan;

            var           identifierNode = root.FindNode(diagnosticSpan);
            SemanticModel semanticModel  = await context.Document.GetSemanticModelAsync();

            if (SyntaxNodeUtils.TryGetFunctionName(semanticModel, identifierNode, out string functionName))
            {
                context.RegisterCodeFix(
                    CodeAction.Create(FixDispatchEntityCall.ToString(), cancellationToken => CodeFixProviderUtils.ReplaceWithIdentifierAsync(context.Document, identifierNode, cancellationToken, functionName), nameof(DispatchEntityNameCodeFixProvider)),
                    diagnostic);
            }
        }