Open emrys90 opened 8 months ago
The AOT support is blocked by reflections code in AddObject
and AddObjectStatic
. If you don't use those, it might be already working.
The AOT support is blocked by reflections code in
AddObject
andAddObjectStatic
. If you don't use those, it might be already working.
Adding attributes to those methods can fix those warnings, and should be able to do so without changing any functionality. Here's a link to an article that explains how to support NativeAOT. https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/
If you don't use those, it might be already working.
It still produces warnings. Is there any way we can make it AOT-compatible using the guide suggested by @emrys90?
Ok, I tried now and the embedded XML serialiser creates all sort of pain. Basically, its Serialize
function must be annotated as incompatible, which also requires that the interface method must be annotated as well. Which then makes all serialisers incompatible, and nothing works.
I only see one option: remove XML from formats supported by default, move all XML stuff to the XML package (existing one). Thoughts?
Further research (I never used source generator provided by System.Text.Json
before) shows that the only way to make it work with trimming is to use JsonSerializerContext
created by the user. Therefore, there's no way to implement it with current set of serialisation abstractions as the context needs to be provided when calling the serialiser.
Which means that the scope of change is way beyond "just" adding some attributes as the whole serialisation story will be annotated and the only way it will work with trimming is to make calls without body and with responses that don't require deserialisation.
To me, it kind of defeats the purpose of using RestSharp at all.
It would be nice to have full NativeAOT support for RestSharp. It currently logs trimming warnings.