madskristensen / Tweakster

A Visual Studio extension
Apache License 2.0
240 stars 23 forks source link

Implement #60. Adds U2DCheckVerbosity Setting #61

Closed StevenBonePgh closed 3 years ago

StevenBonePgh commented 3 years ago

Adds capability for a property defined in BaseOptionModel to be attributed to override the default collection and data type where the setting is stored in the Visual Studio SettingsStore. This functionality was then used to implement getting and setting the General\U2DCheckVerbosity setting.

StevenBonePgh commented 3 years ago

Figured I'd give implementing this one a shot as a learning exercise.

Once I determined that the ShellSettingsManager SettingsStore was merely a proxy to the Visual Studio registry hive, the real trick was figuring out how to expose this in the Tweaks User Interface. I thought the way the Options menu was generated was pretty elegant, and it made sense to put the setting there, so that is where I looked to. Unlike the other Tweaks, where the settings feed into other extensibility points, I just needed to be able to directly read/write a setting from a different SettingsStore collection and using a specific datatype/serialization method rather than the default storage of the setting into a binary serialized base64 string.

This was achieved by the addition of two attributes that can now be applied to a property to indicate where and how to store and retrieve the setting, and a change to the BaseOptionModel<T> LoadAsync and SaveAsync to respect these attributes. I only implemented a Boolean datastore type, but that mechanism can be easily extended for other data types by adding support in load/save. This gives a simple way of adding new Tweaks that only need to change some of the more 'hidden' settings of Visual Studio, like this one does.

One warning - while this functions as expected when installed as a vsix - changing the setting will immediately impact the build system output based on the current value of the U2DCheckVerbosity setting, when debugging via the experimental instance the setting is properly loaded and saved but has no impact on the build output. Any ideas why this is the case?

madskristensen commented 3 years ago

Awesome. Thank you!!