[release/10.0] Address upcoming breaking change for span-valued collection expressions #120774
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.
Backport of #120771 to release/10.0
/cc @RikkiGibson
Customer Impact
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
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.