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

Skip to content

Freeze the runtime and Extensions API shape before 1.0 - #381

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

kzu merged 1 commit into
mainfrom
enhancement/freeze-phase-3-runtime-api

Conversation

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

Third step of the pre-1.0 API freeze: the breaking changes to the public API of Stunts and Stunts.Extensions that are only possible before 1.0.

Breaking changes

Before After
delegate MethodInvoker delegate InvokeHandler (it was ambiguous with System.Reflection.MethodInvoker)
DefaultValueProvider.Deregister(Type) / Deregister<T>() Unregister(Type) / Unregister<T>()
static class ProceedExtension ProceedExtensions
HashSet<Type> IMethodInvocation.SkipBehaviors ISet<Type>
class StuntFactory : IStuntFactory static class StuntFactory
StuntFactory.LocalDefault { get; set; } StuntFactory.UseAmbient(IStuntFactory), returning IDisposable, like BehaviorPipelineFactory.UseAmbient
Default setters and UseAmbient accepted null ArgumentNullException
Unsealed MethodInvocation, ArgumentCollection, BehaviorPipeline, DefaultEqualityBehavior, DefaultValueBehavior, TargetBehavior, RecordingBehavior, RecordedInvocation, NotifyPropertyChangeBehavior, Ref<T>, PointerRef, records MethodReturn, Argument<T>, ObjectArgument Sealed (the records keep their init setters)
class Ref with a public constructor abstract class Ref
ArgumentCollection index members threw IndexOutOfRangeException ArgumentOutOfRangeException
arguments["unknown"] = x stored a hidden entry KeyNotFoundException
Proceed with a null awaitable threw NullReferenceException InvalidOperationException
StructRef after invalidation threw AccessViolationException InvalidOperationException
MethodReturn argument count mismatch threw ArgumentException TargetParameterCountException, as everywhere else
DefaultValueBehavior implemented Execute explicitly Public Execute; its provider cannot be null
StructRef<T>, SpanRef<T>, ReadOnlySpanRef<T> generated as public source into every consumer on .NET 9 or later Public types of a new net9.0 build of Stunts.dll. SignatureRefGenerator is removed
ObservabilityBehavior: histogram in ms, tags stunt.type, member.name, status, activity tags arg.<name> Seconds (unit s), tags stunts.type, stunts.member, and error.type on failure; activity tags stunts.argument.<name>

Not sealed, on purpose: CompiledStuntFactory, DefaultValueProvider, StructRef, StuntGeneratorAttribute.

Also

  • Nullable warnings are on for net8.0 too, and the annotations they hid are fixed (Equals(object?), Argument.Name returns an empty string for an unnamed parameter).
  • allows ref struct does not compile for netstandard2.0 or net8.0 (CS9240), so the holders need the net9.0 target. ST023 now asks whether the compilation sees Stunts.StructRef<T>.
  • The log event of ObservabilityBehavior and its logging of argument values are unchanged.

Verified locally: build, 469 of 469 tests, format checks, the package (lib/netstandard2.0, lib/net8.0, lib/net9.0), the acceptance solution (13 tests in 7 projects), the Native AOT binary for net8.0 and net10.0, samples, and a consumer with Span<T>, ReadOnlySpan<T> and a custom ref struct on net10.0 and net9.0 (ST023 on net8.0). Not run locally: framework-compiler.ps1 and the site build.

This pull request was created by CodeAlta.

🤖 Generated with Claude Code

Uh oh!

There was an error while loading. Please reload this page.

Breaking changes to the public API of Stunts and Stunts.Extensions, made
now because none is possible after 1.0.

- Rename the MethodInvoker delegate to InvokeHandler (it is ambiguous
  with System.Reflection.MethodInvoker), DefaultValueProvider.Deregister
  to Unregister, and ProceedExtension to ProceedExtensions.
- IMethodInvocation.SkipBehaviors is ISet<Type>.
- StuntFactory is a static class with UseAmbient, like
  BehaviorPipelineFactory; LocalDefault is gone. The Default setters and
  UseAmbient reject null.
- Seal the classes and records that are not bases: MethodInvocation,
  ArgumentCollection, BehaviorPipeline, the built-in behaviors, Ref<T>,
  PointerRef, MethodReturn, Argument<T> and ObjectArgument. Ref is
  abstract.
- Throw ArgumentOutOfRangeException from the index members of
  ArgumentCollection, InvalidOperationException from Proceed and
  StructRef, and TargetParameterCountException for every argument count
  mismatch. Setting an unknown argument name throws KeyNotFoundException
  instead of storing a hidden entry.
- DefaultValueBehavior.Execute is public, and its provider cannot be
  null.
- Enable nullable warnings on net8.0 and fix the annotations it hid.
- StructRef<T>, SpanRef<T> and ReadOnlySpanRef<T> are types of a new
  net9.0 build of Stunts.dll instead of source generated into every
  consumer. SignatureRefGenerator is removed.
- ObservabilityBehavior records the duration in seconds, tags
  stunts.type, stunts.member and error.type, and names activity
  arguments stunts.argument.<name>.

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:20
@kzu
kzu merged commit 1f900fd into main Dec 2, 2026
12 checks passed
@kzu
kzu deleted the enhancement/freeze-phase-3-runtime-api branch December 2, 2026 07:27
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