@@ -252,13 +252,14 @@ private bool IsStringOrStringArray(object val)
252
252
return val == null ? false : valArr . All ( x => x is string ) ;
253
253
}
254
254
255
- private List < string > ParseSettingValueStringOrStrings ( object value , string settingName )
255
+ private List < string > ParseSettingValueStringOrStrings ( object value , string settingName , IList < Exception > exceptions )
256
256
{
257
257
if ( value == null )
258
258
{
259
- throw new InvalidDataException ( string . Format (
259
+ exceptions . Add ( new InvalidDataException ( string . Format (
260
260
Strings . SettingValueIsNull ,
261
- settingName ) ) ;
261
+ settingName ) ) ) ;
262
+ return null ;
262
263
}
263
264
264
265
if ( value is string )
@@ -268,9 +269,10 @@ private List<string> ParseSettingValueStringOrStrings(object value, string setti
268
269
269
270
if ( ! ( value is ICollection ) )
270
271
{
271
- throw new InvalidDataException ( string . Format (
272
+ exceptions . Add ( new InvalidDataException ( string . Format (
272
273
Strings . SettingValueIsNotStringOrStringsType ,
273
- settingName ) ) ;
274
+ settingName ) ) ) ;
275
+ return null ;
274
276
}
275
277
var values = value as ICollection ;
276
278
@@ -280,19 +282,21 @@ private List<string> ParseSettingValueStringOrStrings(object value, string setti
280
282
{
281
283
if ( element is null )
282
284
{
283
- throw new InvalidDataException ( string . Format (
285
+ exceptions . Add ( new InvalidDataException ( string . Format (
284
286
Strings . SettingValueElementIsNull ,
285
287
settingName ,
286
- elementIndex ) ) ;
288
+ elementIndex ) ) ) ;
289
+ continue ;
287
290
}
288
291
289
292
if ( ! ( element is string ) )
290
293
{
291
- throw new InvalidDataException ( string . Format (
294
+ exceptions . Add ( new InvalidDataException ( string . Format (
292
295
Strings . SettingValueElementIsNotStringType ,
293
296
settingName ,
294
297
elementIndex ,
295
- element ) ) ;
298
+ element ) ) ) ;
299
+ continue ;
296
300
}
297
301
strings . Add ( element as string ) ;
298
302
@@ -368,23 +372,43 @@ private void ParseSettingsHashtable(Hashtable settings)
368
372
switch ( settingName . ToLowerInvariant ( ) )
369
373
{
370
374
case "severity" :
371
- // TODO Aggregate exceptions.
372
- this . severities = ParseSettingValueStringOrStrings ( setting . Value , settingName ) ;
375
+ var maybeSeverity = ParseSettingValueStringOrStrings ( setting . Value , settingName , exceptions ) ;
376
+ if ( maybeSeverity is null )
377
+ {
378
+ continue ;
379
+ }
380
+
381
+ this . severities = maybeSeverity ;
373
382
break ;
374
383
375
384
case "includerules" :
376
- // TODO Aggregate exceptions.
377
- this . includeRules = ParseSettingValueStringOrStrings ( setting . Value , settingName ) ;
385
+ var maybeIncludeRules = ParseSettingValueStringOrStrings ( setting . Value , settingName , exceptions ) ;
386
+ if ( maybeIncludeRules is null )
387
+ {
388
+ continue ;
389
+ }
390
+
391
+ this . includeRules = maybeIncludeRules ;
378
392
break ;
379
393
380
394
case "excluderules" :
381
- // TODO Aggregate exceptions.
382
- this . excludeRules = ParseSettingValueStringOrStrings ( setting . Value , settingName ) ;
395
+ var maybeExcludeRules = ParseSettingValueStringOrStrings ( setting . Value , settingName , exceptions ) ;
396
+ if ( maybeExcludeRules is null )
397
+ {
398
+ continue ;
399
+ }
400
+
401
+ this . excludeRules = maybeExcludeRules ;
383
402
break ;
384
403
385
404
case "customrulepath" :
386
- // TODO Aggregate exceptions.
387
- this . customRulePath = ParseSettingValueStringOrStrings ( setting . Value , settingName ) ;
405
+ var maybeCustomRulePath = ParseSettingValueStringOrStrings ( setting . Value , settingName , exceptions ) ;
406
+ if ( maybeCustomRulePath is null )
407
+ {
408
+ continue ;
409
+ }
410
+
411
+ this . customRulePath = maybeCustomRulePath ;
388
412
break ;
389
413
390
414
case "includedefaultrules" :
0 commit comments