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 == and != for string comparisons in C# #1746

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

bernardnormier
Copy link
Member

This PR replaces .Equals by == or != for string comparisons in C#.

It also replaces "" comparisons by Length comparisons (0 or > 0).

@bernardnormier bernardnormier added this to the 3.8.0 milestone Feb 1, 2024
Copy link
Member

@pepone pepone 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

@@ -56,57 +56,57 @@ internal static void twoways(global::Test.TestHelper helper, Test.MyClassPrx p)
Ice.Communicator communicator = helper.communicator();
string[] literals = p.opStringLiterals();

test(Test.s0.value.Equals("\\") &&
test(Test.s0.value == "\\" &&
Test.s0.value.Equals(Test.sw0.value) &&
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we use == in all the other comparisons in the && conditions?

test(properties.getProperty("Ice.Trace.Network") == "1");
test(properties.getProperty("Ice.Trace.Protocol") == "1");
test(properties.getProperty("Config.Path") == "./config/中国_client.config");
test(properties.getProperty("Ice.ProgramName") == "PropertiesClient");
test(appName().Equals(properties.getProperty("Ice.ProgramName")));
Copy link
Member

Choose a reason for hiding this comment

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

appName() returns a string too, doesn't it?

test(properties.getProperty("Ice.ProgramName") == appName());

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it was an automatic update. There are many more Equals that can be replaced by ==

@bernardnormier bernardnormier merged commit 97456b0 into zeroc-ice:main Feb 1, 2024
17 checks passed
@bernardnormier bernardnormier deleted the cs-equals branch May 10, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants