Skip to content

Commit b64de7a

Browse files
github-actions[bot]captainsafiawtgodbe
authored
[release/9.0-preview7] Make ApiExplorer for minimal APIs trim-compatible (#56937)
* Make ApiExplorer for minimal APIs trim-compatible * Enable trimming checks for Mvc.Core and consumers * Add setup for NativeAoT test project for OpenAPI * Update AspNetCore.sln reference to OpenAPI tests * Fix OpenApi.slnf * Address feedback from API review * Update OpenApi.slnf * Confirming my sanity * Refactor ModelMetadata for trim compatability * Disable native AoT tests until Microsoft.OpenApi is trim-compatible * Fix up NativeAoT tests for OpenApi * Fix ModelMetadata trimming without API changes * Update native AoT for MVC * Add RDC/RUC attributes and update exception messages * Update suppressions and add more RUC/RDC attributes * Revise ParameterBindingMethodCache initialization and consumption * Update ci-public.yml --------- Co-authored-by: Safia Abdalla <safia@safia.rocks> Co-authored-by: William Godbe <wigodbe@microsoft.com>
1 parent ed7ea40 commit b64de7a

File tree

120 files changed

+2501
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2501
-253
lines changed

.azure/pipelines/ci-public.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,6 @@ stages:
556556
beforeBuild:
557557
- powershell: "& ./src/Servers/IIS/tools/UpdateIISExpressCertificate.ps1; & ./src/Servers/IIS/tools/update_schema.ps1"
558558
displayName: Setup IISExpress test certificates and schema
559-
afterBuild:
560-
- powershell: ./eng/scripts/CompareMinifiedJsFiles.ps1
561-
displayName: Check for changes in generated minified .js files
562559
artifacts:
563560
- name: Windows_Test_Logs_Attempt_$(System.JobAttempt)
564561
path: artifacts/log/

AspNetCore.sln

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,8 +1674,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResultsOfTGenerator", "src\
16741674
EndProject
16751675
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenApi", "OpenApi", "{2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}"
16761676
EndProject
1677-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.OpenApi.Tests", "src\OpenApi\test\Microsoft.AspNetCore.OpenApi.Tests.csproj", "{3AEFB466-6310-4F3F-923F-9154224E3629}"
1678-
EndProject
16791677
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.OpenApi", "src\OpenApi\src\Microsoft.AspNetCore.OpenApi.csproj", "{EFC8EA45-572D-4D8D-A597-9045A2D8EC40}"
16801678
EndProject
16811679
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RateLimiting", "src\Middleware\RateLimiting\src\Microsoft.AspNetCore.RateLimiting.csproj", "{8EE73488-2B92-42BD-96C9-0DD65405C828}"
@@ -1818,6 +1816,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetDocumentSample", "src\To
18181816
EndProject
18191817
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorUnitedApp.Client", "src\Components\Samples\BlazorUnitedApp.Client\BlazorUnitedApp.Client.csproj", "{757CBDE0-5D0A-4FD8-99F3-6C20BDDD4E63}"
18201818
EndProject
1819+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC}"
1820+
EndProject
1821+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.OpenApi.Tests", "src\OpenApi\test\Microsoft.AspNetCore.OpenApi.Tests\Microsoft.AspNetCore.OpenApi.Tests.csproj", "{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}"
1822+
EndProject
18211823
Global
18221824
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18231825
Debug|Any CPU = Debug|Any CPU
@@ -10147,22 +10149,6 @@ Global
1014710149
{9716D0D0-2251-44DD-8596-67D253EEF41C}.Release|x64.Build.0 = Release|Any CPU
1014810150
{9716D0D0-2251-44DD-8596-67D253EEF41C}.Release|x86.ActiveCfg = Release|Any CPU
1014910151
{9716D0D0-2251-44DD-8596-67D253EEF41C}.Release|x86.Build.0 = Release|Any CPU
10150-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10151-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|Any CPU.Build.0 = Debug|Any CPU
10152-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|arm64.ActiveCfg = Debug|Any CPU
10153-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|arm64.Build.0 = Debug|Any CPU
10154-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|x64.ActiveCfg = Debug|Any CPU
10155-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|x64.Build.0 = Debug|Any CPU
10156-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|x86.ActiveCfg = Debug|Any CPU
10157-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Debug|x86.Build.0 = Debug|Any CPU
10158-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|Any CPU.ActiveCfg = Release|Any CPU
10159-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|Any CPU.Build.0 = Release|Any CPU
10160-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|arm64.ActiveCfg = Release|Any CPU
10161-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|arm64.Build.0 = Release|Any CPU
10162-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|x64.ActiveCfg = Release|Any CPU
10163-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|x64.Build.0 = Release|Any CPU
10164-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|x86.ActiveCfg = Release|Any CPU
10165-
{3AEFB466-6310-4F3F-923F-9154224E3629}.Release|x86.Build.0 = Release|Any CPU
1016610152
{EFC8EA45-572D-4D8D-A597-9045A2D8EC40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1016710153
{EFC8EA45-572D-4D8D-A597-9045A2D8EC40}.Debug|Any CPU.Build.0 = Debug|Any CPU
1016810154
{EFC8EA45-572D-4D8D-A597-9045A2D8EC40}.Debug|arm64.ActiveCfg = Debug|Any CPU
@@ -10995,6 +10981,22 @@ Global
1099510981
{757CBDE0-5D0A-4FD8-99F3-6C20BDDD4E63}.Release|x64.Build.0 = Release|Any CPU
1099610982
{757CBDE0-5D0A-4FD8-99F3-6C20BDDD4E63}.Release|x86.ActiveCfg = Release|Any CPU
1099710983
{757CBDE0-5D0A-4FD8-99F3-6C20BDDD4E63}.Release|x86.Build.0 = Release|Any CPU
10984+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10985+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
10986+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|arm64.ActiveCfg = Debug|Any CPU
10987+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|arm64.Build.0 = Debug|Any CPU
10988+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|x64.ActiveCfg = Debug|Any CPU
10989+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|x64.Build.0 = Debug|Any CPU
10990+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|x86.ActiveCfg = Debug|Any CPU
10991+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Debug|x86.Build.0 = Debug|Any CPU
10992+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
10993+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|Any CPU.Build.0 = Release|Any CPU
10994+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|arm64.ActiveCfg = Release|Any CPU
10995+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|arm64.Build.0 = Release|Any CPU
10996+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|x64.ActiveCfg = Release|Any CPU
10997+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|x64.Build.0 = Release|Any CPU
10998+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|x86.ActiveCfg = Release|Any CPU
10999+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7}.Release|x86.Build.0 = Release|Any CPU
1099811000
EndGlobalSection
1099911001
GlobalSection(SolutionProperties) = preSolution
1100011002
HideSolutionNode = FALSE
@@ -11824,7 +11826,6 @@ Global
1182411826
{046F43BC-BEE4-48B7-8C09-ED0A1054A2D7} = {AA5ABFBC-177C-421E-B743-005E0FD1248B}
1182511827
{9716D0D0-2251-44DD-8596-67D253EEF41C} = {323C3EB6-1D15-4B3D-918D-699D7F64DED9}
1182611828
{2299CCD8-8F9C-4F2B-A633-9BF4DA81022B} = {017429CC-C5FB-48B4-9C46-034E29EE2F06}
11827-
{3AEFB466-6310-4F3F-923F-9154224E3629} = {2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}
1182811829
{EFC8EA45-572D-4D8D-A597-9045A2D8EC40} = {2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}
1182911830
{8EE73488-2B92-42BD-96C9-0DD65405C828} = {1D865E78-7A66-4CA9-92EE-2B350E45281F}
1183011831
{41FF4F96-98D2-4482-A2A7-4B179E80D285} = {1D865E78-7A66-4CA9-92EE-2B350E45281F}
@@ -11893,6 +11894,8 @@ Global
1189311894
{6A19D94D-2BC6-4198-BE2E-342688FDBA4B} = {A1B75FC7-A777-4412-A635-D0C9ED8FE7A0}
1189411895
{D8F7091E-A2D1-4E81-BA7C-97EAE392D683} = {A1B75FC7-A777-4412-A635-D0C9ED8FE7A0}
1189511896
{757CBDE0-5D0A-4FD8-99F3-6C20BDDD4E63} = {5FE1FBC1-8CE3-4355-9866-44FE1307C5F1}
11897+
{B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC} = {2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}
11898+
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7} = {B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC}
1189611899
EndGlobalSection
1189711900
GlobalSection(ExtensibilityGlobals) = postSolution
1189811901
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

eng/RequiresDelayedBuildProjects.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.Swagger.Tests\Microsoft.AspNetCore.Grpc.Swagger.Tests.csproj" />
2121
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\IntegrationTestsWebsite\IntegrationTestsWebsite.csproj" />
2222
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\Sandbox\Sandbox.csproj" />
23+
<RequiresDelayedBuild Include="$(RepoRoot)src\OpenApi\test\Microsoft.AspNetCore.OpenApi.NativeAotTests\Microsoft.AspNetCore.OpenApi.NativeAotTests.proj" />
2324
<RequiresDelayedBuild Include="$(RepoRoot)src\ProjectTemplates\test\Templates.Blazor.Tests\Templates.Blazor.Tests.csproj" />
2425
<RequiresDelayedBuild Include="$(RepoRoot)src\SignalR\server\SignalR\test\Microsoft.AspNetCore.SignalR.TrimmingTests\Microsoft.AspNetCore.SignalR.TrimmingTests.proj" />
2526
<RequiresDelayedBuild Include="$(RepoRoot)eng\Npm.Workspace.FunctionalTests.nodeproj" />

eng/TrimmableProjects.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<TrimmableProject Include="Microsoft.AspNetCore.SpaServices.Extensions" />
8686
<TrimmableProject Include="Microsoft.AspNetCore.StaticFiles" />
8787
<TrimmableProject Include="Microsoft.AspNetCore.WebSockets" />
88+
<TrimmableProject Include="Microsoft.AspNetCore.Mvc.Abstractions" />
89+
<TrimmableProject Include="Microsoft.AspNetCore.Mvc.ApiExplorer" />
90+
<TrimmableProject Include="Microsoft.AspNetCore.Mvc.Core" />
8891
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Client.Core" />
8992
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Client" />
9093
<TrimmableProject Include="Microsoft.AspNetCore.Http.Connections.Client" />

