Skip to content

Aot gen - #1965

Closed
TimothyMakkison wants to merge 3 commits into
reactiveui:mainfrom
TimothyMakkison:aot_gen
Closed

Aot gen#1965
TimothyMakkison wants to merge 3 commits into
reactiveui:mainfrom
TimothyMakkison:aot_gen

Conversation

@TimothyMakkison

@TimothyMakkison TimothyMakkison commented Apr 3, 2025 •

Copy link
Copy Markdown
Collaborator

Incomplete source generated refit logic. Needless to say this PR is still in progress, I tried to throw it together.

Future Plans

  • Fix the todos
  • I need to do a lot of refactoring
  • Check logic
  • Add Query and MultiPart support
  • Hopefully figure out how to reference Refittypes in the source generator without it breaking
    • This is why I had to add the Configuration types
  • If my understanding of AOT is correct I can safely get the interface MethodInfo and pass it to functions.
  • Support Refit should emit diagnostics for invalid interfaces #1885
  • Rewrite half the tests to work with source generated logic :(

If we go ahead with this a couple of things may break.

image

@TimothyMakkison

TimothyMakkison commented Apr 4, 2025 •

Copy link
Copy Markdown
Collaborator Author

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'
    }
}

@glennawatson

Copy link
Copy Markdown
Contributor

Thanks for taking a swing at this @TimothyMakkison. This is an explicitly-incomplete draft (conflicting, ~14 months stale) and the AOT / source-gen direction is being carried forward elsewhere (see #1389), so closing to keep the PR list clean. No problem at all picking it back up — reopen or open a fresh PR against current main if you return to the AOT gen work.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants