Beispiel #1
0
        public static async Task ComputeRefactoringsAsync(RefactoringContext context, ArgumentSyntax argument)
        {
            if (context.IsAnyRefactoringEnabled(RefactoringIdentifiers.AddCastExpression, RefactoringIdentifiers.AddToMethodInvocation) &&
                argument.Expression?.IsMissing == false &&
                context.SupportsSemanticModel)
            {
                SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(argument.Expression).ConvertedType;

                if (typeSymbol?.IsErrorType() == false)
                {
                    IEnumerable <ITypeSymbol> newTypes = argument
                                                         .DetermineParameterTypes(semanticModel, context.CancellationToken)
                                                         .Where(f => !typeSymbol.Equals(f));

                    ModifyExpressionRefactoring.ComputeRefactoring(context, argument.Expression, newTypes, semanticModel);
                }
            }
        }