eng/testing/linker/SupportFiles/Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
<ProjectReference Include="$(RepoRoot)src\DataProtection\Extensions\src\Microsoft.AspNetCore.DataProtection.Extensions.csproj" />
7676
<ProjectReference Include="$(RepoRoot)src\SignalR\clients\csharp\Client\src\Microsoft.AspNetCore.SignalR.Client.csproj" />
7777
<ProjectReference Include="$(RepoRoot)src\SignalR\server\SignalR\src\Microsoft.AspNetCore.SignalR.csproj" />
78+
<ProjectReference Include="$(RepoRoot)src\OpenApi\src\Microsoft.AspNetCore.OpenApi.csproj" />
79+
<ProjectReference Include="$(RepoRoot)src\Http\Http.Extensions\gen\Microsoft.AspNetCore.Http.RequestDelegateGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
7880
</ItemGroup>
7981

8082
</Project>

eng/testing/linker/project.csproj.template

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<!-- Workaround while there is no SDK available that understands the TFM; suppress unsupported version errors. -->
1212
<NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
1313
<_ExtraTrimmerArgs>{ExtraTrimmerArgs} $(_ExtraTrimmerArgs)</_ExtraTrimmerArgs>
14+
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.AspNetCore.Http.Generated</InterceptorsPreviewNamespaces>
15+
<!-- Ensure individual warnings are shown when publishing -->
16+
<TrimmerSingleWarn>false</TrimmerSingleWarn>
17+
<!-- But ignore the single warn files marked below to suppress their known warnings. -->
18+
<NoWarn>$(NoWarn);IL2104</NoWarn>
1419
{AdditionalProperties}
1520
</PropertyGroup>
1621

