Skip to content

Conversation

@twsouthwick
Copy link
Member

This enables switching from ConfigurationManager.[Appsettings|ConnectionStrings] to AppConfiguration.[GetSetting|GetConnectionString] so that there is a static configuration source on all platforms while adapting to more modern practices of dependency injection for configuration.

This enables switching from `ConfigurationManager.[Appsettings|ConnectionStrings]` to `AppConfiguration.[GetSetting|GetConnectionString]` so that there is a static configuration source on all platforms while adapting to more modern practices of dependency injection for configuration.
/// </summary>
/// <param name="key">The key of the settings.</param>
/// <returns>The setting if available, otherwise <c>null</c>.</returns>
public static string? GetSetting(string key) => Configuration?.GetSetting(key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make a remark on the requirements of the string parameter? Pretty sure there are keys that are not supported so I wonder if we should either do some sanitization or document we assume it is a valid key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of any IConfiguration[index] constraints. If there are, we can document it but it's nothing that doesn't already exist there as this is just a pass through since we don't want to add the dependency to IConfiguration for consumers of the Microsoft.AspNetCore.SystemWebAdapters package

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments but looks good otherwise

@twsouthwick twsouthwick enabled auto-merge (squash) October 16, 2025 01:05
@twsouthwick twsouthwick disabled auto-merge October 16, 2025 01:05
@twsouthwick twsouthwick requested a review from Copilot October 16, 2025 01:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a static AppConfiguration API and supporting infrastructure to enable migration from ConfigurationManager to IConfiguration across Core and Framework targets. Introduces an internal IConfigurationAccessor service and registers it during system web adapter setup; provides samples and end-to-end tests validating behavior; adjusts host startup to ensure services are available before returning.

  • Introduces AppConfiguration static helper and IConfigurationAccessor interface.
  • Registers configuration accessor in Core and Framework paths and adds samples (Core, Framework, AppHost) plus E2E tests.
  • Modifies host builder to wait for application start before returning.

Reviewed Changes

Copilot reviewed 32 out of 35 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/Microsoft.AspNetCore.SystemWebAdapters.E2E.Tests/Microsoft.AspNetCore.SystemWebAdapters.E2E.Tests.csproj Adds project reference to new AppConfig sample for E2E testing.
test/Microsoft.AspNetCore.SystemWebAdapters.E2E.Tests/AppConfigTests.cs New tests validating static configuration accessor across Core and Framework apps.
src/Services/ConfigurationAccessorExtensions.cs Adds internal extension to register IConfigurationAccessor implementation.
src/Microsoft.AspNetCore.SystemWebAdapters/Microsoft.AspNetCore.SystemWebAdapters.csproj Includes new source files for AppConfiguration and IConfigurationAccessor; adds InternalsVisibleTo for FrameworkServices.
src/Microsoft.AspNetCore.SystemWebAdapters/AppConfiguration.cs Adds static AppConfiguration API with XML docs.
src/Microsoft.AspNetCore.SystemWebAdapters/Adapters/IConfigurationAccessor.cs Defines internal IConfigurationAccessor interface.
src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/SystemWebAdapterConfiguration.cs Registers configuration accessor during adapter setup.
src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/Hosting/HttpApplicationHostBuilder.cs Waits for application start using TaskCompletionSource after queuing host run.
src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/Hosting/HttpApplicationHost.cs Registers configuration accessor in host creation.
src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/Hosting/ConfigurationManagerConfigExtensions.cs Refactors enumeration of connection strings and app settings to strongly typed loops.
src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SystemWebAdaptersExtensions.cs Registers configuration accessor in Core services setup.
samples/AppConfig/... (multiple) Adds Core and Framework sample apps plus AppHost to demonstrate configuration migration.
Microsoft.AspNetCore.SystemWebAdapters.sln Adds solution folder and projects for new AppConfig samples.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

twsouthwick and others added 5 commits October 15, 2025 18:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tionAccessor.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@twsouthwick twsouthwick enabled auto-merge (squash) October 16, 2025 01:15
@twsouthwick twsouthwick disabled auto-merge October 16, 2025 01:20
@twsouthwick twsouthwick enabled auto-merge (squash) October 16, 2025 01:22
@twsouthwick twsouthwick merged commit ca4a9a7 into main Oct 16, 2025
5 checks passed
@twsouthwick twsouthwick deleted the config branch October 16, 2025 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants