Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Configure(IWebHostBuilder builder)
});

[UnconditionalSuppressMessageAttribute("Trimming", "IL2026", Justification = "Configuration object's public properties are preserved.")]
static void ConfigureOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(IServiceCollection services, IConfigurationSection section)
static void ConfigureOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(IServiceCollection services, IConfigurationSection section)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream annotation (in Configure<TOptions>) now specifies DynamicallyAccessedMemberTypes.All, so we have to broaden the annotation here to match.

Copy link
Member

@halter73 halter73 Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbomer @agocke @vitek-karas - any thoughts on what could have fixed this between 8.0.100-preview.6.23305.3 and 8.0.100-preview.7.23321.23? We must have had a bug here in the analyzer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the configuration binder source generator? I seem to see something like the Configure call below to be handled by the source generated at least in some cases. So it's possible that it's effectively started to call a different overload than before? Just guessing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj]
##[error]src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: (NETCORE_ENGINEERING_TELEMETRY=Build) 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

The IL2091 error specifically references the call to Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration), so I don't think the call is getting intercepted by the source generator.

where T : class
{
services.Configure<T>(section);
Expand Down