-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Native AOT warnings #5258
Comments
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better! |
NLog uses compiled expression trees to optimize speed for doing object-reflection of custom logging-objects. Ex: var v = new { Amount = 108, Message = "Hello" };
_logger.Info("{@Hello}", v); // Uses reflection I'm guessing that is also why your build also warns about
When reading about PublishAOT then it says:
When using PublishAOT then there is no JIT-compiler available for optimizing Expression-Trees, and I'm guessing that is why that warnings are generated. I'm not sure there is anyway to work-around this, besides waiting for NLog v6 that hopefully will extract the use of Expression-Trees into a separate nuget-package. Or maybe Microsoft will optimize their support for Expression-Trees in NET8 / NET9 so it no longer gives build-warnings. Until that happens, then you have to live with using PublishReadyToRun If you find places where NLog can be optimized in regard to trimming / ready-to-run / AOT, then pull-requests are most wellcome. |
Getting the following warnings from NLog TestTrimPublish-example-project when using
Looks like I guess all the other location that uses Also interesting that Also interesting that |
Closing as duplicate of #3366 |
Current work-around is probably specifying <Project>
<ItemGroup>
<RdXmlFile Include="rd.xml" />
</ItemGroup>
</Project> rd.xml: <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!-- .NET Native fix -->
<Assembly Dynamic="Required All" Name="NLog"/>
</Application>
</Directives> But unsure if it will remove warnings. |
NLog 5.2 just got released, which removes trim warnings.
Therefore, all issues related to that got closed, namely #5198 and #3777.
However, compiling for Native AOT still gives AOT warnings. Is this a separate topic, or was that intended to be fixed in 5.2 as well?
Here's a screenshot of a very simple reproduction. I can put the repro on github if needed.
NLog version: 5.2.0
Platform: .NET 7
The text was updated successfully, but these errors were encountered: