-
Notifications
You must be signed in to change notification settings - Fork 560
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
Conversation
@@ -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) |
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.
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?
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.
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 >=
).
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.
Looks good
Looks like this should be merged asap. |
can we have this change merged soon? |
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. |
Enables CA1310 at error severity
Also use Contains instead of IndexOf
It is unnecessary to have in the tests.
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)