Skip to content

Commit

Permalink
fix: Correct configuration loading for unnamed sections
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Apr 2, 2024
1 parent e3d7b46 commit 9771c2c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Uno.Extensions.Configuration/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Immutable;
using System.ComponentModel;

namespace Uno.Extensions.Configuration;
namespace Uno.Extensions.Configuration;

/// <summary>
/// Extension methods for <see cref="IServiceCollection"/>.
Expand All @@ -27,13 +24,14 @@ public static IServiceCollection ConfigureAsWritable<T>(
string? name = "")
where T : class, new()
{
var sectionName = name != typeof(T).Name ? name : default;
return services
// Note - we've replaced the Configure method call with the three calls subsequent three calls so that
// we can use a local copy of ConfigurationBinder that handles ImmutableList
//.Configure<T>(section)
.AddOptions()
.AddSingleton<IOptionsChangeTokenSource<T>>(new ConfigurationChangeTokenSource<T>(name ?? Options.DefaultName, section))
.AddSingleton<IConfigureOptions<T>>(new Uno.Extensions.Configuration.Internal.NamedConfigureFromConfigurationOptions<T>(name ?? Options.DefaultName, section, _ => { }))
.AddSingleton<IOptionsChangeTokenSource<T>>(new ConfigurationChangeTokenSource<T>(sectionName ?? Options.DefaultName, section))
.AddSingleton<IConfigureOptions<T>>(new Uno.Extensions.Configuration.Internal.NamedConfigureFromConfigurationOptions<T>(sectionName ?? Options.DefaultName, section, _ => { }))

.AddTransient<IWritableOptions<T>>(provider =>
{
Expand Down

0 comments on commit 9771c2c

Please sign in to comment.