Skip to content

The options subsystem needs linker attributes to preserve constructors on options types #40236

Description

@davidfowl

Description

Looking into what it means to takes to make ASP.NET Core more linkable once we get this (#40227) and (dotnet/aspnetcore#24458), options is the next big hurdle to cross. The issue is the very similar to DI in that the option system creates instances but the linker doesn't understand that and removes constructors from the poco objects.

public class MyOptions
{
    public int Value { get; set; };
}
var services = new ServiceCollection();
services.AddOptions();
services.Configure<MyOptions>(o =>
{
     o.Value = 100;
});
var service= services.GetService<IOptions<MyOptions>>();
var value = service.Value;

Linking this should preserve MyOptions constructors.

This matters for:

  • IOptions<T>
  • IOptionsMonitor<T>
  • IOptionsSnapshot<T>

cc @eerhardt

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions