Repository navigation
Ignore Dispose on the process-wide Instance [patch] - #202
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
Disposing what CredentialCache.Instance returned (easy to do with `using var cache = CredentialCache.Instance;`, since the same type is disposable when you new it) left the singleton disposed for the rest of the process: Instance kept returning it, every method threw ObjectDisposedException, and ConfigureStore refused to replace it. The cache Instance builds now ignores Dispose, so it stays usable for every other component. ResetSingletonForTesting still disposes it, and a cache created with the constructor disposes as before. The Instance and Dispose docs say so. Fixes #201 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5wqHMdBMn6Wino1eH
|
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.



Fixes #201
What changed
This takes option 1 from the triage: the singleton ignores
Dispose()from outside.Instancebuilds is flagged as the singleton, and itsDispose()does nothing. Writingusing var cache = CredentialCache.Instance;no longer breaks credential access for the rest of the process. It keeps its cache, andConfigureStorestill refuses to replace it, so "one cache per process" stays true.ResetSingletonForTestingstill disposes the old singleton, through a privateDisposeCore.new CredentialCache(store)disposes as before.InstanceandDisposeXML docs now say what disposing the singleton does.Tests
DisposingTheSingletonLeavesItUsableis the repro from the issue. After ausingonInstance,TryGetreturns both the cached credential and one that exists only in the store,AddOrReplaceworks, andConfigureStorestill throws. It fails without the fix.ResetSingletonForTestingStillDisposesTheOldSingletonandDisposingAnOwnedCacheStillDisposesItguard the disposal paths that are meant to keep working.The full suite passes: 83 passed, 5 skipped (platform-specific), 0 failed.
The fix won't reach NuGet until #200 (pack failing package validation) is resolved. That is separate from this change.
Generated by Claude Code