You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/extensions/file-globbing.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,37 @@ The preceding C# code:
141
141
142
142
The additional `Match` overloads work in similar ways.
143
143
144
+
### Ordered evaluation of include/exclude
145
+
146
+
By default, the matcher evaluates **all** include patterns first, then applies **all** exclude patterns, regardless of the order in which you added them. This means you can't re-include files that were previously excluded.
147
+
148
+
Starting in version 10 of the [📦 Microsoft.Extensions.FileSystemGlobbing package](https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing), you can opt into *ordered* evaluation, where includes and excludes are processed exactly in the sequence they were added:
149
+
150
+
```csharp
151
+
usingMicrosoft.Extensions.FileSystemGlobbing;
152
+
153
+
// Preserve the order of patterns when matching.
154
+
Matchermatcher=new(preserveFilterOrder: true);
155
+
156
+
matcher.AddInclude("**/*"); // include everything
157
+
matcher.AddExclude("logs/**/*"); // exclude logs
158
+
matcher.AddInclude("logs/important/**/*"); // re-include important logs
0 commit comments