From 71db0ff8088aff692ddb2d193494570c9fb48c89 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 3 Jan 2022 14:20:47 +0100 Subject: [PATCH] Add [DynamicDependency] on System.Math for trimming Fixes #27097 --- src/EFCore.Relational/Query/IMethodCallTranslator.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/EFCore.Relational/Query/IMethodCallTranslator.cs b/src/EFCore.Relational/Query/IMethodCallTranslator.cs index 0f815b4edab..b6e2ecebe74 100644 --- a/src/EFCore.Relational/Query/IMethodCallTranslator.cs +++ b/src/EFCore.Relational/Query/IMethodCallTranslator.cs @@ -1,7 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -28,6 +30,9 @@ public interface IMethodCallTranslator /// SQL representations of . /// The query logger to use. /// A SQL translation of the . + // This is a 6.0.x hack to make trimming work, since the linker doesn't see our GetRequiredRuntimeMethod invocations below + // (see #26288) + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Math))] SqlExpression? Translate( SqlExpression? instance, MethodInfo method,