GetArgumentsWithConversions() public method

Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method.
public GetArgumentsWithConversions ( ) : IList
return IList
        public InvocationResolveResult(ResolveResult targetResult, OverloadResolution or, ITypeResolveContext context)
            : base(
                or.IsExtensionMethodInvocation ? null : targetResult,
                or.GetBestCandidateWithSubstitutedTypeArguments(),
                context)
        {
            this.OverloadResolutionErrors = or.BestCandidateErrors;
            this.argumentToParameterMap   = or.GetArgumentToParameterMap();
            this.Arguments = or.GetArgumentsWithConversions();

            this.IsExtensionMethodInvocation = or.IsExtensionMethodInvocation;
            this.IsExpandedForm             = or.BestCandidateIsExpandedForm;
            this.IsLiftedOperatorInvocation = or.BestCandidate is OverloadResolution.ILiftedOperator;
        }
		public InvocationResolveResult(ResolveResult targetResult, OverloadResolution or, ITypeResolveContext context)
			: base(
				or.IsExtensionMethodInvocation ? null : targetResult,
				or.GetBestCandidateWithSubstitutedTypeArguments(),
				context)
		{
			this.OverloadResolutionErrors = or.BestCandidateErrors;
			this.argumentToParameterMap = or.GetArgumentToParameterMap();
			this.Arguments = or.GetArgumentsWithConversions();
			
			this.IsExtensionMethodInvocation = or.IsExtensionMethodInvocation;
			this.IsExpandedForm = or.BestCandidateIsExpandedForm;
			this.IsLiftedOperatorInvocation = or.BestCandidate is OverloadResolution.ILiftedOperator;
		}
Esempio n. 3
0
        /// <summary>
        /// Resolves an invocation.
        /// </summary>
        /// <param name="target">The target of the invocation. Usually a MethodGroupResolveResult.</param>
        /// <param name="arguments">
        /// Arguments passed to the method.
        /// The resolver may mutate this array to wrap elements in <see cref="ConversionResolveResult"/>s!
        /// </param>
        /// <param name="argumentNames">
        /// The argument names. Pass the null string for positional arguments.
        /// </param>
        /// <returns>InvocationResolveResult or UnknownMethodResolveResult</returns>
        public ResolveResult ResolveInvocation(ResolveResult target, ResolveResult[] arguments, string[] argumentNames = null)
        {
            // C# 4.0 spec: §7.6.5

            if (SpecialType.Dynamic.Equals(target.Type))
                return DynamicResult;

            MethodGroupResolveResult mgrr = target as MethodGroupResolveResult;
            if (mgrr != null) {
                OverloadResolution or = mgrr.PerformOverloadResolution(compilation, arguments, argumentNames, conversions: conversions);
                if (or.BestCandidate != null) {
                    return or.CreateResolveResult(mgrr.TargetResult);
                } else {
                    // No candidate found at all (not even an inapplicable one).
                    // This can happen with empty method groups (as sometimes used with extension methods)
                    return new UnknownMethodResolveResult(
                        mgrr.TargetType, mgrr.MethodName, mgrr.TypeArguments, CreateParameters(arguments, argumentNames));
                }
            }
            UnknownMemberResolveResult umrr = target as UnknownMemberResolveResult;
            if (umrr != null) {
                return new UnknownMethodResolveResult(umrr.TargetType, umrr.MemberName, umrr.TypeArguments, CreateParameters(arguments, argumentNames));
            }
            UnknownIdentifierResolveResult uirr = target as UnknownIdentifierResolveResult;
            if (uirr != null && CurrentTypeDefinition != null) {
                return new UnknownMethodResolveResult(CurrentTypeDefinition, uirr.Identifier, EmptyList<IType>.Instance, CreateParameters(arguments, argumentNames));
            }
            IMethod invokeMethod = target.Type.GetDelegateInvokeMethod();
            if (invokeMethod != null) {
                OverloadResolution or = new OverloadResolution(compilation, arguments, argumentNames, conversions: conversions);
                or.AddCandidate(invokeMethod);
                return new CSharpInvocationResolveResult(
                    target, invokeMethod, //invokeMethod.ReturnType.Resolve(context),
                    or.GetArgumentsWithConversions(), or.BestCandidateErrors,
                    isExpandedForm: or.BestCandidateIsExpandedForm,
                    isDelegateInvocation: true,
                    argumentToParameterMap: or.GetArgumentToParameterMap());
            }
            return ErrorResult;
        }
Esempio n. 4
0
		ResolveResult CreateResolveResultForUserDefinedOperator(OverloadResolution r, System.Linq.Expressions.ExpressionType operatorType)
		{
			if (r.BestCandidateErrors != OverloadResolutionErrors.None)
				return r.CreateResolveResult(null);
			IMethod method = (IMethod)r.BestCandidate;
			return new OperatorResolveResult(method.ReturnType, operatorType, method,
			                                 isLiftedOperator: method is OverloadResolution.ILiftedOperator,
			                                 operands: r.GetArgumentsWithConversions());
		}