Skip to content

Add Arc Roslyn analyzers and bundle all analyzers into the Cratis package#2308

Merged
woksin merged 4 commits into
mainfrom
feat/arc-roslyn-analyzers
Jun 20, 2026
Merged

Add Arc Roslyn analyzers and bundle all analyzers into the Cratis package#2308
woksin merged 4 commits into
mainfrom
feat/arc-roslyn-analyzers

Conversation

@woksin

@woksin woksin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

A single reference to the Cratis package now ships the full set of Cratis Roslyn analyzers, and several new analyzers guide developers and AI toward idiomatic Arc code.

Added

  • ARC0007 analyzer — warns when a [Command] is declared as a class instead of a record.
  • ARC0008 analyzer — warns when a [ReadModel] is declared as a class instead of a record.
  • ARC0009 analyzer — warns when a ConceptAs<T> is declared as a class instead of a record.
  • ARCCHR0002 analyzer — warns when a [Command] has multiple event source id candidates (EventSourceId, EventSourceId<T>, a type with an implicit conversion to EventSourceId, or [Key]) but does not implement ICanProvideEventSourceId; exempt when Handle returns only EventForEventSourceId.
  • ARCCHR0003 analyzer — warns when a reactor injects IEventLog instead of returning side-effect events.
  • ARCCHR0004 analyzer — warns when [EventType] specifies an explicit id (the type name is the identifier); generation stays allowed.

Changed

  • The Cratis meta package now bundles every Cratis analyzer (Arc, Arc.Chronicle, the Arc source generator, the Fundamentals type discovery generator, and the Metrics analyzer), so installing Cratis enables all analyzers without referencing the sub-packages directly.

woksin and others added 3 commits June 20, 2026 01:15
Introduce three model-bound analyzers in Arc.Core.CodeAnalysis that guide
developers toward the idiomatic Arc shape:

- ARC0007 — [Command] should be declared as a record
- ARC0008 — [ReadModel] should be declared as a record
- ARC0009 — a ConceptAs<T> should be declared as a record

Each rule is a Warning, matches types by fully-qualified name, and ships
with BDD specs covering the positive and negative cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduce three analyzers in Chronicle.CodeAnalysis that catch common
mistakes when wiring commands and events:

- ARCCHR0002 — a [Command] with multiple event source id candidates
  (EventSourceId, EventSourceId<T>, an implicit conversion to EventSourceId,
  or [Key]) must implement ICanProvideEventSourceId so the default event
  source id is explicit; exempt when Handle returns only EventForEventSourceId
- ARCCHR0003 — a reactor must not inject IEventLog; return side-effect events
  from the handler instead
- ARCCHR0004 — [EventType] should not specify an explicit id; the type name is
  the identifier (generation stays allowed)

Each rule ships with BDD specs. The spec harness now references Arc.Core and
the Chronicle event sequences assembly so command and event types resolve.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NuGet marks analyzer assets as private by default, so analyzers from
dependency packages do not flow transitively. A single reference to the
Cratis meta package therefore shipped none of the Cratis analyzers.

Pack every analyzer assembly directly into analyzers/dotnet/cs of the Cratis
package: the in-repo Arc and Arc.Chronicle analyzers and the Arc source
generator, plus the Fundamentals type discovery generator and the Metrics
analyzer from their restored packages (resolved per-TFM via
TargetsForTfmSpecificContentInPackage). The Architecture analyzers are wired
behind IncludeArchitectureAnalyzers until that package is published.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@woksin woksin added the minor label Jun 19, 2026
@github-actions

Copy link
Copy Markdown

NuGet packages for this PR, e.g. Cratis.Arc:
https://github.com/cratis/arc/packages/1655206?version=20.43.8

The 2.1.10/2.1.11 native library pulled in transitively by EF Core Sqlite has
a high-severity advisory (GHSA-2m69-gcr7-jv3q) that fails the build under
NuGet audit with warnings-as-errors. Enable central transitive pinning and
pin the package to the patched release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@woksin woksin merged commit ae86706 into main Jun 20, 2026
50 checks passed
@woksin woksin deleted the feat/arc-roslyn-analyzers branch June 20, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant