@@ -1865,7 +1865,7 @@ private static CacheInfo GetCacheInfo(Identity identity, object? exampleParamete
18651865
18661866 private static bool ShouldPassByPosition ( string sql )
18671867 {
1868- return sql ? . IndexOf ( '?' ) >= 0 && pseudoPositional . IsMatch ( sql ) ;
1868+ return sql ? . IndexOf ( '?' ) >= 0 && CompiledRegex . PseudoPositional . IsMatch ( sql ) ;
18691869 }
18701870
18711871 private static void PassByPosition ( IDbCommand cmd )
@@ -1882,7 +1882,7 @@ private static void PassByPosition(IDbCommand cmd)
18821882 bool firstMatch = true ;
18831883 int index = 0 ; // use this to spoof names; in most pseudo-positional cases, the name is ignored, however:
18841884 // for "snowflake", the name needs to be incremental i.e. "1", "2", "3"
1885- cmd . CommandText = pseudoPositional . Replace ( cmd . CommandText , match =>
1885+ cmd . CommandText = CompiledRegex . PseudoPositional . Replace ( cmd . CommandText , match =>
18861886 {
18871887 string key = match . Groups [ 1 ] . Value ;
18881888 if ( ! consumed . Add ( key ) )
@@ -2386,11 +2386,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
23862386 return list ;
23872387 }
23882388
2389- // look for ? / @ / : *by itself*
2390- private static readonly Regex smellsLikeOleDb = new ( @"(?<![\p{L}\p{N}@_])[?@:](?![\p{L}\p{N}@_])" , RegexOptions . IgnoreCase | RegexOptions . Multiline | RegexOptions . CultureInvariant | RegexOptions . Compiled ) ,
2391- literalTokens = new ( @"(?<![\p{L}\p{N}_])\{=([\p{L}\p{N}_]+)\}" , RegexOptions . IgnoreCase | RegexOptions . Multiline | RegexOptions . CultureInvariant | RegexOptions . Compiled ) ,
2392- pseudoPositional = new ( @"\?([\p{L}_][\p{L}\p{N}_]*)\?" , RegexOptions . IgnoreCase | RegexOptions . CultureInvariant | RegexOptions . Compiled ) ;
2393-
23942389 /// <summary>
23952390 /// Replace all literal tokens with their text form.
23962391 /// </summary>
@@ -2496,9 +2491,9 @@ internal static void ReplaceLiterals(IParameterLookup parameters, IDbCommand com
24962491 internal static IList < LiteralToken > GetLiteralTokens ( string sql )
24972492 {
24982493 if ( string . IsNullOrEmpty ( sql ) ) return LiteralToken . None ;
2499- if ( ! literalTokens . IsMatch ( sql ) ) return LiteralToken . None ;
2494+ if ( ! CompiledRegex . LiteralTokens . IsMatch ( sql ) ) return LiteralToken . None ;
25002495
2501- var matches = literalTokens . Matches ( sql ) ;
2496+ var matches = CompiledRegex . LiteralTokens . Matches ( sql ) ;
25022497 var found = new HashSet < string > ( StringComparer . Ordinal ) ;
25032498 var list = new List < LiteralToken > ( matches . Count ) ;
25042499 foreach ( Match match in matches )
@@ -2538,7 +2533,7 @@ private static bool IsValueTuple(Type? type) => (type?.IsValueType == true
25382533
25392534 if ( filterParams && Settings . SupportLegacyParameterTokens )
25402535 {
2541- filterParams = ! smellsLikeOleDb . IsMatch ( identity . Sql ) ;
2536+ filterParams = ! CompiledRegex . LegacyParameter . IsMatch ( identity . Sql ) ;
25422537 }
25432538
25442539 var dm = new DynamicMethod ( "ParamInfo" + Guid . NewGuid ( ) . ToString ( ) , null , new [ ] { typeof ( IDbCommand ) , typeof ( object ) } , type , true ) ;
0 commit comments