Add dark/light theme DSC resource - #20472
Open
Gijsreyn wants to merge 2 commits into
Open
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This comment has been minimized.
This comment has been minimized.
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.
Summary of the Pull Request
This pull request teaches Windows Terminal to speak Microsoft DSC. It adds a small new console tool (
TerminalDsc.exe) that ships inside the Terminal package and serves DSC resources. The first resource is:Microsoft.WindowsTerminal/Settings, managing three global settings:theme,copyOnSelect, andinitialCols. With this in place, you can put your Terminal theme in a DSC configuration document and apply it withdsc.exe.Because Microsoft DSC uses a discovery extension (appx), the resource manifest file can be found. That means that this needs to be shipped in the MSIX.
References and Relevant Issues
Detailed Description of the Pull Request / Additional comments
The PR initially was a little smaller, but the goal wasn't just "make the theme settable." It was to build a little home where more resources can move in later without remodeling. The pieces that are put under
src/cascadia/TerminalDsc/are stepped through step by step:main.cpp. It creates aResourceRegistryand registers every resource this executable serves, with oneregistry.Add(...)call per resource.IGettable,ISettable,ITestable,IDeletable,IExportable, all declared inResource/DscResource.h). A resource says what it can do simply by deriving from them. The repo builds without RTTI, so this uses templates instead ofdynamic_cast.CommandBuilderparses the command line (TerminalDsc <get|set|test|delete|export|schema|manifest> [--resource <type>] [--input <json>]), finds the right resource in the registry, and hands the work toResourceExecutor. That one speaks the protocol: desired state comes in through--input, actual state goes out as one compact JSON line, andLoggerwrites diagnostics as{"info": "..."}or{"error": "..."}lines on stderr, which is how DSC likes them.ManifestGeneratorbuilds the DSC manifest from that same registry, so the manifest can never quietly drift from what the code actually does.TerminalDsc.exe manifest --saveregenerates the checked-in file, and a unit test fails if the two ever disagree.Resources/Settings/. It reusesCascadiaSettings::LoadAll()andWriteSettingsToDisk(), so a DSCsetgoes through the exact same code path as the Settings UI, including settings hot-reload in running windows. Each managed setting is one row in a small property table (reader, writer, schema fragment). Nothing inResource/knows about Terminal settingsAdding the next resource (color schemes? profiles? 👀) works like this:
Resources/<Name>/folder and implementIDscResourceplus the capability interfaces you want.main.cpp.TerminalDsc.exe manifest --save.The framework picks it up from there.
Validation Steps Performed
PR Checklist