Skip to content

Conversation

@victorr99
Copy link

The ExpressionParser was updated with a new method allowing case insensitive compares whenever this was configured in the ParserConfig.

The method CanonicalContains performs a case insensitive check whenever IsCaseSensitive was set to false. It also updates the provided needle parameter to the actual found value. Thus a match on max will be translated to Max.

This fixes issue #967

Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

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

And will this not break any code where a Class has a property max?

Like

public class X
{
  public string max { get ; set; }

   public string MAX { get ; set; }
}

Maybe add a unit test for this.

return true;
}

private bool CanonicalContains(string[] haystack, ref string needle)
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to use ref

just do:

if (_parsingConfig.IsCaseSensitive)
{
    return haystack.Contains(needle);
}

return haystack.Any(s => string.Equals(s, value, StringComparison.OrdinalIgnoreCase));

Copy link
Author

Choose a reason for hiding this comment

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

I've changed the method to just Contains. It indeed works without using ref, so I've removed that.
I've tried to add some unit tests with a max property. Is this what you had in mind?

- Tests added for a model with a max property
- CanonicalContains is now just Contains without ref string needle
@victorr99 victorr99 requested a review from StefH December 6, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants