public sealed class GameSystemGeneratorDeclares every system this assembly puts in a game's frame, before any of its code runs.
Remarks
The other two generators here register something a file may name; this one registers something a frame is made of. A project's system set used to exist only as the imperative body of its Game.OnInitialise, so the editor could list a project's ISystem types by reflection and could not run one of them. What crosses instead is a declaration plus a constructor call written at compile time.
⚠ The constructor is the service list, and the emitted factory is why there is no reflection. ConstructorInfo.Invoke would have made this a small DI container, which is the thing ServiceRegistry's remarks refuse on NativeAOT grounds. A generator already knows every parameter's type, so it writes the new with the casts in it and the runtime does a dictionary lookup per parameter and nothing else.
⚠ One public constructor, and the diagnostic says so. Two would make "which services does this system need" a question with two answers and no way to choose between them; none would make it unconstructible. Both are perfectly good code that is not declarable, which is worth a message rather than a compile error in generated source.
Methods (1)
public void Initialize(IncrementalGeneratorInitializationContext context)Called to initialize the generator and register generation steps via callbacks on the
Used by (1)
- GameSystemRegistrationTestsVixen.Engine.Generators.Tests