Skip to content

Releases: PaulNonatomic/ServiceKitAnalyzers

0.2.0

12 Aug 10:05

Choose a tag to compare

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: Make private, strip static/readonly, remove [SerializeField]

  • SK004 — Cancellation required for injection
    Flags InjectServicesAsync(...).ExecuteAsync() chains that omit .WithCancellation(...)
    Severity: Warning • Code fixes:

    1. Insert .WithCancellation(destroyCancellationToken); or
    2. Replace with .ExecuteWithCancellationAsync(destroyCancellationToken)
  • 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)

  1. Build the analyzer DLL
  2. Place at: Assets/Analyzers/ServiceKit/ServiceKit.Analyzers.dll
  3. Ensure Assets/csc.rsp contains:
    -analyzer:"Assets/Analyzers/ServiceKit/ServiceKit.Analyzers.dll"
    

0.0.0

11 Aug 23:50

Choose a tag to compare

0.0.0