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

RCS1113: Use 'string.IsNullOrEmpty' method is suggested incorrectly #662

Closed
danielabbatt opened this issue Apr 8, 2020 · 2 comments
Closed

Comments

@danielabbatt
Copy link

Product and Version Used:
Roslynator 2019 2.9.0 extension

Steps to Reproduce:

with nullable enabled in a c#8.0 project

if (connectedSystem.Credentials.Account == "")

connectedSystem is not nullable

connectedSystem.Credentials is not nullable

connectedSystem.Credentials.Account is string?

Actual Behavior:
The message below is suggested

Message RCS1113 Use 'string.IsNullOrEmpty' method

Expected Behavior:
No suggestion to be made as the intention is to check that connectedSystem.Credentials.Account is not null but is empty. The same suggestion is made when string.Empty is used instead of "".

On looking at the documentation page, the second diagnostic message shows the same behaviour which also appears incorrect.

if (s == "") // RCS1113
{
}

https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1113.md

I can see this was probably introduced as #650 which incorrectly assumes the intention of whether the original string being null is different to it being empty.

@davidnmbond
Copy link

Yes - #650 was a mistake.

@josefpihrt
Copy link
Collaborator

@danielabbatt Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants