コード例 #1
0
        public FindingReslt FindEquivalentAsyncMethod(IMethod originalMethod, IType invokedType)
        {
            if (!originalMethod.IsValid())
            {
                return(FindingReslt.CreateFail());
            }

            var @class = classForSearchResolver.GetClassForSearch(originalMethod, invokedType);

            if (@class == null)
            {
                return(FindingReslt.CreateFail());
            }

            foreach (var candidateMethod in @class.Methods)
            {
                if (methodFindingChecker.NeedSkip(originalMethod, candidateMethod))
                {
                    continue;
                }

                var parameterCompareResult = parameterComparer.ComparerParameters(candidateMethod.Parameters, originalMethod.Parameters);
                if (!parameterCompareResult.CanBeConvertedToAsync())
                {
                    continue;
                }

                return(new FindingReslt
                {
                    Method = candidateMethod,
                    ParameterCompareResult = parameterCompareResult,
                });
            }
            return(FindingReslt.CreateFail());
        }
コード例 #2
0
        public FindingReslt FindEquivalentAsyncMethod(IParametersOwner originalMethod, IType invokedType)
        {
            if (!originalMethod.IsValid())
            {
                return(FindingReslt.CreateFail());
            }

            var @class = classForSearchResolver.GetClassForSearch(originalMethod, invokedType);

            if (@class == null)
            {
                return(FindingReslt.CreateFail());
            }

            var originalReturnType = originalMethod.Type();

            foreach (var candidateMethod in @class.Methods)
            {
                if (originalMethod.ShortName + "Async" != candidateMethod.ShortName)
                {
                    continue;
                }

                var returnType = candidateMethod.Type();
                if (!returnType.IsTaskOf(originalReturnType))
                {
                    continue;
                }

                var parameterCompareResult = parameterComparer.ComparerParameters(candidateMethod.Parameters, originalMethod.Parameters);
                if (!parameterCompareResult.CanBeConvertedToAsync())
                {
                    continue;
                }

                return(new FindingReslt
                {
                    Method = candidateMethod,
                    ParameterCompareResult = parameterCompareResult,
                });
            }
            return(FindingReslt.CreateFail());
        }