@@ -81,6 +81,38 @@ public static void DeleteHitsFile(string path)
81
81
RetryHelper . Retry ( ( ) => File . Delete ( path ) , retryStrategy , 10 ) ;
82
82
}
83
83
84
+ public static bool IsValidFilterExpression ( string filter )
85
+ {
86
+ if ( filter == null )
87
+ return false ;
88
+
89
+ if ( ! filter . StartsWith ( "[" ) )
90
+ return false ;
91
+
92
+ if ( ! filter . Contains ( "]" ) )
93
+ return false ;
94
+
95
+ if ( filter . Count ( f => f == '[' ) > 1 )
96
+ return false ;
97
+
98
+ if ( filter . Count ( f => f == ']' ) > 1 )
99
+ return false ;
100
+
101
+ if ( filter . IndexOf ( ']' ) < filter . IndexOf ( '[' ) )
102
+ return false ;
103
+
104
+ if ( filter . IndexOf ( ']' ) - filter . IndexOf ( '[' ) == 1 )
105
+ return false ;
106
+
107
+ if ( filter . EndsWith ( "]" ) )
108
+ return false ;
109
+
110
+ if ( new Regex ( @"[^\w*]" ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
111
+ return false ;
112
+
113
+ return true ;
114
+ }
115
+
84
116
public static bool IsModuleExcluded ( string module , string [ ] filters )
85
117
{
86
118
if ( filters == null )
@@ -91,9 +123,6 @@ public static bool IsModuleExcluded(string module, string[] filters)
91
123
92
124
foreach ( var filter in filters )
93
125
{
94
- if ( ! IsValidFilterExpression ( filter ) )
95
- continue ;
96
-
97
126
string modulePattern = filter . Substring ( 1 , filter . IndexOf ( ']' ) - 1 ) ;
98
127
string typePattern = filter . Substring ( filter . IndexOf ( ']' ) + 1 ) ;
99
128
@@ -116,9 +145,6 @@ public static bool IsTypeExcluded(string module, string type, string[] filters)
116
145
117
146
foreach ( var filter in filters )
118
147
{
119
- if ( ! IsValidFilterExpression ( filter ) )
120
- continue ;
121
-
122
148
string typePattern = filter . Substring ( filter . IndexOf ( ']' ) + 1 ) ;
123
149
string modulePattern = filter . Substring ( 1 , filter . IndexOf ( ']' ) - 1 ) ;
124
150
@@ -191,35 +217,6 @@ TimeSpan retryStrategy()
191
217
return retryStrategy ;
192
218
}
193
219
194
- private static bool IsValidFilterExpression ( string filter )
195
- {
196
- if ( ! filter . StartsWith ( "[" ) )
197
- return false ;
198
-
199
- if ( ! filter . Contains ( "]" ) )
200
- return false ;
201
-
202
- if ( filter . Count ( f => f == '[' ) > 1 )
203
- return false ;
204
-
205
- if ( filter . Count ( f => f == ']' ) > 1 )
206
- return false ;
207
-
208
- if ( filter . IndexOf ( ']' ) < filter . IndexOf ( '[' ) )
209
- return false ;
210
-
211
- if ( filter . IndexOf ( ']' ) - filter . IndexOf ( '[' ) == 1 )
212
- return false ;
213
-
214
- if ( filter . EndsWith ( "]" ) )
215
- return false ;
216
-
217
- if ( new Regex ( @"[^\w*]" ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
218
- return false ;
219
-
220
- return true ;
221
- }
222
-
223
220
private static string WildcardToRegex ( string pattern )
224
221
{
225
222
return "^" + Regex . Escape ( pattern ) .
0 commit comments