Add static extension Regex.FromWildcardPattern(string)#47
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/fbafd155-9400-46b5-825d-e116527b1ba7 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
|
||
| namespace PowerKit.Tests; | ||
|
|
||
| public class RegexExtensionsTests |
There was a problem hiding this comment.
Try to consolidate tests a little bit, there are too many @copilot
There was a problem hiding this comment.
Consolidated from 7 methods down to 2 in 757dd1e: FromWildcardPattern_Test (covering *, ?, exact match, and special-char escaping) and FromWildcardPattern_WithOptions_Test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #47 +/- ##
==========================================
+ Coverage 94.36% 94.38% +0.02%
==========================================
Files 82 86 +4
Lines 1740 1800 +60
Branches 141 143 +2
==========================================
+ Hits 1642 1699 +57
- Misses 72 74 +2
- Partials 26 27 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/808cccdf-71cc-4c16-a5fb-6c24ead92543 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Regex static extension API for turning shell-style wildcard patterns (*, ?) into anchored regular expressions, with accompanying unit tests in PowerKit.Tests.
Changes:
- Introduces
Regex.FromWildcardPattern(string pattern, RegexOptions options = RegexOptions.None)to convert wildcard patterns into aRegex. - Adds xUnit/FluentAssertions coverage for
*,?, mixed patterns, exact matching, options passthrough, and escaping of regex metacharacters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| PowerKit/Extensions/RegexExtensions.cs | Adds Regex.FromWildcardPattern(...) implementation by escaping literals and translating */? into regex equivalents. |
| PowerKit.Tests/RegexExtensionsTests.cs | Adds tests verifying wildcard behavior, escaping, and options passthrough. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot please fix formatting |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/a104cbf6-8d39-4974-b874-f8b0ab40eb64 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Adds a static extension method on
Regexto construct aRegexfrom a shell-style wildcard pattern, where?matches any single character and*matches any sequence of characters. All other characters (including regex metacharacters) are treated as literals viaRegex.Escape.Changes
PowerKit/Extensions/RegexExtensions.cs— newextension(Regex)block exposingRegex.FromWildcardPattern(string pattern, RegexOptions options = RegexOptions.None)PowerKit.Tests/RegexExtensionsTests.cs— tests covering*,?, combined patterns, exact matching,RegexOptionspassthrough, and regex special-char escapingUsage