Inheritance: MethodInvocationAsyncRewriter
		public static List<ValidatorResult> Validate(MethodDeclarationSyntax methodSyntax, IAsyncRewriterLogger log, CompilationLookup extensionMethodLookup, SemanticModel semanticModel, HashSet<ITypeSymbol> excludeTypes, ITypeSymbol cancellationTokenSymbol)
		{
			var validator = new AsyncMethodValidator(log, extensionMethodLookup, semanticModel, excludeTypes, cancellationTokenSymbol, methodSyntax);

			validator.Visit(methodSyntax);

			return validator.results;
		}
Exemple #2
0
        public static List <ValidatorResult> Validate(MethodDeclarationSyntax methodSyntax, IAsyncRewriterLogger log, CompilationLookup extensionMethodLookup, SemanticModel semanticModel, HashSet <ITypeSymbol> excludeTypes, ITypeSymbol cancellationTokenSymbol)
        {
            var validator = new AsyncMethodValidator(log, extensionMethodLookup, semanticModel, excludeTypes, cancellationTokenSymbol, methodSyntax);

            validator.Visit(methodSyntax);

            return(validator.results);
        }
Exemple #3
0
        private void ValidateAsyncMethod(MethodDeclarationSyntax methodSyntax, SemanticModel semanticModel)
        {
            var methodSymbol = (IMethodSymbol)ModelExtensions.GetDeclaredSymbol(semanticModel, methodSyntax);
            var results      = AsyncMethodValidator.Validate(methodSyntax, log, this.lookup, semanticModel, excludedTypes, cancellationTokenSymbol);

            if (results.Count > 0)
            {
                foreach (var result in results)
                {
                    if (!result.ReplacementMethodSymbol.Equals(methodSymbol))
                    {
                        log.LogWarning($"Async method call possible in {result.Position.GetLineSpan()}");
                        log.LogWarning($"Replace {result.MethodInvocationSyntax.NormalizeWhitespace()} with {result.ReplacementExpressionSyntax.NormalizeWhitespace()}");
                    }
                }
            }
        }