-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Q: AOT and composite type reflection #63670
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
First question would be about your perf constraints - can you go with |
I want to make it as good as I can for a reasonable effort. I'll try the boxing approach. If I still like to keep the |
But if you have guarantees that You only need to make sure if (string.Empty.Length > 0)
{
Writer w = default;
WriteDictionaryCore<int, object>(ref w, null);
WriteDictionaryCore<int, int>(ref w, null);
WriteDictionaryCore<object, object>(ref w, null);
} This approach works as long as the list of valuetypes you're operating on has a statically knowable bound. List of reference types doesn't matter because of how generic sharing works. |
How about introducing a generic version of For example: private readonly MethodInfo method = typeof(Foo).GetMethod("Bar"); // the analyzer recognized `Foo.Bar` from class initializer
void Test()
{
var m = method.MakeGenericMethod<int, int>(); // given that the analyzer already knows `method` is `Foo.Bar`, add `Foo.Bar<int, int>` into the dependency graph
m.Invoke(1, 2);
} |
Do you have a real-world scenario where this would help? In your example, if we statically know the method, and statically know the arguments, the user should just do: void Test()
{
Foo.Bar<int, int>.Invoke(1, 2);
} It looks like #81204 combined with dotnet/linker#2482 |
It doesn't help here because we can't get the generic types. From |
@MichalStrehovsky, thanks for your suggestions. I will try them, and may get back if I have additional questions. |
I'm trying to make some code AOT friendly, and I'm not sure how to go about it.
The code uses the .NET type system to represent protocol types. The types can be basic types, but there are also composite types such as arrays, structs, and dictionaries.
The following example uses
MakeGenericMethod
to deal with the composite types, and I'm not sure that will work with AOT? and what I can do to to make it AOT friendly?cc @MichalStrehovsky
The text was updated successfully, but these errors were encountered: