Skip to content

Include events on the generated Singleton interface#8

Merged
migus88 merged 2 commits into
mainfrom
feat/singleton-interface-events
May 30, 2026
Merged

Include events on the generated Singleton interface#8
migus88 merged 2 commits into
mainfrom
feat/singleton-interface-events

Conversation

@migus88

@migus88 migus88 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Generator now projects public events onto the auto-generated I<ClassName> interface alongside methods and properties; [SingletonInclude] / [SingletonIgnore] widened to AttributeTargets.Event.
  • README updated to match (auto-mode now says method, property, and event).
  • Demo GameManager grew a CountChanged event and a test subscribes to it through IGameManager — proves the event surfaces on the generated interface.

Test plan

  • Open src/generators-unity/ in Unity 6000.4.0f1 → Test Runner → run EditMode (Unity 6 wasn't available locally; only the dotnet Release build was run, which succeeded and refreshed the package dll).
  • Open tests/generators-tests-2022-3-62/ in Unity 2022.3.62 — confirm the package still loads on the older floor.
  • Sanity: in the demo project, add [SingletonInclude] public event Action Foo; to a [Singleton] class and confirm the analyzer is happy and Foo appears on the generated interface.

migus88 added 2 commits May 30, 2026 17:44
Events were silently dropped by the formatter and by the auto-include
candidate check, so a public event on a [Singleton] class never appeared
on its generated interface. Format IEventSymbol as `event Type Name;`,
accept events in auto-mode, widen [SingletonInclude] / [SingletonIgnore]
to AttributeTargets.Event, and add a demo CountChanged event with a test
that subscribes through the interface.
The tests exercise [Dependency] resolution and the singleton lifecycle,
which only run in PlayMode. Drop the EditMode-only test runner reference
and Editor platform restriction so the [UnityTest] coroutines that yield
a frame for Start() can run.
@migus88 migus88 merged commit 8494fe7 into main May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant