❔ Need Ideas. Switching from Reflections to Source Gen

I'm writting a game engine, currently using reflections to show what the User Assembly (the scripted parts) has types. Then register these types so we can access it easily at runtime. Currently using runtime reflections, I think this is a very messy implementation. And i think source gen could make this so much better. But I'm new to source gen, any ideas?
6 Replies
Hanprogramer
HanprogramerOP2y ago
Also I'm trying to prepare to switch to native AOT. Replacing all reflections would be better
reflectronic
reflectronic2y ago
if you have plugins (like, Assembly.Load) you will not be able to use NativeAOT or trimming without removing the use of Assembly.Load completely if you don't then it's much easier but you will have to explain how exactly the user code is hooked up to the engine. i can think of a few ways to address this but it depends on what exactly is being hooked up and how
Hanprogramer
HanprogramerOP2y ago
So it's currently like you said. I load using Assembly.Load. Then find a class that inherits IGame, then find the constructor then creates the instance. After that call a function .Start() from it. All happening using reflections. I also integrated the assembly with an editor using reflections. Basically the editor is like unity's
Hanprogramer
HanprogramerOP2y ago
Hanprogramer
HanprogramerOP2y ago
The entire system is also like Unity's where i have components and scene. The components have ComponentRegistry.Register(component) to register themselves to the engine but dont mind about the editor. I dont mind it being JIT for now. The exported game is the goal, i want it to be AOT if possible
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server