Add regression tests for generic AddJsonFile named options (#39) - #41
Closed
gerritgoetzen wants to merge 2 commits into
Closed
Add regression tests for generic AddJsonFile named options (#39)#41gerritgoetzen wants to merge 2 commits into
gerritgoetzen wants to merge 2 commits into
Conversation
…ddJsonFile overloads
The generic AddJsonFile overloads must apply the user configuration callback to the named options instance that the provider resolves via IOptionsMonitor.Get(optionsName). Before the fix the callback was registered against Options.DefaultName, so it never reached the provider's own options (adams85#39). Each of the three affected overloads is pinned independently: the tests fail against the pre-fix source and pass with the fix (adams85#40). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
|
Thanks for the tests! Closing as merged into #40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression test for #39 (depends on #40)
Adds a regression test pinning the bug from #39: the generic
AddJsonFile<TProvider>/AddJsonFile<TProvider, TOptions>overloads registered the userconfigurecallback againstOptions.DefaultNameinstead of the named options instance the provider resolves viaIOptionsMonitor.Get(optionsName), so user configuration never reached the provider's own options.What this contains
This branch is stacked on #40 (the fix), which isn't on
masteryet, so the diff currently shows two commits:d866c08— the fix from Fix incorrect registration of user configuration actions in generic AddJsonFile overloads #40 (base only; not my work)Once #40 merges into
master, this PR reduces to just the test commit. If you'd prefer, the test can instead be folded directly into #40.Coverage
Three
[Fact]s inSettingsTest.cs, one per affected overload:AddJsonFile<TProvider>(configure:, optionsName:)AddJsonFile<TProvider, TOptions>(configure:, optionsName:)AddJsonFile<TProvider, TOptions>(bindOptions, configure:, optionsName:)Each builds the service provider, resolves
IOptionsMonitor<FileLoggerOptions>.Get(optionsName), and asserts the user-configured sentinel (BasePath) lands on the named instance and not onOptions.DefaultName.BasePathis the sentinel rather thanRootPathbecauseRootPath's setter eagerly constructs aPhysicalFileAppenderthat validates the directory on disk.Verification (net10.0)
Assert.Equalmismatches (Expected "some-sentinel-base-path", Actual null).Closes #39 once #40 is in.