Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove the new() constraint from options helpers.
  • Loading branch information
CodeBlanch committed Mar 7, 2024
commit 9b85a428f70610a02c99a6ce62b6c24a18a2e476
4 changes: 2 additions & 2 deletions src/Shared/Options/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static bool TryGetValue<T>(
public static IServiceCollection RegisterOptionsFactory<T>(
this IServiceCollection services,
Func<IConfiguration, T> optionsFactoryFunc)
where T : class, new()
where T : class
{
Debug.Assert(services != null, "services was null");
Debug.Assert(optionsFactoryFunc != null, "optionsFactoryFunc was null");
Expand All @@ -150,7 +150,7 @@ public static IServiceCollection RegisterOptionsFactory<T>(
public static IServiceCollection RegisterOptionsFactory<T>(
this IServiceCollection services,
Func<IServiceProvider, IConfiguration, string, T> optionsFactoryFunc)
where T : class, new()
where T : class
{
Debug.Assert(services != null, "services was null");
Debug.Assert(optionsFactoryFunc != null, "optionsFactoryFunc was null");
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Options/DelegatingOptionsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Options
/// <typeparam name="TOptions">The type of options being requested.</typeparam>
internal sealed class DelegatingOptionsFactory<TOptions> :
IOptionsFactory<TOptions>
where TOptions : class, new()
where TOptions : class
{
private readonly Func<IConfiguration, string, TOptions> optionsFactoryFunc;
private readonly IConfiguration configuration;
Expand Down