Skip to content

[API Proposal]: [ReflectionLessBoundableConfiguration] #108111

Open
@rmannibucau

Description

@rmannibucau

Background and motivation

Supporting AOT for the binder API is done using a source generator but dotnet compiler has only 1 (2) passes so it makes it impossible to use it within another generator forcing the other generator to reimplement pretty much the same logic.

It would be neat to have a middle-ground solution.

API Proposal

namespace Whatever;

[ReflectionLessBoundableConfiguration]
public class ConfigClass
{
//...
}

side note: i'm not fan of the name but guess it is sufficient to get started, what is important is to have a marker attribute

Then it would generate a ConfigClass.Binder class which would be usable as binder (ConfigClass.Binder.Bind(configuration, instance))

API Usage

// Fancy the value
var c = new MyFancyCollection<int>();
ConfigClass.Binder.Bind(new ConfigurationBuilder()...., c)

Alternative Designs

Enable to call the generator from another generator (but it is fishy as design and will lead to a spaghetti solution)

Risks

no real risk there (except if you already have a binder nested class but if so you don't use this API which is new so risk is really 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions