Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider obtaining method infos from compiler generated expressions (may help with UWP/.NET Native) #3294

Closed
divega opened this issue Oct 1, 2015 · 8 comments
Assignees
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. type-cleanup

Comments

@divega
Copy link
Contributor

divega commented Oct 1, 2015

Queryable uses this pattern:

       public static IQueryable<TSource> Where<TSource>(
           this IQueryable<TSource> source, 
           Expression<Func<TSource, bool>> predicate) 
       { 
           if (source == null) 
               throw Error.ArgumentNull("source"); 
           if (predicate == null) 
               throw Error.ArgumentNull("predicate"); 
           return source.Provider.CreateQuery<TSource>( 
               Expression.Call( 
                   null, 
                   GetMethodInfoOf(() => Queryable.Where( 
                       default(IQueryable<TSource>), 
                       default(Expression<Func<TSource, bool>>))), 
                   new Expression[] { source.Expression, Expression.Quote(predicate) } 
                   )); 
       } 
...
       private static MethodInfo GetMethodInfoOf<T>(Expression<Func<T>> expression) 
       { 
           var body = (MethodCallExpression)expression.Body; 
           return body.Method; 
       } 

We haven't tested yet if this actually helps but it avoids using reflection directly at runtime and in particular MakeGeneticMethod<T>() which is known to be problematic with .NET Native.

cc @natemcmaster @anpete

@rowanmiller rowanmiller added this to the 7.0.0 milestone Oct 2, 2015
@rowanmiller
Copy link
Contributor

@natemcmaster you may want to do this earlier to reduce directives for .NET Native

@natemcmaster
Copy link
Contributor

@divega
Copy link
Contributor Author

divega commented Oct 5, 2015

Interesting. Then does Queryable currently not work at all in .NET Native?

@natemcmaster
Copy link
Contributor

The problem is in Expression.Call. The overload used in the example above does not trigger a call to MakeGenericMethod

@divega
Copy link
Contributor Author

divega commented Oct 5, 2015

Still don't understand why it wouldn't work for us, sorry about that 😄 Will probably ask you in person.

@natemcmaster natemcmaster reopened this Oct 5, 2015
@natemcmaster
Copy link
Contributor

Discussed in person. Will investigate more.

@natemcmaster
Copy link
Contributor

After further investigation, refactoring our code to avoid calls to MakeGenericMethod is unnecessary, at least for the sake of .NET Native. With RuntimeTypeDiscoverer and the Scaffold-Directives command (see #4197), we can generate most of the rdxml necessary to make these calls work in current UWP tooling. Furthermore, updates to .NET Native include bug fixes that alleviate these problematic scenarios. I recommend closing this issue.

@divega
Copy link
Contributor Author

divega commented Feb 5, 2016

Closing as per @natemcmaster's comment.

@divega divega closed this as completed Feb 5, 2016
@divega divega added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label May 8, 2017
@divega divega removed this from the 1.0.0 milestone May 8, 2017
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. type-cleanup
Projects
None yet
Development

No branches or pull requests

4 participants