Skip to content

Examples given don't work with .netstandard2.0 #24765

@schmik

Description

@schmik

As far as I can tell, the given example for "Parameterless" won't work with a class lib targeting .Net Standard 2.0 -- which should be a viable target, as Microsoft.Extensions.DependencyInjection itself targets netstandard2.0? IServiceCollection has no method .AddOptions<T>

using Microsoft.Extensions.DependencyInjection;

namespace ExampleLibrary.Extensions.DependencyInjection
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection AddMyLibraryService(
            this IServiceCollection services)
        {
            services.AddOptions<LibraryOptions>()
                .Configure(options =>
                {
                    // Specify default option values
                });

            // Register lib services here...
            // services.AddScoped<ILibraryService, DefaultLibraryService>();

            return services;
        }
    }
}

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions