Skip to content
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

fix: Correct configuration loading for unnamed sections (backport #2228) #2229

Merged
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<StackPanel Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock>
<Run Text="Providers: "/>
<Run Text="{Binding ProviderCount}" AutomationProperties.AutomationId="LoginProviderCountText" />
</TextBlock>
<Button Content="Login"
Click="{x:Bind ViewModel.Login}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

internal record class OidcAuthenticationLoginViewModel(INavigator Navigator, IAuthenticationService Authentication, IAuthenticationRouteInfo RouteInfo)
{
public int ProviderCount => Authentication.Providers.Length;
public async void Login()
{
var authenticated = await Authentication.LoginAsync(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace TestHarness.UITest;

public class Given_Oidc : NavigationTestBase
{
// [Test]
public async Task When_Oidc_Auth()
{
InitTestSection(TestSections.Authentication_Oidc);

App.WaitThenTap("ShowAppButton");

App.WaitElement("LoginNavigationBar");
var text = App.GetText("LoginProviderCountText");
Assert.AreEqual("4", text);
}

}
Loading