Skip to content

Add/Expose String.EndsWith(char) #4460

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

Closed
davidfowl opened this issue Aug 31, 2015 · 4 comments
Closed

Add/Expose String.EndsWith(char) #4460

davidfowl opened this issue Aug 31, 2015 · 4 comments
Assignees

Comments

@davidfowl
Copy link
Member

So we don't have to rewrite it over and over 😄. Seems like its already there just made internal for some reason:

https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L2210

People end up writing code like this:

https://github.com/aspnet/dnx/blob/dev/ext/compiler/preprocess/Internalization.cs#L100

and this

https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Runtime/NuGet/Utility/PathUtility.cs#L45

@bbowyersmyth
Copy link
Contributor

I had the same thought a while back and discovered it would be a breaking change for an edge case in VB.

Against the current framework the following is valid VB:

Dim find As Char = "a"c
Dim result = "abc".StartsWith(find)

The compiler wraps find with a call to a string conversion and all is good. If EndsWith(char) was made public and the code recompiled it would switch from using the CurrentCulture based EndsWith(string) to the Ordinal based EndsWith(char).

Whether any of the offending characters or the above scenario is deemed important I would love to hear. Especially a StartsWith(char) with direct access to String.m_firstChar

@AlexGhiondea
Copy link
Contributor

It seems like the VB compiler is trying to help by picking an overload that will work.

@VSadov -- do you know what the VB compile would do if we were to introduce the bool EndsWith(char value) overload on string?

@davidfowl can you create an issue in the CoreFx repo (following the API review process)?

@joshfree
Copy link
Member

joshfree commented Dec 3, 2015

Moved this to the correct repo https://github.com/dotnet/corefx/issues/4805

@joshfree joshfree closed this as completed Dec 3, 2015
@felipepessoto
Copy link
Contributor

Just to update people subscribed to this topic. It's completed: dotnet/corefx#16198

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants