Include events on the generated Singleton interface#8
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I<ClassName>interface alongside methods and properties;[SingletonInclude]/[SingletonIgnore]widened toAttributeTargets.Event.GameManagergrew aCountChangedevent and a test subscribes to it throughIGameManager— proves the event surfaces on the generated interface.Test plan
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).tests/generators-tests-2022-3-62/in Unity 2022.3.62 — confirm the package still loads on the older floor.[SingletonInclude] public event Action Foo;to a[Singleton]class and confirm the analyzer is happy andFooappears on the generated interface.