Skip to content

[DOC] dependency injection custom provider examples do not compile #349

@kylejuliandev

Description

@kylejuliandev

Change in the documentation

The two examples for registering a custom provider (and adding a domain-scoped provider) do not compile as they are found. The AddOpenFeature() service collection extension method returns a IServiceCollection, not a OpenFeatureBuilder.

see

services.AddOpenFeature()
        .AddProvider(provider =>
        {
            // Resolve services or configurations as needed
            var configuration = provider.GetRequiredService<IConfiguration>();
            var flags = new Dictionary<string, Flag>
            {
                { "feature-key", new Flag<bool>(configuration.GetValue<bool>("FeatureFlags:Key")) }
            };

            // Register a custom provider, such as InMemoryProvider
            return new InMemoryProvider(flags);
        });

and

services.AddOpenFeature()
        .AddProvider("my-domain", (provider, domain) =>
        {
            // Resolve services or configurations as needed for the domain
            var flags = new Dictionary<string, Flag>
            {
                { $"{domain}-feature-key", new Flag<bool>(true) }
            };

            // Register a domain-scoped custom provider such as InMemoryProvider
            return new InMemoryProvider(flags);
        });

Should be a relatively quick fix to shift the code into a delegate within the AddOpenFeature(builder => {}) extension method

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: docsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions