Skip to content

Commit

Permalink
Fix AOT warning in System.Linq.Expressions (#109758)
Browse files Browse the repository at this point in the history
The UnconditionalSuppressMessage didn't work correctly because
it wasn't targeting the static constructor. We don't need to suppress
this warning - we can just bubble it up because it looks like all references
to CallSiteOpsReflectionCache<T> are already annotated with
RequiresDynamicCode.
  • Loading branch information
sbomer authored Nov 13, 2024
1 parent f40ef93 commit 25307d8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Reflection;

namespace System.Runtime.CompilerServices;

[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
internal static class CallSiteOpsReflectionCache<T> where T : class
{
[Obsolete("CallSiteOps has been deprecated and is not supported.", error: false), EditorBrowsable(EditorBrowsableState.Never)]
Expand All @@ -31,7 +33,5 @@ internal static class CallSiteOpsReflectionCache<T> where T : class
public static readonly MethodInfo MoveRule = ((Delegate)CallSiteOps.MoveRule<T>).GetMethodInfo();

[Obsolete("CallSiteOps has been deprecated and is not supported.", error: false), EditorBrowsable(EditorBrowsableState.Never)]
[UnconditionalSuppressMessage("DynamicCode", "IL3050",
Justification = "CallSiteOps is obsolete and CallSite has RUC. Propagating warnings through fields isn't worth it.")]
public static readonly MethodInfo Bind = ((Delegate)CallSiteOps.Bind<T>).GetMethodInfo();
}

0 comments on commit 25307d8

Please sign in to comment.