terminal/src/cascadia/TerminalSettingsModel
Leonard Hecker 168d28b036
Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184)
This commit reduces the code surface that interacts with raw JSON data,
reducing code complexity and improving maintainability.
Files that needed to be changed drastically were additionally
cleaned up to remove any code cruft that has accrued over time.

In order to facility this the following changes were made:
* Move JSON handling from `CascadiaSettings` into `SettingsLoader`
  This allows us to use STL containers for data model instances.
  For instance profiles are now added to a hashmap for O(1) lookup.
* JSON parsing within `SettingsLoader` doesn't differentiate between user,
  inbox and fragment JSON data, reducing code complexity and size.
  It also centralizes common concerns, like profile deduplication and
  ensuring that all profiles are assigned a GUID.
* Direct JSON modification, like the insertion of dynamic profiles into
  settings.json were removed. This vastly reduces code complexity,
  but unfortunately removes support for comments in JSON on first start.
* `ColorScheme`s cannot be layered. As such its `LayerJson` API was replaced
  with `FromJson`, allowing us to remove JSON-based color scheme validation.
* `Profile`s used to test their wish to layer using `ShouldBeLayered`, which
  was replaced with a GUID-based hashmap lookup on previously parsed profiles.

Further changes were made as improvements upon the previous changes:
* Compact the JSON files embedded binary, saving 28kB
* Prevent double-initialization of the color table in `ColorScheme`
* Making `til::color` getters `constexpr`, allow better optimizations

The result is a reduction of:
* 48kB binary size for the Settings.Model.dll
* 5-10% startup duration
* 26% code for the `CascadiaSettings` class
* 1% overall code in this project

Furthermore this results in the following breaking changes:
* The long deprecated "globals" settings object will not be detected and no
  warning will be created during load.
* The initial creation of a new settings.json will not produce helpful comments.

Both cases are caused by the removal of manual JSON handling and the
move to representing the settings file with model objects instead

## PR Checklist
* [x] Closes #5276
* [x] Closes #7421
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

* Out-of-box-experience is identical to before ✔️
  (Except for the settings.json file lacking comments.)
