Skip to content

Commit

Permalink
Exclude the CreateActionModel method from trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
mkArtakMSFT committed Jan 30, 2025
1 parent e937a99 commit 7886a25
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -355,6 +356,8 @@ internal PropertyModel CreatePropertyModel(PropertyInfo propertyInfo)
return actionModel;
}

[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode",
Justification = "The method utilizes reflection to get information about the return type of an action")]
internal static void AddReturnTypeMetadata(IList<SelectorModel> selectors, MethodInfo methodInfo)
{
// Get metadata from return type
Expand All @@ -372,7 +375,7 @@ internal static void AddReturnTypeMetadata(IList<SelectorModel> selectors, Metho
invokeArgs[0] = methodInfo;
invokeArgs[1] = builder;
EndpointMetadataPopulator.PopulateMetadataForEndpointMethod.MakeGenericMethod(returnType).Invoke(null, invokeArgs);

// The metadata is added to the builder's metadata collection.
// We need to populate the selectors with that metadata.
foreach (var metadata in builder.Metadata)
Expand Down

0 comments on commit 7886a25

Please sign in to comment.