@@ -21,5 +26,20 @@
2126
<ItemGroup>
2227
{AdditionalProjectReferences}
2328
</ItemGroup>
24-
29+
30+
<!-- Single warn the following assemblies, which have known warnings, so the warnings can be suppressed for now.
31+
Remove this (and the above NoWarn IL2104) once https://github.com/microsoft/OpenAPI.NET/pull/1717 is merged. -->
32+
<Target Name="ConfigureTrimming"
33+
BeforeTargets="PrepareForILLink">
34+
<ItemGroup>
35+
<IlcArg Include="--singlewarnassembly:Microsoft.OpenApi" />
36+
</ItemGroup>
37+
<ItemGroup>
38+
<ManagedAssemblyToLink Condition="'%(Filename)' == 'Microsoft.OpenApi'">
39+
<IsTrimmable>true</IsTrimmable>
40+
<TrimmerSingleWarn>true</TrimmerSingleWarn>
41+
</ManagedAssemblyToLink>
42+
</ItemGroup>
43+
</Target>
44+
2545
</Project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Reflection;
5+
6+
namespace Microsoft.AspNetCore.Http.Metadata;
7+
8+
/// <summary>
9+
/// Exposes metadata about the parameter binding details associated with a parameter
10+
/// in the endpoints handler.
11+
/// </summary>
12+
/// <remarks>
13+
/// This metadata is injected by the RequestDelegateFactory and RequestDelegateGenerator components
14+
/// and is primarily intended for consumption by the EndpointMetadataApiDescriptionProvider in
15+
/// ApiExplorer.
16+
/// </remarks>
17+
public interface IParameterBindingMetadata
18+
{
19+
/// <summary>
20+
/// The name of the parameter.
21+
/// </summary>
22+
string Name { get; }
23+
24+
/// <summary>
25+
/// <see langword="true "/> is the parameter is associated with a type that implements <see cref="IParsable{TSelf}" /> or exposes a <c>TryParse</c> method.
26+
/// </summary>
27+
bool HasTryParse { get; }
28+
29+
/// <summary>
30+
/// <see langword="true"/> if the parameter is associated with a type that implements a <c>BindAsync</c> method.
31+
/// </summary>
32+
bool HasBindAsync { get; }
33+
34+
/// <summary>
35+
/// The <see cref="ParameterInfo"/> associated with the parameter.
36+
/// </summary>
37+
ParameterInfo ParameterInfo { get; }
38+
39+
/// <summary>
40+
/// <see langword="true"/> if the parameter is optional.
41+
/// </summary>
42+
bool IsOptional { get; }
43+
}

src/Http/Http.Abstractions/src/PublicAPI.Unshipped.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ Microsoft.AspNetCore.Http.HostString.HostString(string? value) -> void
55
Microsoft.AspNetCore.Http.HostString.Value.get -> string?
66
Microsoft.AspNetCore.Http.HttpValidationProblemDetails.HttpValidationProblemDetails(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, string![]!>>! errors) -> void
77
Microsoft.AspNetCore.Http.Metadata.IDisableHttpMetricsMetadata
8+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata
9+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.HasBindAsync.get -> bool
10+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.HasTryParse.get -> bool
11+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.IsOptional.get -> bool
12+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.Name.get -> string!
13+
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.ParameterInfo.get -> System.Reflection.ParameterInfo!

src/Http/Http.Extensions/gen/RequestDelegateGenerator.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
using System.Globalization;
66
using System.IO;
77
using System.Linq;
8-
using System.Text;
98
using Microsoft.AspNetCore.Analyzers.Infrastructure;
109
using Microsoft.AspNetCore.App.Analyzers.Infrastructure;
1110
using Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandlerModel;
1211
using Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandlerModel.Emitters;
1312
using Microsoft.CodeAnalysis;
1413
using Microsoft.CodeAnalysis.CSharp;
15-
using Microsoft.CodeAnalysis.Operations;
1614

