Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Aug 15, 2025

Link issues

fixes #6625

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enable and test case-insensitive string comparison for the Contains filter, addressing issue #6625

Bug Fixes:

  • Fix Contains filter not matching values with differing letter cases

Enhancements:

  • Enable case-insensitive matching for the Contains filter by using the StringComparison.OrdinalIgnoreCase overload

Tests:

  • Add unit tests to verify case-insensitive Contains filter behavior

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enhance 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 filter

classDiagram
    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
Loading

Flow diagram for case-insensitive Contains filter logic

flowchart 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]
Loading

File-Level Changes

Change Details Files
Use StringComparison overload for Contains filter
  • Retrieve the two-parameter Contains method (string, StringComparison)
  • Add a StringComparison.OrdinalIgnoreCase constant
  • Call Contains with the comparison argument and null-check the left expression
src/BootstrapBlazor/Extensions/LambdaExtensions.cs
Extend unit tests for case-insensitive Contains
  • Add assertions for matching mixed-case substrings
  • Verify behavior with various uppercase and lowercase inputs
test/UnitTest/Extensions/LambadaExtensionsTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6625 Add case-insensitive support to the 'contains' filter in TableColumnFilter.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Aug 15, 2025
@bb-auto bb-auto bot added this to the 9.9.0 milestone Aug 15, 2025
@ArgoZhang ArgoZhang merged commit 716325e into main Aug 15, 2025
3 of 4 checks passed
@ArgoZhang ArgoZhang deleted the feat-table-filter branch August 15, 2025 04:57
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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));
Copy link
Contributor

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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(TableColumnFilter): contains filter support case-sensitive

2 participants