Skip to content

Commit 24417c5

Browse files
authored
Solve some easy NativeAOT warnings. (#35560)
1 parent 2bbae55 commit 24417c5

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ namespace Microsoft.EntityFrameworkCore;
1919
"MakeGenericMethod is used in this class to create MethodCallExpression nodes, but only if the method in question is called "
2020
+ "from user code - so it's never trimmed. After https://github.com/dotnet/linker/issues/2482 is fixed, the suppression will no "
2121
+ "longer be necessary.")]
22+
[UnconditionalSuppressMessage(
23+
"AOT",
24+
"IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.",
25+
Justification =
26+
"MakeGenericMethod is used in this class to create MethodCallExpression nodes, but only if the method in question is called "
27+
+ "from user code - so it's never trimmed.")]
2228
public static class EntityFrameworkQueryableExtensions
2329
{
2430
/// <summary>

src/EFCore/Query/QueryableMethods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.EntityFrameworkCore.Query;
57

68
/// <summary>
@@ -458,6 +460,7 @@ public static MethodInfo GetSumWithSelector(Type type)
458460
private static Dictionary<Type, MethodInfo> SumWithoutSelectorMethods { get; }
459461
private static Dictionary<Type, MethodInfo> SumWithSelectorMethods { get; }
460462

463+
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Types used here in 'MakeGenericType' are types like 'TSource', not specific types.")]
461464
static QueryableMethods()
462465
{
463466
var queryableMethodGroups = typeof(Queryable)

src/Shared/EnumerableMethods.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections;
5+
using System.Diagnostics.CodeAnalysis;
56

67
namespace Microsoft.EntityFrameworkCore;
78

@@ -248,6 +249,7 @@ public static MethodInfo GetMinWithoutSelector(Type type)
248249
public static MethodInfo GetMinWithSelector(Type type)
249250
=> MinWithSelectorMethods.GetValueOrDefault(type, MinWithSelector);
250251

252+
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Types used here in 'MakeGenericType' are types like 'TSource', not specific types.")]
251253
static EnumerableMethods()
252254
{
253255
var queryableMethodGroups = typeof(Enumerable)

0 commit comments

Comments
 (0)