Skip to content

Commit e8b7160

Browse files
committed
Optimize RegexOptions
1 parent b1d11e2 commit e8b7160

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/DapperTests/IntegrationTests/SqlTextAdapter.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ namespace DapperTests.IntegrationTests;
55

66
internal sealed class SqlTextAdapter(DatabaseProvider databaseProvider)
77
{
8+
#if NET6_0
9+
private const RegexOptions Options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture;
10+
#else
11+
private const RegexOptions Options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.NonBacktracking;
12+
#endif
13+
814
private static readonly Dictionary<Regex, string> SqlServerReplacements = new()
915
{
10-
[new Regex("\"([^\"]+)\"", RegexOptions.Compiled)] = "[$+]",
11-
[new Regex($@"(VALUES \([^)]*\)){Environment.NewLine}RETURNING \[Id\]", RegexOptions.Compiled)] = $"OUTPUT INSERTED.[Id]{Environment.NewLine}$1"
16+
[new Regex("\"([^\"]+)\"", Options)] = "[$+]",
17+
[new Regex($@"(VALUES \([^)]*\)){Environment.NewLine}RETURNING \[Id\]", Options)] = $"OUTPUT INSERTED.[Id]{Environment.NewLine}$1"
1218
};
1319

1420
private readonly DatabaseProvider _databaseProvider = databaseProvider;

0 commit comments

Comments
 (0)