Пример #1
0
        public void ResolveMethod_should_return_original_method_info()
        {
            var typeResolver = new TypeResolver();

            System.Reflection.TypeInfo   type           = typeof(TypeHiding).GetTypeInfo();
            System.Reflection.MethodInfo methodInfo     = type.GetDeclaredMethod(nameof(TypeHiding.Method));
            Aqua.TypeSystem.MethodInfo   mappedMethod   = new Aqua.TypeSystem.MethodInfo(methodInfo);
            System.Reflection.MethodInfo resolvedMethod = mappedMethod.ResolveMethod(typeResolver);

            resolvedMethod.ShouldBe(methodInfo);
        }
        public void ResolveMethod_ExplicitCast_should_return_original_method_info()
        {
            var typeResolver = new TypeResolver();

            Expression <Func <decimal?, double?> > expr = x => (double?)x;

            System.Reflection.MethodInfo methodInfo     = ((UnaryExpression)expr.Body).Method;
            Aqua.TypeSystem.MethodInfo   mappedMethod   = new Aqua.TypeSystem.MethodInfo(methodInfo);
            System.Reflection.MethodInfo resolvedMethod = mappedMethod.ResolveMethod(typeResolver);

            resolvedMethod.ShouldBe(methodInfo);
        }
Пример #3
0
        public void ResolveMethod_should_return_original_method_info(bool dirtyCache)
        {
            var typeResolver = new TypeResolver();

            Type type1 = TestObjects1.Helper.GetAnonymousType1();
            Type type2 = TestObjects2.Helper.GetAnonymousType1();

            // "Pollute" the type cache
            if (dirtyCache)
            {
                typeResolver.ResolveType(
                    new Aqua.TypeSystem.TypeInfo(typeof(IEnumerable <>).MakeGenericType(type2)));
            }

            System.Reflection.MethodInfo methodInfo = GetType()
                                                      .GetMethod(nameof(SayHello), AnyStatic)
                                                      .MakeGenericMethod(type1);

            System.Reflection.MethodInfo resolvedMethod =
                new Aqua.TypeSystem.MethodInfo(methodInfo).ResolveMethod(typeResolver);

            resolvedMethod.ShouldBe(methodInfo);
        }
 private System.Reflection.MethodInfo ResolveMethod(Aqua.TypeSystem.MethodInfo method)
 => method.ResolveMethod(_typeResolver)
 ?? throw new RemoteLinqException($"Failed to resolve method '{method}'");