Repository navigation
Pass ref structs and pointers of delegate stunts through holders - #360
Merged
Merged
Conversation
kzu
enabled auto-merge (rebase)
November 29, 2026 05:17
A delegate stunt with a ref struct or pointer in its signature, such as delegate int Sum(Span<int> data) or SpanAction<T, TArg>, generated code that did not compile (CS9244), and no diagnostic said why. DelegateScaffold now carries those parameters and returns through the pipeline in the holders CSharpRewrite uses for class and interface members (SpanRef, ReadOnlySpanRef, StructRef, PointerRef), and the registration binds an Invoke with pointers in an unsafe block. UnsafeSignatureAnalyzer walks the Invoke method of a delegate, so ST009 and ST023 apply to delegate stunts too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: CodeAlta <noreply@codealta.io>
kzu
force-pushed
the
alta/mighty-kingfisher-545z
branch
from
November 29, 2026 05:46
85c0b76 to
0d50bbe
Compare
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.
A delegate stunt with a ref struct or pointer in its signature generated code that did not compile, and no diagnostic said why:
Framework delegates were affected too, such as
System.Buffers.SpanAction<T, TArg>.Changes
DelegateScaffoldpasses ref-struct and pointer parameters and returns ofInvokethrough the holders already used for class and interface members (SpanRef<T>,ReadOnlySpanRef<T>,StructRef<T>,PointerRef). Delegates without such types generate the same code as before.StuntRegistrationsbinds anInvokethat has pointers in its signature inside anunsafeblock (CS0214otherwise).UnsafeSignatureAnalyzerwalks theInvokemethod of a delegate, soST009andST023apply to delegate stunts:'Sum.Invoke' uses a ref struct or pointer and requires compile-time stunts and AllowUnsafeBlocks.CreateHolder,RefSlot,HolderType) move from the private visitor ofCSharpRewriteto the class, so both paths share one mapping.Tests
ST009_UnsafeSignature: delegate cases replaceDoesNotReportADelegate(unsafe blocks off, missing holders,SpanAction<int, int>, a pointer return, and no report for an ordinary delegate).Scenarios/SignatureRefs.cs, through the real generator: a span parameter seen and changed by a behavior, a delegate without implementation, a span return, a ref struct by reference with anoutargument, pointers by value, by reference and returned,SpanAction<int, int>andFunc<int[], Span<int>>.The unit test suite passes (409 tests). The Native AOT acceptance project was not run locally.
This pull request was created by CodeAlta.
🤖 Generated with Claude Code