-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(TableColumnFilter): contains filter support case-sensitive #6626
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
Conversation
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| var comparison = Expression.Constant(StringComparison.OrdinalIgnoreCase); | ||
| return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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: