Editor hint: service registered as concrete type but implements an interface#16
Open
PaulNonatomic wants to merge 1 commit into
Open
Editor hint: service registered as concrete type but implements an interface#16PaulNonatomic wants to merge 1 commit into
PaulNonatomic wants to merge 1 commit into
Conversation
…plements an interface The ServiceKit window now shows an amber 'i' badge on a service registered under its concrete type when that type implements a user-defined interface that is not itself registered in the locator. The tooltip suggests [Service(typeof(IFoo))]. This surfaces the common trap of a forgotten attribute, or one placed on an abstract base (where it has no effect because [Service] is not inherited) -- the runtime counterpart to analyzer rule SK006.
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
Adds a runtime/editor counterpart to analyzer rule SK006. In the ServiceKit window, a service that is registered under its concrete type but implements a user-defined interface — one that is not itself registered in the locator — now shows a small amber
ibadge. The tooltip suggests registering it as the interface with[Service(typeof(IFoo))].This surfaces, at a glance, the common traps:
[Service(typeof(IFoo))](service registered as its concrete type, consumers expect the interface).[Service]placed on an abstract base class, where it has no effect because the attribute is declaredInherited = false— exactly the V1→V2 migration trap.Behaviour / false-positive guards
serviceType.IsInterface→ no badge).System.*,UnityEngine.*,UnityEditor.*,Unity.*,Cysharp.*,Mono.*,Microsoft.*are filtered out.Files
Editor/ServiceKitWindow/ServiceItem.cs— hint computation + amber badge (inline-styled, class hookservice-interface-hintfor future theming).CHANGELOG.md— Unreleased entry.Validation
Self-reviewed; not yet compiled in Unity (no Unity available in this environment). Needs an editor compile + a quick visual check that the badge renders and the tooltip reads correctly. Happy to run an EditMode batchmode compile if you close Unity, as before.