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 ordinal string operations #766

Merged
merged 5 commits into from
Jan 19, 2024
Merged

Conversation

Rob-Hague
Copy link
Contributor

This PR adds an .editorconfig file enabling CA1310 (Specify StringComparison for correctness) at 'error' severity and fixes violations by using ordinal string operations.

Ref #713 (comment)

@@ -681,7 +681,7 @@ public void ReverseRoute(Header header)
this.Header.RemoveField(Tags.OnBehalfOfLocationID);
this.Header.RemoveField(Tags.DeliverToLocationID);

if (beginString.CompareTo("FIX.4.1") >= 0)
if (string.CompareOrdinal(beginString, "FIX.4.1") >= 0)
Copy link

@maxnis maxnis Mar 27, 2023

Choose a reason for hiding this comment

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

As recommended by Microsoft - it's better to use Equals method to test equality, isn't it ?

if (beginString.Equals("FIX.4.1", StringComparison.InvariantCulture))

also, magic string "FIX.4.1" - can it be converted to a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, but here we are not checking for equality (of FIX version 4.1), rather that we are at version 4.1 or higher (from the >=).

Copy link

@maxnis maxnis left a comment

Choose a reason for hiding this comment

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

Looks good

@Svisstack
Copy link

Looks like this should be merged asap.

@caoyang1024
Copy link

can we have this change merged soon?

@gbirchmeier
Copy link
Member

Oops-- earlier this week I fixed some of these myself (noticed the errors in my IDE), but I used InvariantCulture. In retrospect, that was stupid of me, because Ordinal is clearly more appropriate.

Going to rebase your PR and fix those (newly created by me) conflicts.

Rob-Hague and others added 4 commits January 19, 2024 16:40
@gbirchmeier gbirchmeier merged commit b81beed into connamara:master Jan 19, 2024
2 checks passed
@Rob-Hague Rob-Hague deleted the ordinal branch January 20, 2024 05:33
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.

5 participants