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

Improve documentation of StringValues.IsNullOrEmpty() with regard to empty string #49626

Closed
scharnyw opened this issue Mar 15, 2021 · 2 comments · Fixed by #49629
Closed

Improve documentation of StringValues.IsNullOrEmpty() with regard to empty string #49626

scharnyw opened this issue Mar 15, 2021 · 2 comments · Fixed by #49629
Labels
area-Extensions-Primitives untriaged New issue has not been triaged by the area owner

Comments

@scharnyw
Copy link
Contributor

Description

The docs on StringValues.IsNullOrEmpty() says that the method returns:

/// <returns>true if <paramref name="value">value</paramref> contains a single null string or empty array; otherwise, false.</returns>

This is not technically correct, since the method also returns true if the StringValues contains a single empty string:

var value = (StringValues)"";
var empty = StringValues.IsNullOrEmpty(value); // true

value = (StringValues)new[] { "" };
empty = StringValues.IsNullOrEmpty(value); // true

For the sake of correctness I suggest changing the docs to:

returns true if value contains a single null or empty string or an empty array; otherwise, false.

Configuration

Regression?

Other information

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 15, 2021
@dotnet-issue-labeler
Copy link

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.

scharnyw pushed a commit to scharnyw/runtime that referenced this issue Mar 15, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 15, 2021
@ghost
Copy link

ghost commented Mar 15, 2021

Tagging subscribers to this area: @eerhardt, @maryamariyan
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

The docs on StringValues.IsNullOrEmpty() says that the method returns:

/// <returns>true if <paramref name="value">value</paramref> contains a single null string or empty array; otherwise, false.</returns>

This is not technically correct, since the method also returns true if the StringValues contains a single empty string:

var value = (StringValues)"";
var empty = StringValues.IsNullOrEmpty(value); // true

value = (StringValues)new[] { "" };
empty = StringValues.IsNullOrEmpty(value); // true

For the sake of correctness I suggest changing the docs to:

returns true if value contains a single null or empty string or an empty array; otherwise, false.

Configuration

Regression?

Other information

Author: scharnyw
Assignees: -
Labels:

area-Extensions-Primitives, in pr, untriaged

Milestone: -

eerhardt pushed a commit that referenced this issue Mar 15, 2021
Fix #49626

Co-authored-by: Guanbo Wang <GWang26@slb.com>
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Primitives untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants