Repository navigation
Report ST013 for a ref return of a ref struct or pointer - #363
Merged
Merged
Conversation
A member or delegate that returns a ref struct or pointer by reference (ref Span<int> Current()) made the generator emit code that does not compile (CS8150), with no Stunts diagnostic: the stunt returns the held value from a local slot, which a ref return cannot do, and Ref<T>, which carries the other ref returns, cannot take a ref struct or pointer as T. RuntimeSignature now finds those signatures too, for methods, properties, indexers and the Invoke of a delegate. ST013 reports them where the stunt is asked for, with the reason in its message, and the generator skips that stunt, so the other stunts of the project are still generated. RuntimeSignature had a walk of its own that also returned members the stunt does not intercept: an interface member the base class implements, or a member a derived class seals. It now reads the members from InterceptedMembers, the walk of UnsafeSignatureAnalyzer moved to a class both share, so ST013 no longer rejects a stunt for such a member. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: CodeAlta <noreply@codealta.io>
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 member or delegate that returns a ref struct or pointer by reference made the generator emit code that does not compile, with no Stunts diagnostic saying why:
The stunt returns the held value from a local slot, which a
refreturn cannot do.Ref<T>, which carries the otherrefreturns, cannot take a ref struct or pointer asT, so the pipeline cannot carry the signature under any build setting.What changes
ST013now also reports arefreturn of a ref struct or pointer, for methods, properties, indexers and theInvokeof a delegate. Its message states the reason:'IBuffers' cannot be proxied because 'IBuffers.Current()' returns a ref struct or pointer by reference.ST013signatures, so the other stunts of the project are still generated.RuntimeSignaturehad a walk of its own that also returned members the stunt does not intercept: an interface member the base class implements, or a member a derived class seals. It now reads the members fromInterceptedMembers, the walk ofUnsafeSignatureAnalyzermoved to a class both share, soST013no longer rejects a stunt for such a member.The guide (
docs/guide/diagnostics.md), the readme andAGENTS.mddescribe the new case.Tests
StuntGeneratorTests:ReportsRefReturnsOfRefStructsAndPointers(method, property, indexer, pointer, delegate; it failed for all five before the fix) andDoesNotReportRefReturnsTheStuntDoesNotIntercept. The unit test project passes (418 tests).🤖 Generated with Claude Code
This pull request was created by CodeAlta.