-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove always-true condition #3009
Conversation
@@ -142,7 +142,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul | |||
|
|||
private object GetKey(string keyToken, CultureInfo culture) | |||
{ | |||
if (keyToken == String.Empty) | |||
if (keyToken.Length == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NullReferenceException?
Could you use string.IsNullOrEmpty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller code is:
string fullName = ((string)source).Trim();
object key = GetKey(fullName, CultureInfo.InvariantCulture);
Trim won't return null, so fullName
is going to be a non-null value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you looked at the old code and traced it if the passed keyToken
is null, You'll find that it will throw NullReferenceException at:
keyToken = keyToken.ToUpper(culture);
But, anyway the passed value isn't null. So, it's okay.
Thank you @Youssef1313 And I think the |
That's correct. I just did both because they're in the same file and the change is really small. |
Thanks, @Youssef1313. |
No description provided.