Ejemplo n.º 1
0
 protected virtual Task <SemanticDocument> UpdateMethodAfterGenerationAsync(
     SemanticDocument originalDocument,
     OperationStatus <IMethodSymbol> methodSymbolResult,
     CancellationToken cancellationToken)
 => Task.FromResult(originalDocument);
Ejemplo n.º 2
0
        private async Task <OperationStatus> CheckVariableTypesAsync(
            OperationStatus status,
            AnalyzerResult analyzeResult,
            CancellationToken cancellationToken
            )
        {
            var document = analyzeResult.SemanticDocument;

            // sync selection result to same semantic data as analyzeResult
            var firstToken = OriginalSelectionResult.With(document).GetFirstTokenInSelection();
            var context    = firstToken.Parent;

            var result = await TryCheckVariableTypeAsync(
                document,
                context,
                analyzeResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken),
                status,
                cancellationToken
                )
                         .ConfigureAwait(false);

            if (!result.Item1)
            {
                result = await TryCheckVariableTypeAsync(
                    document,
                    context,
                    analyzeResult.GetVariablesToSplitOrMoveIntoMethodDefinition(
                        cancellationToken
                        ),
                    result.Item2,
                    cancellationToken
                    )
                         .ConfigureAwait(false);

                if (!result.Item1)
                {
                    result = await TryCheckVariableTypeAsync(
                        document,
                        context,
                        analyzeResult.MethodParameters,
                        result.Item2,
                        cancellationToken
                        )
                             .ConfigureAwait(false);

                    if (!result.Item1)
                    {
                        result = await TryCheckVariableTypeAsync(
                            document,
                            context,
                            analyzeResult.GetVariablesToMoveOutToCallSite(cancellationToken),
                            result.Item2,
                            cancellationToken
                            )
                                 .ConfigureAwait(false);

                        if (!result.Item1)
                        {
                            result = await TryCheckVariableTypeAsync(
                                document,
                                context,
                                analyzeResult.GetVariablesToSplitOrMoveOutToCallSite(
                                    cancellationToken
                                    ),
                                result.Item2,
                                cancellationToken
                                )
                                     .ConfigureAwait(false);

                            if (!result.Item1)
                            {
                                return(result.Item2);
                            }
                        }
                    }
                }
            }

            status = result.Item2;

            var checkedStatus = await CheckTypeAsync(
                document.Document,
                context,
                context.GetLocation(),
                analyzeResult.ReturnType,
                cancellationToken
                )
                                .ConfigureAwait(false);

            return(checkedStatus.With(status));
        }
Ejemplo n.º 3
0
        protected SelectionResult(OperationStatus status)
        {
            Contract.ThrowIfNull(status);

            Status = status;
        }
Ejemplo n.º 4
0
 public static bool FailedWithNoBestEffortSuggestion(this OperationStatus status)
 {
     return(status.Flag.Failed() && !status.Flag.HasBestEffort());
 }
Ejemplo n.º 5
0
 public static bool Failed(this OperationStatus status)
 {
     return(status.Flag.Failed());
 }
Ejemplo n.º 6
0
 public static bool Succeeded(this OperationStatus status)
 {
     return(status.Flag.Succeeded());
 }
 public ErrorSelectionResult(OperationStatus status) :
     base(status.MakeFail())
 {
 }
 protected NullSelectionResult(OperationStatus status) :
     base(status)
 {
 }
Ejemplo n.º 9
0
 public static bool Failed(this OperationStatus status)
 => status.Flag.Failed();
Ejemplo n.º 10
0
 public static bool Succeeded(this OperationStatus status)
 => status.Flag.Succeeded();