Skip to content

Commit 0f5e184

Browse files
committed
Fix usage of question mark. Not sure if this is what was intended but seemed logical.
1 parent 45eba43 commit 0f5e184

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ Coverlet gives the ability to have fine grained control over what gets excluded
101101

102102
Syntax: `/p:Exclude=[Assembly-Filter]Type-Filter`
103103

104+
Wildcards
105+
- `*` => matches zero or more characters
106+
- `?` => the prefixed character is optional
107+
104108
Examples
105109
- `/p:Exclude="[*]*"` => Excludes all types in all assemblies (nothing is instrumented)
106110
- `/p:Exclude="[coverlet.*]Coverlet.Core.Coverage"` => Excludes the Coverage class in the `Coverlet.Core` namespace belonging to any assembly that matches `coverlet.*` (e.g `coverlet.core`)
107111
- `/p:Exclude="[*]Coverlet.Core.Instrumentation.*"` => Excludes all types belonging to `Coverlet.Core.Instrumentation` namespace in any assembly
112+
- `/p:Exclude="[coverlet.*.tests?]*"` => Excludes all types in any assembly starting with `coverlet.` and ending with `.test` or `.tests` (the `?` makes the `s` optional)
113+
- `/p:Exclude="[coverlet.*]*,[*]Coverlet..Core*"` => Excludes assemblies matching `coverlet.*` and excludes all types belonging to the `Coverlet.Core` namespace in any assembly
108114

109115
```bash
110116
dotnet test /p:CollectCoverage=true /p:Exclude="[coverlet.*]Coverlet.Core.Coverage"

src/coverlet.core/Helpers/InstrumentationHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static bool IsValidFilterExpression(string filter)
107107
if (filter.EndsWith("]"))
108108
return false;
109109

110-
if (new Regex(@"[^\w*]").IsMatch(filter.Replace(".", "").Replace("[", "").Replace("]", "")))
110+
if (new Regex(@"[^\w*]").IsMatch(filter.Replace(".", "").Replace("?", "").Replace("[", "").Replace("]", "")))
111111
return false;
112112

113113
return true;
@@ -229,7 +229,7 @@ private static string WildcardToRegex(string pattern)
229229
{
230230
return "^" + Regex.Escape(pattern).
231231
Replace("\\*", ".*").
232-
Replace("\\?", ".") + "$";
232+
Replace("\\?", "?") + "$";
233233
}
234234

235235
private static bool IsAssembly(string filePath)

0 commit comments

Comments
 (0)