Add Arc Roslyn analyzers and bundle all analyzers into the Cratis package#2308
Merged
Conversation
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>
|
NuGet packages for this PR, e.g. Cratis.Arc: |
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>
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
A single reference to the
Cratispackage now ships the full set of Cratis Roslyn analyzers, and several new analyzers guide developers and AI toward idiomatic Arc code.Added
ARC0007analyzer — warns when a[Command]is declared as a class instead of a record.ARC0008analyzer — warns when a[ReadModel]is declared as a class instead of a record.ARC0009analyzer — warns when aConceptAs<T>is declared as a class instead of a record.ARCCHR0002analyzer — warns when a[Command]has multiple event source id candidates (EventSourceId,EventSourceId<T>, a type with an implicit conversion toEventSourceId, or[Key]) but does not implementICanProvideEventSourceId; exempt whenHandlereturns onlyEventForEventSourceId.ARCCHR0003analyzer — warns when a reactor injectsIEventLoginstead of returning side-effect events.ARCCHR0004analyzer — warns when[EventType]specifies an explicit id (the type name is the identifier);generationstays allowed.Changed
Cratismeta package now bundles every Cratis analyzer (Arc, Arc.Chronicle, the Arc source generator, the Fundamentals type discovery generator, and the Metrics analyzer), so installingCratisenables all analyzers without referencing the sub-packages directly.