-
Notifications
You must be signed in to change notification settings - Fork 224
Description
Perhaps this should not be an issue or a feature request but I think it's worthy of discussion, and we can always delete later if needed.
I'm about to Migrate perhaps 50k to 100k lines of code from VB to C#. Almost all of it has Option Compare Text.
Now when we migrate, code like this
If kv.Key = sVariableName Then
It gets converted to this:
if (CultureInfo.CurrentCulture.CompareInfo.Compare(kv.Key ?? "", sVariableName ?? "", CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0)
I'm sure I'm not the only one who doesn't want to live with that kind of code going forward, especially in a large project.
Ideally I would like improve the syntactic elegance using something like an Extension method
[Extension]
public static bool EqualsIgnoreCase(this string str1, string str2)
{
return string.Equals(str1 ?? "", str2 ?? "", StringComparison.OrdinalIgnoreCase);
}
Then the migrated c# would be
if (kv.Key.EqualsIgnoreCase(sVariableName)) {
I would have liked to overload the string == operator but that doesn't sound possible.
So, before I start digging in the CodeConverter source code for how to implement this, are there any other options or ways to influence the conversion as above, and does anyone else feel that there would be value in changing the code if appropriate for something like the above ?