Releases: PaulNonatomic/ServiceKitAnalyzers
Releases · PaulNonatomic/ServiceKitAnalyzers
0.2.0
ServiceKit.Analyzers v0.2.0
TL;DR
- New safety rules for injection and cancellation
- Style nudge to standardise call sites
- Smarter SK001 with one-click interface swap
- Cleaner packaging (no RS warnings once you update headers/messages)
New Analyzers
-
SK002 — Injected field visibility/shape
Ensures[InjectService]fields are private, instance (non-static), mutable (non-readonly), and not[SerializeField]
Severity: Warning • Code fix: Makeprivate, stripstatic/readonly, remove[SerializeField] -
SK004 — Cancellation required for injection
FlagsInjectServicesAsync(...).ExecuteAsync()chains that omit.WithCancellation(...)
Severity: Warning • Code fixes:- Insert
.WithCancellation(destroyCancellationToken); or - Replace with
.ExecuteWithCancellationAsync(destroyCancellationToken)
- Insert
-
SK010 — Prefer wrapper over inline cancellation
Suggests.ExecuteWithCancellationAsync(token)instead of.WithCancellation(token).ExecuteAsync()
Severity: Info • Code fix: Convert chain to wrapper and remove.WithCancellation(...)
Updated Analyzers
- SK001 — Injected member should be an interface
Now checks fields and properties, improves attribute detection, and adds a code fix to change the declaration to a discovered interface implemented by the concrete type
Companion runtime addition (ServiceKit)
To support SK004/SK010 ergonomically, ServiceInjectionBuilder now exposes:
public Task ExecuteWithCancellationAsync(CancellationToken destroyCancellationToken);
public void ExecuteWithCancellation(CancellationToken destroyCancellationToken);Typical usage
await _serviceKitLocator.InjectServicesAsync(this)
.WithTimeout()
.ExecuteWithCancellationAsync(destroyCancellationToken);Migration notes
- After updating, you may see SK004 warnings on older call sites; use the quick-fix to add
.WithCancellation(...)or switch to the wrapper - SK010 will appear as an info suggestion; accept to standardise on the wrapper
- SK002 may trigger on public/static/readonly or
[SerializeField]injected fields; apply the one-click fix
Packaging & housekeeping
- Release files updated (
AnalyzerReleases.Shipped.md,AnalyzerReleases.Unshipped.md) with correct headers - Diagnostic messages follow RS1032 formatting (single sentence, no trailing period)
Install / Update (Unity)
- Build the analyzer DLL
- Place at:
Assets/Analyzers/ServiceKit/ServiceKit.Analyzers.dll - Ensure
Assets/csc.rspcontains:-analyzer:"Assets/Analyzers/ServiceKit/ServiceKit.Analyzers.dll"
0.0.0
0.0.0