Thank you everyone for rubber ducking. The solution was to add “where T : class” to the action. After plenty of reloading and regenerating AOTClasses it now works fine.
PS: Could you please add a way to automate “Generate AOTClasses.cs and link.xml Files”, since I don’t see why my input is needed to find the same paths over and over, but I have to run this like 10 times a day and it’s gotten pretty annoying.
EDIT: Oh, and yeah, obviously with the change above I’m sacrificing being able to use value types, but this is good enough for me. If someone has a solution that will also work for value types, that would be interesting.