-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Allow Use of IConfigureOptions Consistently Everywhere #39251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
They compose, so it can be used. Are you saying you want overloads that don’t require the action overload? |
Yes, at the moment it's pretty strange to be forced to pass an empty delegate: services.AddStackExchangeRedisCache(x => {});
services.AddHsts(x => {}); It would be a good idea to review all such API's to see if there are others I missed. |
Thanks for contacting us. |
Today we have two common patterns for configuring options when adding built-in ASP.NET Core features.
We should decide on the preferred approach and update any areas that are currently forcing an aspnetcore/src/Security/CookiePolicy/src/CookiePolicyServiceCollectionExtensions.cs Line 19 in c85baf8
Bringing this up with API review so we can agree on the pattern we want to use before updating places like |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API review:
+ IServiceCollection AddStackExchangeRedisCache(this IServiceCollection services)
IServiceCollection AddStackExchangeRedisCache(this IServiceCollection services, Action<RedisCacheOptions> setupAction)
public static IServerSideBlazorBuilder AddMyFeature(this IServiceCollection services);
public static IServerSideBlazorBuilder AddMyFeature(this IServiceCollection services, Action<MyFeatureOption> configureOptions) ;
Separately we'll approve the changes proposed in this issue: + IServiceCollection AddStackExchangeRedisCache(this IServiceCollection services)
+ IServiceCollection AddHsts(this IServiceCollection services) |
We decided on the PR (#40689) that the add Options can be configured separately without the callback, but this is uncommon. We're worried that introducing this overload will create confusion only to save seven characters of code in the uncommon case. + IServiceCollection AddStackExchangeRedisCache(this IServiceCollection services) [1]: This brings up questions about whether |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API Review Notes:
We are worried that adding the non-options-configuring |
Is your feature request related to a problem? Please describe.
IConfigureOptions<T>
allows you to move your configuration code to a separate class. However, it cannot be used with certain API's which require us to pass anAction<T>
:This is not an exhaustive list, there may be others.
Describe the solution you'd like
All API's in ASP.NET Core should be consistent and allow us to configure them using
IConfigureOptions<T>
. The following overloads should be added:The text was updated successfully, but these errors were encountered: