Fixes #macOS-tests-failing. Deep-clone hard-coded config cache values at initialization to prevent mutation corruption#4847
Merged
tig merged 2 commits intov2_developfrom Mar 23, 2026
Conversation
… prevent mutation corruption When ConfigurationManager.Initialize() builds _hardCodedConfigPropertyCache, it calls UpdateToCurrentValue() which stored the SAME reference to mutable objects like Application.DefaultKeyBindings (a Dictionary). In-place mutations to that dictionary (e.g., Application.DefaultKeyBindings![Command.Quit] = ...) then silently corrupted the cached "hard-coded default". On macOS, test ordering caused Load_And_Apply_HardCoded to run before any Disable(true) call that would break the shared reference, making the cache contain Ctrl+X instead of Esc, failing the assertion. Fix: deep-clone each PropertyValue immediately after UpdateToCurrentValue() in Initialize(), ensuring the cache stores independent copies of reference-type values. Co-authored-by: tig <585482+tig@users.noreply.github.com> Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/a68bc920-92d0-4813-8c67-03a18439a0ea
Copilot
AI
changed the title
[WIP] Fix macOS tests failing due to incorrect global keybindings
Fixes #macOS-tests-failing. Deep-clone hard-coded config cache values at initialization to prevent mutation corruption
Mar 23, 2026
This was referenced May 1, 2026
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.
ConfigurationManager._hardCodedConfigPropertyCachestored a shared reference toApplication.DefaultKeyBindings(aDictionary<Command, PlatformKeyBinding>). In-place mutations likeApplication.DefaultKeyBindings![Command.Quit] = Bind.All(Key.X.WithCtrl)silently corrupted the "hard-coded default" cache, since both pointed to the same object. On macOS, test ordering causedLoad_And_Apply_HardCodedto run before anyDisable(true)→Apply()call that would have created a new dictionary and broken the shared reference — producingActual: Ctrl+XwhereExpected: Esc.Proposed Changes/Todos
ConfigurationManager.Initialize(), deep-clone eachPropertyValueimmediately afterUpdateToCurrentValue(), before marking the cache entryImmutable = true:This ensures the cache stores independent copies of reference-type values so in-place mutations to static properties (e.g.
Application.DefaultKeyBindings![cmd] = ...) cannot corrupt the hard-coded defaults regardless of test execution order.Pull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.