Aot gen by TimothyMakkison · Pull Request #1965 · reactiveui/refit

Okay, after reading my notes and doing a couple of experiments:

  • We might be able to support attributes inheriting from attributes, it will be very awkward and doable, although I'm not sure it would be worth it.
    • this relies on GetCustomAttributes working In aot. The generated code will be super janky
  • Query parameters won't be able to support runtime serialisation. (See below)
    • It will be possible to create a compile time serializer, but it won't handle inheritance.
    • I could make this backwards compatible by:
      • Making users add an attribute somewhere to enable AotRefit. This would tell the generator to emit a compile time query serialiser.
      • Emit some code that tries to use runtime serialisation, if it fails we switch to a compile time version.
        • This would generate a load of
      • Determine if the project has PublishAot enabled (I don't know if this is possible)
        and emit compile time serialisation code
void Descend([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type t)
{
    foreach (var p in t.GetProperties())
    {
        Console.WriteLine(p.Name);
        Descend(p.PropertyType); //  't' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods'
    }
}