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

[C#] Inconsistent String Comparisons in Schema Field Retrieval Methods #44650

Open
vthemelis opened this issue Nov 5, 2024 · 0 comments
Open

Comments

@vthemelis
Copy link

vthemelis commented Nov 5, 2024

In the Schema class, there are three methods used to retrieve individual fields:

public class Schema
{
    // ...

    public Field GetFieldByName(string name) => FieldsLookup[name].FirstOrDefault();

    public int GetFieldIndex(string name, StringComparer comparer)
    {
        IEqualityComparer<string> equalityComparer = (IEqualityComparer<string>)comparer;
        return GetFieldIndex(name, equalityComparer);
    }

    public int GetFieldIndex(string name, IEqualityComparer<string> comparer = default)
    {
        // Implementation using the specified comparer
    }
}

The first method (GetFieldByName) use the default string comparer, while the latter two (GetFieldIndex overloads) are using a culture aware comparator by default (StringComparer.CurrentCulture). This inconsistency can be confusing, as it is unclear when custom comparers are utilized.

Component(s)

C#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant