forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Support for Translating ByteArray.IndexOf for SQLite
Fixes dotnet#19287
- Loading branch information
Showing
11 changed files
with
299 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore; | ||
|
||
internal static class ArrayMethods | ||
{ | ||
public static MethodInfo IndexOf { get; } | ||
|
||
public static MethodInfo IndexOfWithStartingPosition { get; } | ||
|
||
static ArrayMethods() | ||
{ | ||
var arrayGenericMethods = typeof(Array) | ||
.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) | ||
.Where(m => m.IsGenericMethod) | ||
.GroupBy(m => m.Name) | ||
.ToDictionary(m => m.Key, l => l.ToList()); | ||
|
||
IndexOf = GetMethod(nameof(Array.IndexOf), 1, (t) => | ||
{ | ||
return [t[0].MakeArrayType(), t[0]]; | ||
}); | ||
|
||
IndexOfWithStartingPosition = GetMethod(nameof(Array.IndexOf), 1, (t) => | ||
{ | ||
return [t[0].MakeArrayType(), t[0], typeof(int)]; | ||
}); | ||
|
||
MethodInfo GetMethod(string name, int genericParameterCount, Func<Type[], Type[]> parameterGenerator) | ||
=> arrayGenericMethods[name].Single( | ||
mi => mi.IsGenericMethod && mi.GetGenericArguments().Length == genericParameterCount | ||
&& mi.GetParameters().Select(e => e.ParameterType).SequenceEqual( | ||
parameterGenerator(mi.IsGenericMethod ? mi.GetGenericArguments() : []))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.