-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
AOT support for .NET #283
Comments
This looks similar to #220, but this time it will be easier to investigate since it only uses the standard .NET tooling :) |
I can't reproduce the failure. Can you share your csproj and the command you used to generate your exe? I used Visual Studio 2022 Version 17.6.0 Preview 4.0 and .NET 8 preview 3 with the following csproj: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamicExpresso.Core" Version="2.16.0" />
</ItemGroup>
</Project> Program.cs: using DynamicExpresso;
namespace ConsoleApp1;
internal class Program
{
static void Main(string[] args)
{
var interpreter = new Interpreter();
var result = interpreter.Eval("8 / 2 + 2");
Console.WriteLine($"result:{result}");
}
} dotnet command:
I get a lot of warnings during publish:
but I still get the expected result when I execute the exe:
|
I think you are missing something important; you are running the dotenet .exe, not the native code executable. |
Ah right, I get the AOT error when running the native exe. I'll see if I can find a solution, but I'm not sure it's possible since DynamicExpresso tries to instantiate generic types. |
I will open an issue with the .NET team related to this issue. In the meantime, it would be helpful to start paying attention to trimming warnings on DynamicExpresso library to prepare the library to be used in AOT scenarios that will become much more common after .NET7 and beyond. About the MakeGenericType, the problematic scenario is using a parameter Type into it and not a concrete type which AOT has no problem with. I have a working sample test were i trick the AOT tooling by forcing some common Func<T..> to be not trimmed. The good news is that the library did work well in native AOT after that manual step so it seems that we could be close. |
It seems this library does not have AOT support, i tried a basic sample and the AOT tooling give me warnings and the generated exe throws an exception.
Tried a trivial 3 lines sample on a Console app:
The build give me this:
When running it give me this:
The text was updated successfully, but these errors were encountered: