@@ -1416,33 +1416,14 @@ public void TerminationInNonBacktrackingVsBackTracking(RegexOptions options, int
1416
1416
[ Theory ]
1417
1417
[ InlineData ( RegexEngine . Interpreter ) ]
1418
1418
[ InlineData ( RegexEngine . Compiled ) ]
1419
- public void PatternsDataSet_ConstructRegexForAll ( RegexEngine engine )
1419
+ public async Task PatternsDataSet_ConstructRegexForAll ( RegexEngine engine )
1420
1420
{
1421
- Parallel . ForEach ( s_patternsDataSet . Value , r =>
1421
+ foreach ( DataSetExpression exp in s_patternsDataSet . Value )
1422
1422
{
1423
- try
1424
- {
1425
- RegexHelpers . GetRegexAsync ( engine , r . Pattern , r . Options ) . GetAwaiter ( ) . GetResult ( ) ;
1426
- }
1427
- catch ( Exception e ) when ( RegexHelpers . IsNonBacktracking ( engine ) && e . Message . Contains ( "NonBacktracking" ) )
1428
- {
1429
- // Some tests aren't supported with RegexOptions.NonBacktracking.
1430
- }
1431
- } ) ;
1423
+ await RegexHelpers . GetRegexAsync ( engine , exp . Pattern , exp . Options ) ;
1424
+ }
1432
1425
}
1433
1426
1434
- [ OuterLoop ( "Takes many seconds" ) ]
1435
- [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "NonBacktracking isn't supported on .NET Framework" ) ]
1436
- [ Fact ]
1437
- public void PatternsDataSet_ConstructRegexForAll_NonBacktracking ( ) =>
1438
- PatternsDataSet_ConstructRegexForAll ( RegexEngine . NonBacktracking ) ;
1439
-
1440
- [ OuterLoop ( "Takes minutes to generate and compile thousands of expressions" ) ]
1441
- [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "Source generator isn't supported on .NET Framework" ) ]
1442
- [ Fact ]
1443
- public void PatternsDataSet_ConstructRegexForAll_SourceGenerated ( ) =>
1444
- PatternsDataSet_ConstructRegexForAll ( RegexEngine . SourceGenerated ) ;
1445
-
1446
1427
private static Lazy < DataSetExpression [ ] > s_patternsDataSet = new Lazy < DataSetExpression [ ] > ( ( ) =>
1447
1428
{
1448
1429
using Stream json = File . OpenRead ( "Regex_RealWorldPatterns.json" ) ;
@@ -1460,5 +1441,32 @@ other is not null &&
1460
1441
other . Pattern == Pattern &&
1461
1442
( Options & ~ RegexOptions . Compiled ) == ( other . Options & ~ RegexOptions . Compiled ) ; // Compiled doesn't affect semantics, so remove it from equality for our purposes
1462
1443
}
1444
+
1445
+ #if NETCOREAPP
1446
+ [ OuterLoop ( "Takes many seconds" ) ]
1447
+ [ Fact ]
1448
+ public async Task PatternsDataSet_ConstructRegexForAll_NonBacktracking ( )
1449
+ {
1450
+ foreach ( DataSetExpression exp in s_patternsDataSet . Value )
1451
+ {
1452
+ try
1453
+ {
1454
+ await RegexHelpers . GetRegexAsync ( RegexEngine . NonBacktracking , exp . Pattern , exp . Options ) ;
1455
+ }
1456
+ catch ( Exception e ) when ( e . Message . Contains ( nameof ( RegexOptions . NonBacktracking ) ) ) { }
1457
+ }
1458
+ }
1459
+
1460
+ [ OuterLoop ( "Takes minutes to generate and compile thousands of expressions" ) ]
1461
+ [ Fact ]
1462
+ public void PatternsDataSet_ConstructRegexForAll_SourceGenerated ( )
1463
+ {
1464
+ Parallel . ForEach ( s_patternsDataSet . Value . Chunk ( 50 ) , chunk =>
1465
+ {
1466
+ RegexHelpers . GetRegexesAsync ( RegexEngine . SourceGenerated ,
1467
+ chunk . Select ( r => ( r . Pattern , ( RegexOptions ? ) r . Options , ( TimeSpan ? ) null ) ) . ToArray ( ) ) . GetAwaiter ( ) . GetResult ( ) ;
1468
+ } ) ;
1469
+ }
1470
+ #endif
1463
1471
}
1464
1472
}
0 commit comments