-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Address upcoming breaking change for span-valued collection expressions #120771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address upcoming breaking change for span-valued collection expressions #120771
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an upcoming breaking change in C# related to the safe-context rules for span-valued collection expressions. The change modifies how collection expressions for Span/ReadOnlySpan types are handled when passed to constructors or methods.
Key Changes:
- Extracts a span-valued collection expression from within a conditional block to the top level of the method to comply with new safe-context rules
|
Tagging subscribers to this area: @dotnet/area-system-numerics |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorShape.cs
Show resolved
Hide resolved
tannergooding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We probably need to backport this, since the local lifetime is incorrect without this change.
It would be nice if Roslyn could generate slightly better IL as well, but that's separate
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18543984013 |
…ction expressions (#120774) Backport of #120771 to release/10.0 /cc @RikkiGibson ## Customer Impact - [ ] Customer reported - [X] Found internally Customers could end up with incorrect behavior due to the backing storage for a collection expression having the wrong lifetime relative to the local that tracked it. ## Regression - [ ] Yes - [x] No C# took a late breaking change to fix a lifetime issue around collection expressions and the IL it was emitting. This behavior has been around since collection expressions were introduced. ## Testing Explicit validation of the IL was done. ## Risk Low. This is the only place in the repo that was impacted by the break and was updated to use an appropriate lifetime for the collection expression. Co-authored-by: Rikki Gibson <[email protected]>
Doc for upcoming breaking change
See dotnet/roslyn#80684. TensorShape's constructor was the only break I found when compiling the libraries. I fixed this by extracting the collection-expression to the top level.