-
Notifications
You must be signed in to change notification settings - Fork 127
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
Track MethodInfo, PropertyInfo, and FieldInfo through reflection uses #3037
Comments
We would also need a "typed stack" because of the We did this kind of analysis in .NET Native (where illinker dataflow analysis originally comes from). The logic wasn't ported over to illink because it doesn't fundamentally move the needle. We kept adding patterns for all sorts of things (.NET Native could also model System.Reflection.Assembly, return types of MethodInfo's, some of At the time .NET Native was getting defunded, we were thinking about modeling string concatenation operations because there was an app that concatenated type name and namespace and fed it to My 2 cents is that I think it would be better use of time to just rewrite the code in EF to use the primitives we already support. |
I agree with Michal about the pattern above. That said we have other reasons to support "typed stack": If/when we do that, then adding this is not such a stretch. But I do agree that we should first see how common this is. I remember there was a more appealing case for something like this which was about the ability to store MethodInfo in a static/readonly field for perf reasons - and linker being able to recognize it (currently such pattern has no way to be annotated without warning). I think a more likely thing we would support is a pattern like: Type type = typeof(TestType).GetField("TestField").FieldType;
type.GetMethods(); // No warning - currently this will warn That is more of a "static" approach. The The above code can be rewritten with the |
Found the issue discussing ability to store |
If we want to take on this work, my suggestion would be to be very crisp about scoping. Otherwise it's easy to spend several man-months doing tiny features that we wouldn't have done if we know it's a several months big workitem (i.e. this is a rabbit hole and it's very easy to spend unjustifiable amounts of time on it because it's all broken into increments so small that they're not part of planning). |
For codebases that use reflection extensively, this could simplify transitioning to trim compatibility.
For example, EFCore.Sqlite has this code:
This can technically be statically analyzed, and we know the exact types we need:
Windows.Storage.ApplicationData
,Windows.Storage.ApplicationData.Current
, the type ofWindows.Storage.ApplicationData.Current
, and its propertyLocalFolder
, the type ofLocalFolder
, and its propertyPath
.In addition, we may be able to make
MethodInfo.MakeGenericMethod
AOT-Friendly if we know to keep the method in its generic form and the type being made generic.Related to #2482
The text was updated successfully, but these errors were encountered: