feat(TableColumnFilter): contains filter support case-sensitive#6626
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnhance the string ‘Contains’ filter to use the overload with StringComparison and enable case-insensitive matching, and extend unit tests to cover mixed-case scenarios. Class diagram for updated LambdaExtensions string Contains filterclassDiagram
class LambdaExtensions {
+Contains(Expression left, Expression right)
}
LambdaExtensions : Contains uses string.Contains(string value, StringComparison comparison)
class string {
+Contains(string value, StringComparison comparison)
}
LambdaExtensions --> string : calls Contains with StringComparison
Flow diagram for case-insensitive Contains filter logicflowchart TD
A[Input string for filter] --> B{Is input null?}
B -- Yes --> C[Return false]
B -- No --> D[Call string.Contains with StringComparison.OrdinalIgnoreCase]
D --> E[Return result]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Extensions/LambdaExtensions.cs:234` </location>
<code_context>
- var method = typeof(string).GetMethod("Contains", [typeof(string)])!;
- return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right));
+ var method = typeof(string).GetMethod("Contains", [typeof(string), typeof(StringComparison)])!;
+ var comparison = Expression.Constant(StringComparison.OrdinalIgnoreCase);
+ return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison));
}
</code_context>
<issue_to_address>
Consider making StringComparison configurable instead of hardcoding OrdinalIgnoreCase.
Allowing the caller to specify the StringComparison would improve flexibility and accommodate different comparison needs.
Suggested implementation:
```csharp
private static BinaryExpression Contains(this Expression left, Expression right, StringComparison comparisonType)
{
var method = typeof(string).GetMethod("Contains", [typeof(string), typeof(StringComparison)])!;
var comparison = Expression.Constant(comparisonType);
return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison));
}
```
You will need to update all usages of the `Contains` extension method to pass the desired `StringComparison` value as an argument.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+234
to
+235
| var comparison = Expression.Constant(StringComparison.OrdinalIgnoreCase); | ||
| return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison)); |
Contributor
There was a problem hiding this comment.
suggestion: Consider making StringComparison configurable instead of hardcoding OrdinalIgnoreCase.
Allowing the caller to specify the StringComparison would improve flexibility and accommodate different comparison needs.
Suggested implementation:
private static BinaryExpression Contains(this Expression left, Expression right, StringComparison comparisonType)
{
var method = typeof(string).GetMethod("Contains", [typeof(string), typeof(StringComparison)])!;
var comparison = Expression.Constant(comparisonType);
return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison));
}You will need to update all usages of the Contains extension method to pass the desired StringComparison value as an argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #6625
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable and test case-insensitive string comparison for the Contains filter, addressing issue #6625
Bug Fixes:
Enhancements:
Tests: