Constrain behavior extension methods to IStunt - #253
Merged
Merged
Conversation
kzu
enabled auto-merge (rebase)
September 30, 2026 22:26
kzu
disabled auto-merge
September 30, 2026 22:28
AddBehavior/InsertBehavior were duplicated as IStunt and unconstrained generic overloads, with the generic ones unwrapping a delegate target at runtime and throwing ArgumentException when the receiver was not a stunt. Keep only the generic overloads and constrain TStunt to IStunt, so the API is discoverable only on stunts, the receiver type is preserved for chaining, and misuse is a compile error instead of a runtime throw.
The IStunt constraint means behaviors can no longer be configured off a bare stunt instance. Update the affected tests and generator scenarios to create the stunt with Stunt.For<T>, configure behaviors on the returned StuntReference<T>, and materialize it with ToObject().
The API overview and package description still showed behaviors being added directly on the stunt. Show Stunt.For<T> with ToObject(), and mention Stunt.Get for configuring an already created stunt.
Custom attribute replication and optional parameter defaults are now generated and covered by AttributeTests, so drop them from the gap list and record them as supported. Narrow the remaining metadata and serialization entries to what is genuinely Castle-specific, and restate the interface limitation as the inability to tell identical interface slots apart.
Nothing in the project consumes the generated ThisAssembly constants.
kzu
force-pushed
the
dev/session-changes
branch
from
September 30, 2026 22:31
4f30509 to
deba077
Compare
kzu
enabled auto-merge (rebase)
September 30, 2026 22:32
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.
Tightens the behavior configuration API so that
AddBehavior/InsertBehaviorare onlyreachable on actual stunts, and brings the tests, scenarios and docs in line with it.
Constrain behavior extension methods to IStunt
AddBehavior/InsertBehavioreach had two shapes: anIStuntoverload, and anunconstrained generic overload that unwrapped a delegate target at runtime and threw
ArgumentExceptionwhen the receiver turned out not to be a stunt.The duplicated overloads are gone. What remains is the generic form, constrained to
IStunt:The constraint keeps the API off arbitrary objects, the type parameter preserves the
concrete receiver type so calls still chain, and passing a non-stunt is now a compile
error rather than a runtime throw.
Tests and scenarios
Behaviors can no longer be configured off a bare stunt instance, so the affected tests and
generator scenarios now create the stunt with
Stunt.For<T>, configure behaviors on thereturned
StuntReference<T>, and materialize it withToObject().Documentation
The API overview and the package description still showed behaviors being added directly
on the stunt. Both now show the
Stunt.For<T>/ToObject()pattern, and the overviewmentions
Stunt.Getfor configuring an already created stunt.Castle support notes
Castle/Unsupported.mdwas re-evaluated against what the generator actually emits today.Custom attribute replication and optional parameter defaults are generated and covered by
AttributeTests, so they moved out of the gap list and into the supported table. Theremaining metadata and serialization entries are narrowed to what is genuinely
Castle-specific, and the interface limitation is restated as the inability to tell
identical interface slots apart.
Build
Dropped the unused
ThisAssemblypackage reference fromStunts.CompiledProxy.Verified with
dotnet test src/Stunts.UnitTests— 211 passed, 0 failed.