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

Use platform agnostic StartsWith null check #161

Merged
merged 1 commit into from
Jan 5, 2021
Merged

Use platform agnostic StartsWith null check #161

merged 1 commit into from
Jan 5, 2021

Conversation

jacobx1
Copy link
Contributor

@jacobx1 jacobx1 commented Nov 10, 2020

Found on OSX Catalina w/ .NET Core 3.1:

StartsWith("\0") always returns true

Implemented fix from the following discussion:

https://stackoverflow.com/questions/52395504/inconsistent-string-startswith-on-different-platforms

Found on OSX Catalina w/ .NET Core 3.1:

`StartsWith("\0")` always returns `true`

Implemented fix from the following discussion:

https://stackoverflow.com/questions/52395504/inconsistent-string-startswith-on-different-platforms
@@ -170,7 +170,7 @@ private async Task Run(CancellationToken token)

var jsonString = await _proxy.GetMessageAsString(token);

if (!string.IsNullOrEmpty(jsonString) && !jsonString.StartsWith("\0"))
if (!string.IsNullOrEmpty(jsonString) && !jsonString.StartsWith("\u0000", StringComparison.OrdinalIgnoreCase))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - if this lib is updated to .NET Standard 2.1, .StartsWith('\0') would work here as well. Decided to go with this change to prevent needing dependents to update.

https://docs.microsoft.com/en-us/dotnet/api/system.string.startswith?view=netcore-3.1#System_String_StartsWith_System_Char_

@csharpfritz
Copy link
Collaborator

Looks like a good fix! Thank you for sending this update

@csharpfritz csharpfritz merged commit e418e46 into FritzAndFriends:dev Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants