[release/9.0] Remove string.Trim{,Start,End}(ReadOnlySpan<char>) ref-API#108777
Merged
carlossanlop merged 1 commit intodotnet:release/9.0from Oct 11, 2024
Merged
[release/9.0] Remove string.Trim{,Start,End}(ReadOnlySpan<char>) ref-API#108777carlossanlop merged 1 commit intodotnet:release/9.0from
carlossanlop merged 1 commit intodotnet:release/9.0from
Conversation
|
Note regarding the |
1 similar comment
|
Note regarding the |
Contributor
|
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
stephentoub
reviewed
Oct 11, 2024
| <DiagnosticId>CP0002</DiagnosticId> | ||
| <Target>M:System.String.TrimStart(System.ReadOnlySpan{System.Char})</Target> | ||
| </Suppression> | ||
| </Suppressions> |
Member
There was a problem hiding this comment.
If we haven't already, I assume our intent is to follow-up for net10.0 with a change to remove these and delete the source impl?
Member
Author
There was a problem hiding this comment.
The current intent is both main and ~9.0.1, just letting prebuilt things get through a cycle of the method "not being there" without the MissingMethodException.
stephentoub
approved these changes
Oct 11, 2024
Member
Author
|
Breaking change documentation seeded at dotnet/docs#43032. |
Contributor
|
/ba-g failure is preexisting |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Manual backport of #108537 to release/9.0
Customer Impact
Customers who have existing extension methods, string.Trim(string) (or TrimEnd, or TrimStart) find that their extension methods no longer get called after upgrading to .NET 9. These extension methods almost always want to turn
"prefixinfixsuffix".TrimEnd("suffix")into"prefixinfix", but our new methodpublic [instance] string [string::]TrimEnd(ReadOnlySpan<char> value)has higher binding order over their extension method, and it produces the result"prefixin", as it is instead treating the "suffix" as a set of characters to remove from the end of the string (equivalent to"prefixinfixsuffix".TrimEnd('s', 'u', 'f', 'f', 'i', 'x'), rather than a specific sequence of characters.Regression
Customers who had applicable extension methods experience these new overloads as a regression from previous versions.
Testing
As the tests for these methods no longer compile, they are also removed.
Risk
This change is breaking. Any callers who specifically call Trim, TrimStart, or TrimEnd with a
ReadOnlySpan<char>will have to change their code. Two such sites were identified in dotnet/wpf and have already been mitigated.Callers which were calling the new methods via params syntax will not experience a runtime break with this change, as it removes the ref but not the implementation (yet). When those callers recompile they will switch (back) to the
Trim(params char[])overload with no action required on their part.As this change only removes things, the risk that the change does not solve the problem is low. The risk that it requires unanticipated followup in dotnet/runtime is also low. While other dotnet/* repositories have been checked for breaks, some may have been missed, and they will break automatic ingestion and have to be fixed as they surface.