-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/9.0] Remove string.Trim{,Start,End}(ReadOnlySpan<char>) ref-API #108777
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
<Target>M:System.String.TrimStart(System.ReadOnlySpan{System.Char})</Target> | ||
</Suppression> | ||
</Suppressions> |
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.
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?
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.
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.
Breaking change documentation seeded at dotnet/docs#43032. |
/ba-g failure is preexisting |
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.