From d91d59c16bed05fb68cfec912fd4e9eb23936d10 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 12 Sep 2024 19:28:41 +0000 Subject: [PATCH] Fix for linker errors --- src/Components/Forms/src/FieldIdentifier.cs | 4 ++-- src/SignalR/server/Core/src/DynamicHub.cs | 2 ++ src/SignalR/server/Core/src/DynamicHubClients.cs | 2 ++ src/SignalR/server/Core/src/Internal/DynamicClientProxy.cs | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Components/Forms/src/FieldIdentifier.cs b/src/Components/Forms/src/FieldIdentifier.cs index 3a5eab25b70c..1ff67d80c610 100644 --- a/src/Components/Forms/src/FieldIdentifier.cs +++ b/src/Components/Forms/src/FieldIdentifier.cs @@ -126,7 +126,7 @@ private static void ParseAccessor(Expression> accessor, out object mo // so, given that it embeds captured values such as "this". We could consider special-casing // for "() => something.Member" and building a cache keyed by "something.GetType()" with values // of type Func so we can cheaply map from "something" to "something.Member". - var modelLambda = Expression.Lambda(memberExpression.Expression); + var modelLambda = Expression.Lambda(typeof(Func), memberExpression.Expression); var modelLambdaCompiled = (Func)modelLambda.Compile(); var result = modelLambdaCompiled() ?? throw new ArgumentException("The provided expression must evaluate to a non-null value."); @@ -201,7 +201,7 @@ static Func CreateAccessor((Type model, MemberInfo member) arg) private static object GetModelFromIndexer(Expression methodCallExpression) { object model; - var methodCallObjectLambda = Expression.Lambda(methodCallExpression!); + var methodCallObjectLambda = Expression.Lambda(typeof(Func), methodCallExpression!); var methodCallObjectLambdaCompiled = (Func)methodCallObjectLambda.Compile(); var result = methodCallObjectLambdaCompiled(); if (result is null) diff --git a/src/SignalR/server/Core/src/DynamicHub.cs b/src/SignalR/server/Core/src/DynamicHub.cs index 8375c80d4063..8b8eb67f7f60 100644 --- a/src/SignalR/server/Core/src/DynamicHub.cs +++ b/src/SignalR/server/Core/src/DynamicHub.cs @@ -1,11 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; namespace Microsoft.AspNetCore.SignalR; /// /// A base class for SignalR hubs that use dynamic to represent client invocations. /// +[RequiresDynamicCode("DynamicHub requires dynamic code generation to construct a call site.")] public abstract class DynamicHub : Hub { private DynamicHubClients? _clients; diff --git a/src/SignalR/server/Core/src/DynamicHubClients.cs b/src/SignalR/server/Core/src/DynamicHubClients.cs index 6151e5b12296..67bd2d18aef5 100644 --- a/src/SignalR/server/Core/src/DynamicHubClients.cs +++ b/src/SignalR/server/Core/src/DynamicHubClients.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.SignalR.Internal; namespace Microsoft.AspNetCore.SignalR; @@ -8,6 +9,7 @@ namespace Microsoft.AspNetCore.SignalR; /// /// A class that provides dynamic access to connections, including the one that sent the current invocation. /// +[RequiresDynamicCodeAttribute("DynamicHubClient requires dynamic code generation to construct a call site.")] public class DynamicHubClients { private readonly IHubCallerClients _clients; diff --git a/src/SignalR/server/Core/src/Internal/DynamicClientProxy.cs b/src/SignalR/server/Core/src/Internal/DynamicClientProxy.cs index e8f1f49f909e..9c2f769fdacf 100644 --- a/src/SignalR/server/Core/src/Internal/DynamicClientProxy.cs +++ b/src/SignalR/server/Core/src/Internal/DynamicClientProxy.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Dynamic; namespace Microsoft.AspNetCore.SignalR.Internal; @@ -9,6 +10,7 @@ internal sealed class DynamicClientProxy : DynamicObject { private readonly IClientProxy _clientProxy; + [RequiresDynamicCodeAttribute("This constructor requires dynamic code generation to construct a call site.")] public DynamicClientProxy(IClientProxy clientProxy) { _clientProxy = clientProxy;