m31coding / M31.FluentAPI

Generate fluent builders for your C# classes with ease.
MIT License
94 stars 3 forks source link

Use UnsafeAccessorAttribute in dotnet8 instead of reflection #16

Open Genmutant opened 3 months ago

Genmutant commented 3 months ago

Would it be possible to generate private method accessors using UnsafeAccessorAttribute when targetting at least dotnet8? That would make it safe to use with NativeAOT and Trimming, as the accessed attributes are marked as used and not removed.

m31coding commented 3 months ago

Thank you for pointing this out! The UnsafeAccessorAttribute is indeed a great feature, and I would love to eliminate the reflection code. However, I plan to stick with .NET 6 until the end of the year, and I prefer not to complicate the code with conditional compilation directives (ifdefs).

Is there another way to address your issue? Are there possibilities for configuring the trimming, such as ignoring a specific class during the trimming process?

Best regards, Kevin

Genmutant commented 3 months ago

Yes, it's possible to manually force it to keep the complete classes when trimming. I haven't checked if AOT would still work though.

Thanks for your fast answer and work!