-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
String.TrimStart trims unexpected characters in dotnet 9 #103892
Comments
There is no overload of
How can you do this in .NET 8? There wasn't a |
I think we should review the new API again before .NET 9 releases. It is already confusing people. |
We have been using |
I wouldn't be surprised if this is related to https://stackoverflow.com/questions/4335878/c-sharp-trimstart-with-string-parameter We have something similar in our codebase. The pains of extension methods... |
It's probably some extension method implemented by yourself or some third-party package. You can navigate the code and confirm it. |
API review already extensively discussed this and had even more weigh in when the initial questions were raised. I don't expect we will change our stance that overloads need to have consistent behavior. At best I could see us not exposing the overload, but that hurts the overall ecosystem more as devs no longer have an allocation free way to achieve the trimming support. New cases of potential breaks are of course interesting, but we've also historically never quantified us exposing new APIs on the core types, with regards to how they can cause a user-defined extension method to no longer be selected, as a blocking type of break,. This is because quantifying such changes as blocking would make it impossible for us to version our own types and expose new APIs. CC. @bartonjs, @stephentoub |
@huoyaoyuan You are right, it was an extension method 👍 |
Also see ThreeMammals/Ocelot#2145 |
Description
In dotnet 9, the behavior of String.TrimStart is very different to 8
If you have a string like "Hello this is my string", and you do
.TrimStart
on it with "Hello this".The result is "my string".
Also TrimStart is now Case sensitive, which it wasn't before, so maybe TrimStart should be able to pass a
StringComparison
parameter.Reproduction Steps
Console app
You can do this quickly in a console app like this:
Unit tests
Setup a unit test like so:
Expected behavior
Expected behavior should be the "shouldBe" strings
Actual behavior
TrimStart trims more words than it should, and is now case sensitive.
Regression?
Guess this could be new behavior in dotnet 9, but still strange that it trims more words than it should
Known Workarounds
No response
Configuration
This is running on dotnet 9.0.100-preview.5
Windows x64
Other information
No response
The text was updated successfully, but these errors were encountered: