Support reload in ChainedConfigurationSource#125122
Conversation
Add support for reloading configuration to `ChainedConfigurationSource`. Fixes dotnet#58683.
|
Thank you for the PR. I think you should also test the case where the chained configuration is not an |
Add a test for when the configuration being reloaded isn't an `IConfigurationRoot`.
src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Outdated
Show resolved
Hide resolved
Fix test method name casing typo. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Outdated
Show resolved
Hide resolved
🤖 Code Review — PR #125122Review co-authored by @tarekgh and GitHub Copilot Holistic AssessmentMotivation: The PR addresses a real bug (#58683): calling Approach: The fix changes Summary: Detailed Findings❌ Construction-time side effect — Inner root gets reloaded during outer construction
foreach (IConfigurationProvider p in providers)
{
p.Load(); // triggers Reload() on the inner root!
}With this change, when the outer
The same issue applies to Recommendation: Add a private bool _loaded;
public void Load()
{
if (_loaded)
{
(_config as IConfigurationRoot)?.Reload();
}
_loaded = true;
}
|
|
FYI the original code was written by Copilot (martincostello#6) which explicitly calls out the reload behaviour here:
I don't fully trust Copilot to review itself when it gives differing opinions of its own work, so if a human can tell me which which Copilot is correct, I'll implement any required changes. |
|
Hi @martincostello, In my opinion, I don’t see any conflict in the Copilot feedback. Both the author Copilot and the commenter Copilot are pointing to the same issue: duplicate notifications. This issue wasn’t introduced by this PR, but the changes here make it more noticeable. I haven’t spent much time digging deeper, but it seems there’s a way to fix both the construction and double-fire issue in the code path you’re modifying. Instead of calling private bool _loaded;
public void Load()
{
if (!_loaded)
{
_loaded = true;
return;
}
if (_config is IConfigurationRoot root)
{
foreach (IConfigurationProvider provider in root.Providers)
{
provider.Load();
}
}
}Anyway, having some test for the concerning scenario will be good to have to add confidence to what we are doing. Thanks! |
|
My point was more around "if you thought that, why did you do it that way in the first place?" with regards to Copilot. I'll make the changes tomorrow. |
That depends on what you asked Copilot to do 😄 Copilot mentioned that “This is consistent with how automatic (file-watcher) reloads already propagate through chains and is not a data-correctness issue.” If you explicitly instruct it to fix the behavior, it would likely attempt to address it.
Thanks for your help fixing the issue! |
|
@martincostello The Coding Agent and the Code review agent are optimized for different jobs, so it’s normal for the review agent to flag things the coding agent didn’t. We've also been iterating in this repo on specializing the review capabilities. They can also use different models, context windows, etc. All around we're seeing favorable results with iterating between the two agents. |
|
Sure, but from a user perspective it looks like a single AI is giving me (seemingly) contradictory perspectives, which a maintainer may or may not agree is needed. Rather than go on a wild goose chase potentially wasting time on unnecessary changes, I'd rather just action feedback direct from a human (like Tarek has now given me). |
Re-use `CountingValueConfigurationProvider` and remove `RandomValueConfigurationProvider`.
src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Show resolved
Hide resolved
No longer needed with `Guid` removal.
src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Outdated
Show resolved
Hide resolved
It isn't random anymore.
Rename variable for clarity and add comment.
src/libraries/Microsoft.Extensions.Configuration/tests/ChainedConfigurationProviderTests.cs
Show resolved
Hide resolved
Add support for reloading configuration to `ChainedConfigurationSource`. Fixes #58683. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
Add support for reloading configuration to
ChainedConfigurationSource.Fixes #58683.