Closed joaofbantunes closed 8 months ago
Can confirm reproduction, System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
is thrown.
Investigating, thanks
tracking via #87
Just tested it: everything working as expected.
Thanks!
Describe the bug
When building a sample application using minimal APIs and top level statements (sample linked below), it seems like the source generation isn't working as expected. Even though adding the
[module:DapperAot]
, compiling producesWarning DAP005 : 1 candidate Dapper methods detected, but none have Dapper.AOT enabled
, and running the application results in the expected errors, due to not being able to use dynamic code generation under Native AOT.If I move the code to a static class and map the endpoint, then the warning disappears and everything works as expected.
I imagine this isn't a very relevant issue, as in non-sample code, it's unlikely to have queries in top level statements, but just in case it's an unknown issue (or maybe I'm using it wrong), I thought of reporting.
Where are you seeing this?
To Reproduce Sample code Note: out of the box this code works, because the direct route to code is commented out and replaced with a static class, but reverting things, we can see the reported issue.
Expected behavior
Source generation works regardless of where the queries are used.
However, if supporting this scenario is not worth the effort, maybe include it as a known limitation in the docs.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.