@@ -76,15 +76,18 @@ public override HqlTreeNode BuildHql(MemberInfo member, Expression expression, H
76
76
77
77
public class StartsWithGenerator : BaseHqlGeneratorForMethod
78
78
{
79
+ private static readonly MethodInfo MethodWithComparer = ReflectHelper . GetMethodDefinition < string > ( x => x . StartsWith ( null , default ( StringComparison ) ) ) ;
80
+
79
81
public StartsWithGenerator ( )
80
82
{
81
- SupportedMethods = new [ ] { ReflectHelper . GetMethodDefinition < string > ( x => x . StartsWith ( null ) ) } ;
83
+ SupportedMethods = new [ ] { ReflectHelper . GetMethodDefinition < string > ( x => x . StartsWith ( null ) ) , MethodWithComparer } ;
82
84
}
83
85
84
86
public override bool AllowsNullableReturnType ( MethodInfo method ) => false ;
85
87
86
88
public override HqlTreeNode BuildHql ( MethodInfo method , Expression targetObject , ReadOnlyCollection < Expression > arguments , HqlTreeBuilder treeBuilder , IHqlExpressionVisitor visitor )
87
89
{
90
+ LogIgnoredStringComparisonParameter ( method , MethodWithComparer ) ;
88
91
return treeBuilder . Like (
89
92
visitor . Visit ( targetObject ) . AsExpression ( ) ,
90
93
treeBuilder . Concat (
@@ -95,15 +98,18 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
95
98
96
99
public class EndsWithGenerator : BaseHqlGeneratorForMethod
97
100
{
101
+ private static readonly MethodInfo MethodWithComparer = ReflectHelper . GetMethodDefinition < string > ( x => x . EndsWith ( null , default ( StringComparison ) ) ) ;
102
+
98
103
public EndsWithGenerator ( )
99
104
{
100
- SupportedMethods = new [ ] { ReflectHelper . GetMethodDefinition < string > ( x => x . EndsWith ( null ) ) } ;
105
+ SupportedMethods = new [ ] { ReflectHelper . GetMethodDefinition < string > ( x => x . EndsWith ( null ) ) , MethodWithComparer , } ;
101
106
}
102
107
103
108
public override bool AllowsNullableReturnType ( MethodInfo method ) => false ;
104
109
105
110
public override HqlTreeNode BuildHql ( MethodInfo method , Expression targetObject , ReadOnlyCollection < Expression > arguments , HqlTreeBuilder treeBuilder , IHqlExpressionVisitor visitor )
106
111
{
112
+ LogIgnoredStringComparisonParameter ( method , MethodWithComparer ) ;
107
113
return treeBuilder . Like (
108
114
visitor . Visit ( targetObject ) . AsExpression ( ) ,
109
115
treeBuilder . Concat (
@@ -210,20 +216,32 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
210
216
211
217
public class IndexOfGenerator : BaseHqlGeneratorForMethod
212
218
{
219
+ private static readonly MethodInfo MethodWithComparer1 = ReflectHelper . GetMethodDefinition < string > ( x => x . IndexOf ( string . Empty , default ( StringComparison ) ) ) ;
220
+ private static readonly MethodInfo MethodWithComparer2 = ReflectHelper . GetMethodDefinition < string > ( x => x . IndexOf ( string . Empty , 0 , default ( StringComparison ) ) ) ;
221
+
213
222
public IndexOfGenerator ( )
214
223
{
215
224
SupportedMethods = new [ ]
216
225
{
217
226
ReflectHelper . GetMethodDefinition < string > ( s => s . IndexOf ( ' ' ) ) ,
218
227
ReflectHelper . GetMethodDefinition < string > ( s => s . IndexOf ( " " ) ) ,
219
228
ReflectHelper . GetMethodDefinition < string > ( s => s . IndexOf ( ' ' , 0 ) ) ,
220
- ReflectHelper . GetMethodDefinition < string > ( s => s . IndexOf ( " " , 0 ) )
229
+ ReflectHelper . GetMethodDefinition < string > ( s => s . IndexOf ( " " , 0 ) ) ,
230
+ MethodWithComparer1 ,
231
+ MethodWithComparer2 ,
221
232
} ;
222
233
}
223
234
public override HqlTreeNode BuildHql ( MethodInfo method , Expression targetObject , ReadOnlyCollection < Expression > arguments , HqlTreeBuilder treeBuilder , IHqlExpressionVisitor visitor )
224
235
{
236
+ var argsCount = arguments . Count ;
237
+ if ( LogIgnoredStringComparisonParameter ( method , MethodWithComparer1 , MethodWithComparer2 ) )
238
+ {
239
+ //StringComparison is last argument, just ignore it
240
+ argsCount -- ;
241
+ }
242
+
225
243
HqlMethodCall locate ;
226
- if ( arguments . Count == 1 )
244
+ if ( argsCount == 1 )
227
245
{
228
246
locate = treeBuilder . MethodCall ( "locate" ,
229
247
visitor . Visit ( arguments [ 0 ] ) . AsExpression ( ) ,
@@ -244,21 +262,32 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
244
262
245
263
public class ReplaceGenerator : BaseHqlGeneratorForMethod
246
264
{
265
+ #if NETCOREAPP2_0
266
+ private static readonly MethodInfo MethodWithComparer = ReflectHelper . GetMethodDefinition < string > ( x => x . Replace ( string . Empty , string . Empty , default ( StringComparison ) ) ) ;
267
+ #endif
268
+
247
269
public ReplaceGenerator ( )
248
270
{
249
271
SupportedMethods = new [ ]
250
- {
251
- ReflectHelper . GetMethodDefinition < string > ( s => s . Replace ( ' ' , ' ' ) ) ,
252
- ReflectHelper . GetMethodDefinition < string > ( s => s . Replace ( "" , "" ) )
253
- } ;
272
+ {
273
+ ReflectHelper . GetMethodDefinition < string > ( s => s . Replace ( ' ' , ' ' ) ) ,
274
+ ReflectHelper . GetMethodDefinition < string > ( s => s . Replace ( "" , "" ) ) ,
275
+ #if NETCOREAPP2_0
276
+ MethodWithComparer ,
277
+ #endif
278
+ } ;
254
279
}
255
280
256
281
public override HqlTreeNode BuildHql ( MethodInfo method , Expression targetObject , ReadOnlyCollection < Expression > arguments , HqlTreeBuilder treeBuilder , IHqlExpressionVisitor visitor )
257
282
{
258
- return treeBuilder . MethodCall ( "replace" ,
259
- visitor . Visit ( targetObject ) . AsExpression ( ) ,
260
- visitor . Visit ( arguments [ 0 ] ) . AsExpression ( ) ,
261
- visitor . Visit ( arguments [ 1 ] ) . AsExpression ( ) ) ;
283
+ #if NETCOREAPP2_0
284
+ LogIgnoredStringComparisonParameter ( method , MethodWithComparer ) ;
285
+ #endif
286
+ return treeBuilder . MethodCall (
287
+ "replace" ,
288
+ visitor . Visit ( targetObject ) . AsExpression ( ) ,
289
+ visitor . Visit ( arguments [ 0 ] ) . AsExpression ( ) ,
290
+ visitor . Visit ( arguments [ 1 ] ) . AsExpression ( ) ) ;
262
291
}
263
292
}
264
293
0 commit comments