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

API Proposal: Make char.IsAscii public #40936

Closed
eiriktsarpalis opened this issue Aug 17, 2020 · 17 comments · Fixed by #41396
Closed

API Proposal: Make char.IsAscii public #40936

eiriktsarpalis opened this issue Aug 17, 2020 · 17 comments · Fixed by #41396
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime good first issue Issue should be easy to implement, good for first-time contributors
Milestone

Comments

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Aug 17, 2020

System.Char currently defines a private IsAscii method. It think it might make sense to make this public?

public readonly struct Char
{
+  public static bool IsAscii(char ch);
}
@eiriktsarpalis eiriktsarpalis added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Aug 17, 2020
@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Aug 17, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Aug 17, 2020
@eiriktsarpalis
Copy link
Member Author

Not sure what the right area label for corelib stuff is.

@danmoseley
Copy link
Member

Note there is already Rune.IsAscii(char) but it seems to me this is probably a case where duplication is reasonable, as the duplication is at a trivial level, and Rune is much less widely used than char; one might operate entirely on char and only need this one method on Rune.

@danmoseley danmoseley added api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Aug 18, 2020
@danmoseley
Copy link
Member

@GrabYourPitchforks

@danmoseley danmoseley added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Aug 19, 2020
@terrajobst
Copy link
Member

Unless @GrabYourPitchforks has any objections, this feels like a sensible addition.

@GrabYourPitchforks
Copy link
Member

We're also adding Ascii.IsAscii(char) (see #28230).

But I agree, targeted duplication like what's suggested here could help discoverability.

@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation untriaged New issue has not been triaged by the area owner labels Aug 25, 2020
@terrajobst
Copy link
Member

terrajobst commented Aug 25, 2020

Video

  • Looks reasonable
namespace System
{
    public readonly struct Char
    {
        public static bool IsAscii(char ch);
    }
}

@GrabYourPitchforks
Copy link
Member

Correction: the parameter should be named c, not ch. That matches other static APIs on the char class.

@danmoseley danmoseley added good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors labels Aug 25, 2020
@danmoseley
Copy link
Member

Anyone in the community interested in picking this up?

@gfoidl
Copy link
Member

gfoidl commented Aug 25, 2020

You can assign it to me -- will send a PR tomorrow.

Is https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime/tests/System/CharTests.cs the right place to add some tests for this?

That matches other static APIs on the char class.

There is a bit of mix on c / ch. Shall this be unified to c (within the coming PR)?

@GrabYourPitchforks
Copy link
Member

@gfoidl it's yours! :)

There is a bit of mix on c / ch. Shall this be unified to c (within the coming PR)?

Looks like we use c for our public APIs and ch (sometimes) for our internal APIs? I can't find any counterexamples offhand but admittedly I didn't look that hard. I wouldn't bother normalizing any other internal methods during this PR.

@GrabYourPitchforks GrabYourPitchforks removed the help wanted [up-for-grabs] Good issue for external contributors label Aug 25, 2020
@svick
Copy link
Contributor

svick commented Aug 25, 2020

@GrabYourPitchforks

For the record, in .Net Core 3.1 corelib, I count 29 methods with char c parameter and 9 methods with char ch:

  • System.Text.Rune: System.Text.Rune op_Explicit(Char)
  • System.Text.Rune: Boolean TryCreate(Char, System.Text.Rune ByRef)
  • System.Text.Rune: Void .ctor(Char)
  • System.IO.BinaryWriter: Void Write(Char)
  • System.Globalization.CharUnicodeInfo: Double GetNumericValue(Char)
  • System.Globalization.CharUnicodeInfo: Int32 GetDecimalDigitValue(Char)
  • System.Globalization.CharUnicodeInfo: Int32 GetDigitValue(Char)
  • System.Globalization.CharUnicodeInfo: System.Globalization.UnicodeCategory GetUnicodeCategory(Char)
  • System.Globalization.CompareInfo: Boolean IsSortable(Char)

@GrabYourPitchforks
Copy link
Member

@svick right, I'm only considering existing static public methods on the char type. That way the parameter names are at least locally consistent.

@gfoidl
Copy link
Member

gfoidl commented Sep 1, 2020

Are there any steps needed for the documentation?

@danmoseley
Copy link
Member

@gfoidl it's complicated -- normally the simple answer is "add XML docs in the src for this new public method" and that may be the correct answer. It's complicated because unlike almost everyone else, the core libraries don't historically generate their docs from the sources. We do want to use XML docs going forward, but only for seeding the docs.microsoft.com text initially. We have a tool that does this seeding so I think the answer is we'll need another PR to add <summary> for IsAscii. We missed this in PR review.

Now I've typed that, I see it's documented by @carlossanlop here https://github.com/dotnet/runtime/blob/c87e75e8ef260ccc6e979f9df1cc012536ee036f/docs/coding-guidelines/adding-api-guidelines.md#documentation

@gfoidl
Copy link
Member

gfoidl commented Sep 2, 2020

@danmosemsft it was easy to miss, as no other api in

public readonly struct Char : IComparable, IComparable<char>, IEquatable<char>, IConvertible
has xml doc comments.

So I'll send a PR with the doc comments (for this new public API)?

@danmoseley
Copy link
Member

@gfoidl certainly that is true, and it is because until recent years, there was no path from our source code to docs at all, and I guess we have not added much to Char recently. Yes, all that is needed is one for the new member. thanks

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime good first issue Issue should be easy to implement, good for first-time contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants