Skip to content

Commit c8fe8ca

Browse files
committed
Enable trimming checks for Mvc.Core and consumers
1 parent 37a62ae commit c8fe8ca

File tree

6 files changed

+678
-3
lines changed

6 files changed

+678
-3
lines changed

src/Mvc/Mvc.ApiExplorer/src/DefaultApiDescriptionProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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;
45
using System.Linq;
56
using Microsoft.AspNetCore.Http.Metadata;
67
using Microsoft.AspNetCore.Mvc.Abstractions;
@@ -20,6 +21,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer;
2021
/// Implements a provider of <see cref="ApiDescription"/> for actions represented
2122
/// by <see cref="ControllerActionDescriptor"/>.
2223
/// </summary>
24+
[RequiresUnreferencedCode("DefaultApiDescriptionProvider is used by MVC which does not currently support trimming or native AOT.", Url = "https://aka.ms/aspnet/trimming")]
2325
public class DefaultApiDescriptionProvider : IApiDescriptionProvider
2426
{
2527
private readonly MvcOptions _mvcOptions;
@@ -268,7 +270,7 @@ parameter.ModelMetadata is DefaultModelMetadata defaultModelMetadata &&
268270
!defaultModelMetadata.Attributes.Attributes.OfType<IFromRouteMetadata>().Any())
269271
{
270272
// If we didn't see the parameter in the route and no FromRoute metadata is set, it probably means
271-
// the parameter binding source was inferred (InferParameterBindingInfoConvention)
273+
// the parameter binding source was inferred (InferParameterBindingInfoConvention)
272274
// probably because another route to this action contains it as route parameter and
273275
// will be removed from the API description
274276
// https://github.com/dotnet/aspnetcore/issues/26234

src/Mvc/Mvc.ApiExplorer/src/DependencyInjection/MvcApiExplorerMvcCoreBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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;
45
using Microsoft.AspNetCore.Mvc.ApiExplorer;
56
using Microsoft.Extensions.DependencyInjection.Extensions;
67

@@ -16,6 +17,7 @@ public static class MvcApiExplorerMvcCoreBuilderExtensions
1617
/// </summary>
1718
/// <param name="builder">The <see cref="IMvcCoreBuilder"/>.</param>
1819
/// <returns>The <see cref="IMvcCoreBuilder"/>.</returns>
20+
[RequiresUnreferencedCode("MVC does not currently support trimming or native AOT.", Url = "https://aka.ms/aspnet/trimming")]
1921
public static IMvcCoreBuilder AddApiExplorer(this IMvcCoreBuilder builder)
2022
{
2123
ArgumentNullException.ThrowIfNull(builder);
@@ -25,6 +27,7 @@ public static IMvcCoreBuilder AddApiExplorer(this IMvcCoreBuilder builder)
2527
}
2628

2729
// Internal for testing.
30+
[RequiresUnreferencedCode("MVC does not currently support trimming or native AOT.", Url = "https://aka.ms/aspnet/trimming")]
2831
internal static void AddApiExplorerServices(IServiceCollection services)
2932
{
3033
services.TryAddSingleton<IApiDescriptionGroupCollectionProvider, ApiDescriptionGroupCollectionProvider>();

src/Mvc/Mvc.ApiExplorer/src/Microsoft.AspNetCore.Mvc.ApiExplorer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>
99
<IsPackable>false</IsPackable>
10-
<IsAotCompatible>true</IsAotCompatible>
10+
<IsTrimmable>true</IsTrimmable>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

0 commit comments

Comments
 (0)