Skip to content

Commit dda3543

Browse files
authored
Merge pull request #173 from servicetitan/mergeUpstream
Merge upstream
2 parents e20b684 + 2876029 commit dda3543

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

Orm/Xtensive.Orm/IoC/ServiceContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected virtual object CreateInstance(ServiceRegistration serviceInfo)
119119
_ = creating.TryRemove(key, out _);
120120
}
121121
#if NET8_0_OR_GREATER
122-
return cInfo.Invoke(new Span<object>(args));
122+
return cInfo.Invoke(args.AsSpan());
123123
#else
124124
return cInfo.Invoke(args);
125125
#endif

Orm/Xtensive.Orm/Orm/Linq/QueryProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,21 @@ public IQueryable<TElement> CreateQuery<TElement>(Expression expression) =>
5353
object IQueryProvider.Execute(Expression expression)
5454
{
5555
var resultType = expression.Type;
56+
#if NET8_0_OR_GREATER
5657
var executeMethod = resultType.IsOfGenericInterface(WellKnownInterfaces.EnumerableOfT)
57-
? WellKnownMembers.QueryProvider.ExecuteSequence.CachedMakeGenericMethodInvoker(
58-
SequenceHelper.GetElementType(resultType))
58+
? WellKnownMembers.QueryProvider.ExecuteSequence.CachedMakeGenericMethodInvoker(SequenceHelper.GetElementType(resultType))
5959
: WellKnownMembers.QueryProvider.ExecuteScalar.CachedMakeGenericMethodInvoker(resultType);
6060
try {
61-
#if NET8_0_OR_GREATER
6261
return executeMethod.Invoke(this, expression);
62+
}
6363
#else
64+
var executeMethod = resultType.IsOfGenericInterface(WellKnownInterfaces.EnumerableOfT)
65+
? WellKnownMembers.QueryProvider.ExecuteSequence.CachedMakeGenericMethod(SequenceHelper.GetElementType(resultType))
66+
: WellKnownMembers.QueryProvider.ExecuteScalar.CachedMakeGenericMethod(resultType);
67+
try {
6468
return executeMethod.Invoke(this, new object[] { expression });
65-
#endif
6669
}
70+
#endif
6771
catch (TargetInvocationException e) {
6872
if (e.InnerException != null) {
6973
ExceptionDispatchInfo.Throw(e.InnerException);

Orm/Xtensive.Orm/Reflection/TypeHelper.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public int GetHashCode((Type, Type[]) obj)
5454
private static readonly string TypeHelperNamespace = typeof(TypeHelper).Namespace;
5555

5656
#if NET8_0_OR_GREATER
57-
private static readonly ConcurrentDictionary<(Type, Type[]), ConstructorInvoker> ConstructorInfoByTypes =
57+
private static readonly ConcurrentDictionary<(Type, Type[]), ConstructorInvoker> ConstructorInvokerByTypes =
5858
#else
5959
private static readonly ConcurrentDictionary<(Type, Type[]), ConstructorInfo> ConstructorInfoByTypes =
6060
#endif
@@ -666,7 +666,7 @@ public static object Activate(this Type type, Type[] genericArguments, params ob
666666
/// </exception>
667667
#if NET8_0_OR_GREATER
668668
public static ConstructorInvoker GetSingleConstructorInvoker(this Type type, Type[] argumentTypes) =>
669-
ConstructorInfoByTypes.GetOrAdd((type, argumentTypes),
669+
ConstructorInvokerByTypes.GetOrAdd((type, argumentTypes),
670670
static t => ConstructorExtractor(t) is ConstructorInfo ctor
671671
? ConstructorInvoker.Create(ctor)
672672
: throw new InvalidOperationException(Strings.ExGivenTypeHasNoOrMoreThanOneCtorWithGivenParameters));
@@ -689,7 +689,7 @@ public static ConstructorInfo GetSingleConstructor(this Type type, Type[] argume
689689
[CanBeNull]
690690
#if NET8_0_OR_GREATER
691691
public static ConstructorInvoker GetSingleConstructorInvokerOrDefault(this Type type, Type[] argumentTypes) =>
692-
ConstructorInfoByTypes.GetOrAdd((type, argumentTypes),
692+
ConstructorInvokerByTypes.GetOrAdd((type, argumentTypes),
693693
static t => ConstructorExtractor(t) is ConstructorInfo ctor ? ConstructorInvoker.Create(ctor) : null);
694694
#else
695695
public static ConstructorInfo GetSingleConstructorOrDefault(this Type type, Type[] argumentTypes) =>
@@ -970,12 +970,6 @@ public static MethodInvoker CachedMakeGenericMethodInvoker(this MethodInfo gener
970970

971971
public static MethodInvoker CachedMakeGenericMethodInvoker(this MethodInfo genericDefinition, Type typeArgument1, Type typeArgument2) =>
972972
GenericMethodInvokers2.GetOrAdd((genericDefinition, typeArgument1, typeArgument2), GenericMethodInvokerFactory2);
973-
#else
974-
public static MethodInfo CachedMakeGenericMethodInvoker(this MethodInfo genericDefinition, Type typeArgument) =>
975-
CachedMakeGenericMethod(genericDefinition, typeArgument);
976-
977-
public static MethodInfo CachedMakeGenericMethodInvoker(this MethodInfo genericDefinition, Type typeArgument1, Type typeArgument2) =>
978-
CachedMakeGenericMethod(genericDefinition, typeArgument1, typeArgument2);
979973
#endif
980974

981975
public static Type CachedMakeGenericType(this Type genericDefinition, Type typeArgument) =>

0 commit comments

Comments
 (0)