Update CaseInsensitiveSubstringSearch sample to .NET 10 - #2206
Open
vladimir-pecanac-main wants to merge 1 commit into
Open
vladimir-pecanac-main wants to merge 1 commit into
vladimir-pecanac-main wants to merge 1 commit into
Conversation
Retarget all three projects from net7.0 to net10.0 and move the test and benchmark packages to their current stable versions. Make RegexIsMatch treat the search term as literal text with Regex.Escape and add RegexOptions.CultureInvariant, so a term holding regex metacharacters no longer matches the wrong strings or throws. Add SubstringSearchSemanticsTest pinning three facts: LinqStringEquals matches whole separator-delimited words rather than substrings, the escaped regex search agrees with String.Contains on metacharacter terms, and all four containment methods still match under a Turkish culture.
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.
Retargets the CaseInsensitiveSubstringSearch sample from net7.0 to net10.0 across all three projects and moves the test and benchmark packages to their current stable versions (Microsoft.NET.Test.Sdk 18.10.0, MSTest 4.4.0, coverlet.collector 10.0.1, BenchmarkDotNet 0.15.8). The MSTest 2.x to 4.x jump needed no source changes.
One behaviour fix: RegexIsMatch passed the caller's search term straight in as a regular expression pattern. Terms such as "c.de", "z*" and "m|q" matched strings that do not contain them, and "(" threw a RegexParseException instead of returning false. It now wraps the term in Regex.Escape() and adds RegexOptions.CultureInvariant, which also fixes a miss under a Turkish culture.
Two explanatory comments record what Regex.Escape and CultureInvariant are for, and that LinqStringEquals matches whole separator-delimited words rather than substrings.
New test class SubstringSearchSemanticsTest, three test methods over eight cases, pins all of that. Build is clean at 0 warnings and 0 errors, and dotnet test --filter "FullyQualifiedName!~Live" reports 23 passed, 0 failed, 0 skipped on .NET 10.0.10.