* Existing user settings load correctly ✔️
* New WSL instances are added to user settings ✔️
* New fragments are added to user settings ✔️
* All profiles are assigned GUIDs ✔️
2021-09-22 16:27:31 +00:00
..
dll Update to MUX 2.7 (#11240) 2021-09-20 22:08:55 +00:00
Resources/en-US Replace TrayIcon with NotificationIcon (#11219) 2021-09-14 16:12:40 +00:00
ActionAndArgs.cpp Add an openSystemMenu keybinding (#11086) 2021-09-10 18:25:43 +00:00
ActionAndArgs.h Add action to run multiple actions. (#11045) 2021-08-31 19:35:51 +00:00
ActionArgs.cpp Add the ability to split a pane and put the new pane first. (#11145) 2021-09-15 20:14:57 +00:00
ActionArgs.h Add the ability to split a pane and put the new pane first. (#11145) 2021-09-15 20:14:57 +00:00
ActionArgs.idl Add the ability to split a pane and put the new pane first. (#11145) 2021-09-15 20:14:57 +00:00
ActionMap.cpp Make ActionMap compatible with ScanCode-only KeyChords (#10945) 2021-08-20 00:21:33 +00:00
ActionMap.h Make ActionMap compatible with ScanCode-only KeyChords (#10945) 2021-08-20 00:21:33 +00:00
ActionMap.idl Adding/fixing Alt+Space handling (#10799) 2021-08-10 19:53:07 +00:00
ActionMapSerialization.cpp Use WinRT VirtualKeyModifiers instead of a custom enum (#10603) 2021-07-12 21:24:26 +00:00
AllShortcutActions.h Add an openSystemMenu keybinding (#11086) 2021-09-10 18:25:43 +00:00
AppearanceConfig.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
AppearanceConfig.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
AppearanceConfig.idl Add support for a profile to specify an "unfocused" appearance (#8392) 2021-04-08 22:46:16 +00:00
ApplicationState.cpp Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
ApplicationState.h Teach info bars to be dismissed permanently (#11139) 2021-09-10 17:16:41 +00:00
ApplicationState.idl Teach info bars to be dismissed permanently (#11139) 2021-09-10 17:16:41 +00:00
AzureCloudShellGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
AzureCloudShellGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
BaseVisualStudioGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
BaseVisualStudioGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
CascadiaSettings.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
CascadiaSettings.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
CascadiaSettings.idl Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
CascadiaSettingsSerialization.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
ColorScheme.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
ColorScheme.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
ColorScheme.idl Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
Command.cpp Bugfix: serialize iterable commands (#10373) 2021-06-10 18:25:27 +00:00
Command.h Introduce serialization for actions (#9926) 2021-05-20 18:44:04 +00:00
Command.idl Introduce ActionMap to Terminal Settings Model (#9621) 2021-05-04 21:50:13 -07:00
defaults-universal.json Introduce vk() and sc() key chord specifiers (#10666) 2021-07-20 22:34:51 +00:00
defaults.json Bind resetFontSize to numpad_0 (#11243) 2021-09-16 07:14:15 +00:00
DefaultTerminal.cpp Prevent crashes in Settings UI launch on OS versions before package management extensions (#10238) 2021-05-27 17:53:00 +00:00
DefaultTerminal.h Prevent crashes in Settings UI launch on OS versions before package management extensions (#10238) 2021-05-27 17:53:00 +00:00
DefaultTerminal.idl Implement UI for choosing default terminal inside Settings page (#9907) 2021-04-28 10:43:30 +00:00
DynamicProfileUtils.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
DynamicProfileUtils.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
EnumMappings.cpp Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
EnumMappings.h Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
EnumMappings.idl Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
FileUtils.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
FileUtils.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
FontConfig.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
FontConfig.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
FontConfig.idl Allow users to set font features and font axes (#10525) 2021-07-22 23:15:44 +00:00
GlobalAppSettings.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
GlobalAppSettings.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
GlobalAppSettings.idl Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
HashUtils.h Introduce ActionMap to Terminal Settings Model (#9621) 2021-05-04 21:50:13 -07:00
IAppearanceConfig.idl Enable Vintage Opacity (#11180) 2021-09-20 17:08:13 +00:00
IconPathConverter.cpp Revert "Add the profile, page icons to the page headers (#10046)" (#10124) 2021-05-18 17:35:50 -05:00
IconPathConverter.h Move IconSourceConverter from TerminalApp to TSM 2020-12-11 13:17:22 -08:00
IconPathConverter.idl Move IconSourceConverter from TerminalApp to TSM 2020-12-11 13:17:22 -08:00
IDynamicProfileGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
IInheritable.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
IInheritable.idl.h Introduce setting override tracking and update SettingContainer (#9079) 2021-02-19 23:50:52 +00:00
init.cpp Hook up the WIL fallback error tracer in Terminal (#7864) 2020-10-09 22:20:12 +00:00
JsonUtils.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
KeyChordSerialization.cpp Fix: Multimedia Key Hotkey Support (#10801) 2021-07-27 17:11:51 +00:00
KeyChordSerialization.h Introduce ActionMap to Terminal Settings Model (#9621) 2021-05-04 21:50:13 -07:00
KeyChordSerialization.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
LegacyProfileGeneratorNamespaces.h From orbit, nuke the Telnet connection and all supporting infra. (#7840) 2020-10-09 18:59:58 +00:00
Microsoft.Terminal.Settings.ModelLib.vcxproj Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
Microsoft.Terminal.Settings.ModelLib.vcxproj.filters Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
packages.config Add profile generators for Visual Studio (#7774) 2021-09-15 17:20:06 -05:00
pch.cpp Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
pch.h Fix crash when unpackaged due to PrimaryLanguageOverride (#10434) 2021-06-16 21:08:14 +00:00
PowershellCoreProfileGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
PowershellCoreProfileGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
Profile.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
Profile.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
Profile.idl Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
SettingsTypes.h Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
TerminalSettings.cpp Enable Vintage Opacity (#11180) 2021-09-20 17:08:13 +00:00
TerminalSettings.h Enable Vintage Opacity (#11180) 2021-09-20 17:08:13 +00:00
TerminalSettings.idl Persist window layout on window close (#10972) 2021-09-08 22:44:53 +00:00
TerminalSettingsSerializationHelpers.h Enable Vintage Opacity (#11180) 2021-09-20 17:08:13 +00:00
TerminalWarnings.h Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
TerminalWarnings.idl Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
userDefaults.json Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsDevCmdGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsDevCmdGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsDevShellGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsDevShellGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsSetupConfiguration.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
VsSetupConfiguration.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
WslDistroGenerator.cpp Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00
WslDistroGenerator.h Reduce usage of Json::Value throughout Terminal.Settings.Model (#11184) 2021-09-22 16:27:31 +00:00