-
Notifications
You must be signed in to change notification settings - Fork 199
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
Issues while using efcore with NativeAOT #733
Comments
Looking at the code, we probably need RD.XML to keep all methods on DateTime: Hopefully these places will be fixed in EF as they're working on dotnet/efcore#21894. If this reflection wasn't wrapped in the GetRequiredRuntimeMethod helper, the compiler would actually figure this out on it's own ( |
You can add |
Thanks @MichalStrehovsky .
My rd.xml:
Update: fixed by adding:
|
Now I'm getting <Directives>
<Application>
<Assembly Name="Microsoft.EntityFrameworkCore">
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.EntryCurrentValueComparer`1[[System.Int32, System.Private.CoreLib]]" Dynamic="Required All" />
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.Int32, System.Private.CoreLib]]" Dynamic="Required All" />
<Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[efaottest.Table1, efaottest],[System.Int32, System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
<Method Name="CreateGeneric" Dynamic="Required All">
<GenericArgument Name="efaottest.Table1, efaottest" />
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
<Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
<Method Name="CreateGeneric" Dynamic="Required All">
<GenericArgument Name="efaottest.Table1, efaottest" />
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`1[[System.Int32,System.Private.CoreLib]]" Dynamic="Required All" />
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`2[[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMapFactoryFactory" Dynamic="Required All">
<Method Name="CreateFactory" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
<Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.PropertyAccessorsFactory" Dynamic="Required All">
<Method Name="CreateGeneric" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry" Dynamic="Required All">
<Method Name="ReadStoreGeneratedValue" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="ReadTemporaryValue" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="ReadOriginalValue" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="ReadRelationshipSnapshotValue" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
</Assembly>
<Assembly Name="mscorlib">
<Type Name="System.DateTime" Dynamic="Required All">
<Method Name="AddYears" Dynamic="Required" />
<Method Name="AddMonths" Dynamic="Required" />
<Method Name="AddDays" Dynamic="Required" />
<Method Name="AddHours" Dynamic="Required" />
<Method Name="AddMinutes" Dynamic="Required" />
<Method Name="AddSeconds" Dynamic="Required" />
</Type>
</Assembly>
</Application>
</Directives> Seems that I hit this line: Line 52 in 9f1e27d
I think if it can print which type is looking for, it will be eaiser to resolve. |
I think there's a problem with how generic virtual methods get rooted from RD.XML. Maybe you need to root both the slot declaring method (the method that introduces the virtual method), and the override. I'll need to take a look at that at some point. If you have this under a debugger (e.g. Visual Studio), you can look what thing the EEType pointer is pointing at. E.g. type this into the "Immediate" window of VS: (void*)0x00007FF629DD46F0 (This is an address from the above error message - you should obviously use the current address.) |
(And if you use WinDbg, you would use the ln command with the address.) |
Yeah, I solved the issue of Full output while navigating to
|
Can this line print the type and method signature so that I can know which it is looking for? Line 52 in 9f1e27d
I'm stuck here because no information except a line with "GVM resolution failure" was printed. |
Sure - #746. Thanks for your persistence! |
It turns out that the resolution failure because the default interface method: But I cannot make it work by adding: <Type Name="Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger" Dynamic="Required All">
<Method Name="NeedsEventData" Dynamic="Required">
<GenericArgument Name="System.Object, System.Private.CoreLib" />
</Method>
<Method Name="NeedsEventData" Dynamic="Required" />
</Type> ilc threw error about either |
This is a minimal repro: using System;
namespace DimRepro
{
interface IFoo
{
void Bar(string baz) => Console.WriteLine(baz);
void Bar<T>(T what, string baz) => Console.WriteLine(what.ToString() + baz);
}
class Test : IFoo
{
}
class Program
{
static void Main(string[] args)
{
IFoo x = new Test();
x.Bar("test");
x.Bar<int>(5, "test");
}
}
} Output:
Should I open a separate issue for this? |
Default generic interface methods support just merged. The nuget package with support should be out soon. Hopefully this will let things make progress. |
I found there's a line which is incompatible with NativeAOT: https://github.com/dotnet/efcore/blob/b3619b49eb43fdeb8c93d167f2bc1fd67c2735ec/src/Microsoft.Data.Sqlite.Core/Utilities/BundleInitializer.cs#L20, but thanks to the Finally make it work as expected. For anyone wants to have a try, I created a sample project showing how to integrate efcore (SQLite) with NativeAOT: https://github.com/hez2010/EFCore.NativeAOT Thanks @MichalStrehovsky for your great work. |
Since major issue preventing efcore being used with NativeAOT has been resolved, I'm closing this. BTW, is it possible to make |
Thank you @hez2010 for working on this! It's nice to have a sample we can point to!
You might need to add the type/method in question ( We don't currently do analysis of Assembly.GetType. If we did it, this pattern might just work. Tracked here: dotnet/linker#1884 |
After efcore fixed infinite recursive generics, I hit this exception while trying to use efcore daily build with SQLite using NativeAOT:
A simple repro project:
efaottest.zip
The text was updated successfully, but these errors were encountered: