Skip to content
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

add ReadOnlySpan<char> as string parameter #9

Closed
jpbruyere opened this issue Jan 17, 2021 · 8 comments · Fixed by #23
Closed

add ReadOnlySpan<char> as string parameter #9

jpbruyere opened this issue Jan 17, 2021 · 8 comments · Fixed by #23
Assignees
Labels
enhancement New feature or request

Comments

@jpbruyere
Copy link

First, thank you for this remarkable utility. Do you plan to introduce 'ReadOnlySpan' as string parameter?

@xin9le
Copy link
Owner

xin9le commented Jan 17, 2021

Thank you for your good suggestion! Just to confirm, do you mean you want some overload methods like following?

  • bool IsDefined<T>(ReadOnlySpan<char> value)
  • T Parse<T>(ReadOnlySpan<char> value)
  • bool TryParse<T>(ReadOnlySpan<char> value, out T result)
  • bool TryParse<T>(ReadOnlySpan<char> value, bool ignoreCase, out T result)

@xin9le xin9le self-assigned this Jan 17, 2021
@xin9le xin9le added the enhancement New feature or request label Jan 17, 2021
@jpbruyere
Copy link
Author

Absolutely, I guess every living net library will get to this point soon.

@xin9le
Copy link
Owner

xin9le commented Jan 23, 2021

I think I would love to implement ReadOnlySpan<char> overloads. However ReadOnlySpan<char>.GetHashCode() throws NotSupportedException, so I have to workaround this problem. I'm not sure I can do it well, but I'll try it.

@jpbruyere
Copy link
Author

jpbruyere commented Jan 23, 2021

Have you consider this method:

public int GetHashCode (ReadOnlySpan<char> source, System.Globalization.CompareOptions options);

The following code worked for me (win10, netcore 3.1)

ReadOnlySpan<char> span = test.AsSpan ();
int a = string.GetHashCode (span, StringComparison.CurrentCulture);

@lsoft
Copy link

lsoft commented Jan 29, 2023

@xin9le I would love this feature too! :)

@xin9le
Copy link
Owner

xin9le commented Feb 11, 2023

I am motivated to improve, but I have been working extremely hard for the past few years. I apologize for putting the improvement task on the back burner.

@xin9le
Copy link
Owner

xin9le commented Aug 31, 2024

Although it has taken a considerable amount of time, we have now addressed this request. We will be releasing the NuGet Package in the near future 🚀

@xin9le
Copy link
Owner

xin9le commented Sep 1, 2024

I've just released v2.0.0-preview2. Please take advantage of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants