8000 Freeze the generator and analyzer API shape before 1.0 by kzu · Pull Request #383 · devlooped/stunts · GitHub
[go: up one dir, main page]

Skip to content

Freeze the generator and analyzer API shape before 1.0 - #383

Merged
kzu merged 1 commit into
mainfrom
enhancement/freeze-phase-4-generator-api
Dec 2, 2026
Merged

kzu merged 1 commit into
mainfrom
enhancement/freeze-phase-4-generator-api

Conversation

@kzu
@kzu kzu commented Dec 2, 2026
Copy link
Copy Markdown
Member

Fourth step of the pre-1.0 API freeze: the breaking changes to the public API of Stunts.CompiledProxy and Stunts.CodeAnalysis, which the Stunts.CompiledProxy package exposes to libraries that build a generator on StuntGenerator.

Breaking changes

Before After
Microsoft.CodeAnalysis.Shared.Extensions.INamedTypeSymbolExtensions Stunts.CodeAnalysis.INamedTypeSymbolExtensions
Stunts.UnsafeSignatureAnalyzer Stunts.CodeAnalysis.UnsafeSignatureAnalyzer
StuntDiagnostics.BaseTypeNoContructor BaseTypeNoConstructor
StuntDiagnostics.PointerMember (ST005) Removed; the id stays reserved and is not reported
record StuntGenerator, record ProcessorContext sealed record
ProcessorContext.Compilation { get; init; } { get; internal init; }
GetCandidates returns (SyntaxNode source, INamedTypeSymbol[] candidate) (SyntaxNode Source, ImmutableArray<INamedTypeSymbol> Types)
ISyntaxProcessor.Language Removed, with Language of the built-in processors: compile-time stunts are C# only
Public DependencyResolver, SyntaxProcessorDriver, NestedTypeStunt, StuntClosure, StuntClosureResult, StuntDefinition, StuntClosureError Internal
Public SymbolExtensions.IsRegistrationAttribute, ValidateGeneratorTypes, TryValidateGeneratorTypes Internal. CanBeIntercepted stays public
SymbolExtensions.InterceptableRecursively Removed: it had no caller
SymbolFullNameExtensions (ToFullName, GetTypeByFullName) Removed: only tests used it. The Superpower dependency goes with it, and Superpower.dll leaves the Stunts package
UnsafeSignatureAnalyzer(Type generatorAttribute) read StuntAttribute<> registrations for any generator attribute Follows the generator: none for a custom generator attribute, unless given
UnsafeSignatureAnalyzer(Type, Type registrationAttribute) (Type, Type? registrationAttribute), where null means none

Also

  • The Stunts.CompiledProxy readme says which diagnostics the generator reports itself (ST003, ST006, ST007, ST012, ST013, ST015, ST020, ST021, ST025 to ST027) and which only the analyzers report (ST001, ST002, ST004, ST008 to ST010, ST016 to ST019, ST023), with an example of deriving from each analyzer.
  • The test that matches diagnostic descriptors with the docs anchors now also covers the ids of Stunts.targets and the reserved ids.

Verified locally: build, 461 of 461 tests (the tests of the removed helper and of ST005 are gone, two were added), format checks, the package file lists, the acceptance solution, the Native AOT binary for net8.0 and net10.0, and the standalone package: a netstandard2.0 generator built from the readme's snippets as written, and a consumer that gets its types generated next to the stunts. Not run locally: framework-compiler.ps1.

This pull request was created by CodeAlta.

🤖 Generated with Claude Code

Breaking changes to the public API of Stunts.CompiledProxy and
Stunts.CodeAnalysis, which the Stunts.CompiledProxy package exposes to
the libraries that build a generator on StuntGenerator.

- Move INamedTypeSymbolExtensions out of the Roslyn namespace
  Microsoft.CodeAnalysis.Shared.Extensions into Stunts.CodeAnalysis, and
  UnsafeSignatureAnalyzer from Stunts into Stunts.CodeAnalysis.
- Rename StuntDiagnostics.BaseTypeNoContructor to BaseTypeNoConstructor,
  and remove the PointerMember descriptor: ST005 is reserved and not
  reported.
- Seal the StuntGenerator and ProcessorContext records.
  ProcessorContext.Compilation is set by this assembly only.
- IStuntCandidatesProvider.GetCandidates returns
  (SyntaxNode Source, ImmutableArray<INamedTypeSymbol> Types).
- Remove ISyntaxProcessor.Language: compile-time stunts are C# only.
- Make internal what was public by accident: DependencyResolver,
  SyntaxProcessorDriver, NestedTypeStunt, StuntClosure and its result
  types, and the members of SymbolExtensions other than
  CanBeIntercepted. Remove InterceptableRecursively, which had no caller.
- Remove SymbolFullNameExtensions and the Superpower dependency, which
  only tests used: Superpower.dll leaves the Stunts package.
- UnsafeSignatureAnalyzer follows the generator for the registration
  attribute: none for a custom generator attribute unless given, and
  null means none.
- Say in the Stunts.CompiledProxy readme which diagnostics only the
  analyzers report and how an extender derives from them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu kzu added the enhancement New feature or request label Dec 2, 2026
@kzu
kzu enabled auto-merge (rebase) December 2, 2026 07:40
@kzu
kzu merged commit 73cb761 into main Dec 2, 2026
12 checks passed
@kzu
kzu deleted the enhancement/freeze-phase-4-generator-api branch December 2, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0