1715
namespace Microsoft.AspNetCore.Http.RequestDelegateGenerator;
1816

@@ -243,6 +241,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
243241
var hasJsonBody = endpoints.Any(endpoint => endpoint.EmitterContext.HasJsonBody || endpoint.EmitterContext.HasJsonBodyOrService || endpoint.EmitterContext.HasJsonBodyOrQuery);
244242
var hasResponseMetadata = endpoints.Any(endpoint => endpoint.EmitterContext.HasResponseMetadata);
245243
var requiresPropertyAsParameterInfo = endpoints.Any(endpoint => endpoint.EmitterContext.RequiresPropertyAsParameterInfo);
244+
var requiresParameterBindingMetadataClass = endpoints.Any(endpoint => endpoint.EmitterContext.RequiresParameterBindingMetadataClass);
246245

247246
using var stringWriter = new StringWriter(CultureInfo.InvariantCulture);
248247
using var codeWriter = new CodeWriter(stringWriter, baseIndent: 0);
@@ -262,6 +261,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
262261
codeWriter.WriteLine(RequestDelegateGeneratorSources.PropertyAsParameterInfoClass);
263262
}
264263

264+
if (requiresParameterBindingMetadataClass)
265+
{
266+
codeWriter.WriteLine(RequestDelegateGeneratorSources.ParameterBindingMetadataClass);
267+
}
268+
265269
return stringWriter.ToString();
266270
});
267271

src/Http/Http.Extensions/gen/RequestDelegateGeneratorSources.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,36 @@ public override bool IsDefined(Type attributeType, bool inherit)
449449
}
450450
""";
451451

452+
public static string ParameterBindingMetadataClass = $$"""
453+
{{GeneratedCodeAttribute}}
454+
file sealed class ParameterBindingMetadata: IParameterBindingMetadata
455+
{
456+
internal ParameterBindingMetadata(
457+
string name,
458+
ParameterInfo parameterInfo,
459+
bool hasTryParse = false,
460+
bool hasBindAsync = false,
461+
bool isOptional = false)
462+
{
463+
Name = name;
464+
ParameterInfo = parameterInfo;
465+
HasTryParse = hasTryParse;
466+
HasBindAsync = hasBindAsync;
467+
IsOptional = isOptional;
468+
}
469+
470+
public string Name { get; }
471+
472+
public bool HasTryParse { get; }
473+
474+
public bool HasBindAsync { get; }
475+
476+
public ParameterInfo ParameterInfo { get; }
477+
478+
public bool IsOptional { get; }
479+
}
480+
""";
481+
452482
public static string AntiforgeryMetadataType = """
453483
file sealed class AntiforgeryMetadata : IAntiforgeryMetadata
454484
{

src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EmitterContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ internal sealed class EmitterContext
1212
public bool HasBindAsync { get; set; }
1313
public bool HasParsable { get; set; }
1414
public bool RequiresPropertyAsParameterInfo { get; set; }
15+
public bool RequiresParameterBindingMetadataClass { get; set; }
1516
public bool RequiresLoggingHelper { get; set; }
1617
public bool HasEndpointMetadataProvider { get; set; }
1718
public bool HasEndpointParameterMetadataProvider { get; set; }

src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private EndpointParameter(Endpoint endpoint, IPropertySymbol property, IParamete
4747
PropertyAsParameterInfoConstruction = parameter is not null
4848
? $"new PropertyAsParameterInfo({(IsOptional ? "true" : "false")}, {propertyInfo}, {parameter.GetParameterInfoFromConstructorCode()})"
4949
: $"new PropertyAsParameterInfo({(IsOptional ? "true" : "false")}, {propertyInfo})";
50-
endpoint.EmitterContext.RequiresPropertyAsParameterInfo = IsProperty && IsEndpointParameterMetadataProvider;
50+
endpoint.EmitterContext.RequiresPropertyAsParameterInfo = IsProperty;
5151
ProcessEndpointParameterSource(endpoint, property, attributeBuilder.ToImmutable(), wellKnownTypes);
5252
}
5353

0 commit comments

Comments
 (0)