// TODO: Support inlining of expressions so this passes // e.g. https://referencesource.microsoft.com/#system.data.linq/SqlClient/Query/Funcletizer.cs,ccef8437bc51e04e // e.g. https://github.com/aspnet/EntityFrameworkCore/blob/98f41f7cc483d1688c23017fbc495a709f308cfb/src/EFCore/Query/ExpressionVisitors/Internal/ParameterExtractingExpressionVisitor.cs#L101 // e.g. https://github.com/RxDave/Qactive/blob/6cd5a058082562128d51c50e3ac8bd393ea6015e/Source/Qactive/LocalEvaluationVisitor.cs public void Should_inline_etcetera() { var serviceProvider = new CapturingAsyncQueryServiceProvider(); var client = new QxAsyncQueryClient(serviceProvider: serviceProvider); _ = client.GetEnumerable <string, int>("Test1")("A").SelectMany(l => GetQueryableFromLocalMethod(client, "Test2", "B").Select(r => l + r)).GetAsyncEnumerator(); }
public void GetEnumerable1_should_refer_to_enumerables_as_unbound_parameters() { var serviceProvider = new CapturingAsyncQueryServiceProvider(); var client = new QxAsyncQueryClient(serviceProvider: serviceProvider); _ = client.GetEnumerable <int>("Test").GetAsyncEnumerator(); AssertIsKnownResourceInvocation( actualExpression: serviceProvider.CapturedExpression, expectedKnownResourceType: typeof(Func <IAsyncQueryable <int> >), expectedKnownResourceName: "Test"); }
public void GetEnumerable3_should_refer_to_enumerables_as_unbound_parameters() { var serviceProvider = new CapturingAsyncQueryServiceProvider(); var client = new QxAsyncQueryClient(serviceProvider: serviceProvider); _ = client.GetEnumerable <string, bool, int>("Test")("1", false).GetAsyncEnumerator(); AssertIsKnownResourceInvocation( actualExpression: serviceProvider.CapturedExpression, expectedKnownResourceType: typeof(Func <string, bool, IAsyncQueryable <int> >), expectedKnownResourceName: "Test", /* expectedArguments: */ (typeof(string), "1"), (typeof(bool), false)); }
public void GetEnumerable1_should_replace_closed_over_GetEnumerable1_calls_with_unbound_parameters() { var serviceProvider = new CapturingAsyncQueryServiceProvider(); var client = new QxAsyncQueryClient(serviceProvider: serviceProvider); _ = client.GetEnumerable <int>("Test1").SelectMany(l => client.GetEnumerable <int>("Test2").Select(r => l + r)).GetAsyncEnumerator(); Assert.Equal(ExpressionType.Call, serviceProvider.CapturedExpression.NodeType); var methodCallExpression = (MethodCallExpression)serviceProvider.CapturedExpression; var test1Expression = methodCallExpression.Arguments[0]; var test2Expression = ((MethodCallExpression)((LambdaExpression)((UnaryExpression)methodCallExpression.Arguments[1]).Operand).Body).Arguments[0]; AssertIsKnownResourceInvocation( actualExpression: test1Expression, expectedKnownResourceType: typeof(Func <IAsyncQueryable <int> >), expectedKnownResourceName: "Test1"); AssertIsKnownResourceInvocation( actualExpression: test2Expression, expectedKnownResourceType: typeof(Func <IAsyncQueryable <int> >), expectedKnownResourceName: "Test2"); }