Renaming properties to C# styling to fix warnings (#5166)

* Renaming properties

* Update PowerLauncherProperties.cs

trying to kick CI

* PowerLauncher is way for naming.

Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
Clint Rutkas 2020-07-23 11:01:49 -07:00 committed by GitHub
parent f25d2b3a86
commit 2bd2ec7a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 107 additions and 98 deletions

View File

@ -1,45 +1,60 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public class PowerLauncherProperties public class PowerLauncherProperties
{ {
public string search_result_preference { get; set; } [JsonPropertyName("search_result_preference")]
public string SearchResultPreference { get; set; }
public string search_type_preference { get; set; } [JsonPropertyName("search_type_preference")]
public string SearchTypePreference { get; set; }
public int maximum_number_of_results { get; set; } [JsonPropertyName("maximum_number_of_results")]
public int MaximumNumberOfResults { get; set; }
public HotkeySettings open_powerlauncher { get; set; } [JsonPropertyName("open_powerlauncher")]
public HotkeySettings OpenPowerLauncher { get; set; }
public HotkeySettings open_file_location { get; set; } [JsonPropertyName("open_file_location")]
public HotkeySettings OpenFileLocation { get; set; }
public HotkeySettings copy_path_location { get; set; } [JsonPropertyName("copy_path_location")]
public HotkeySettings CopyPathLocation { get; set; }
public HotkeySettings open_console { get; set; } [JsonPropertyName("open_console")]
public HotkeySettings OpenConsole { get; set; }
public bool override_win_r_key { get; set; } [JsonPropertyName("override_win_r_key")]
public bool OverrideWinkeyR { get; set; }
public bool override_win_s_key { get; set; } [JsonPropertyName("override_win_s_key")]
public bool OverrideWinkeyS { get; set; }
public bool ignore_hotkeys_in_fullscreen { get; set; } [JsonPropertyName("ignore_hotkeys_in_fullscreen")]
public bool IgnoreHotkeysInFullscreen { get; set; }
public bool disable_drive_detection_warning { get; set; } [JsonPropertyName("disable_drive_detection_warning")]
public bool clear_input_on_launch { get; set; } public bool DisableDriveDetectionWarning { get; set; }
[JsonPropertyName("clear_input_on_launch")]
public bool ClearInputOnLaunch { get; set; }
public PowerLauncherProperties() public PowerLauncherProperties()
{ {
open_powerlauncher = new HotkeySettings(); OpenPowerLauncher = new HotkeySettings();
open_file_location = new HotkeySettings(); OpenFileLocation = new HotkeySettings();
copy_path_location = new HotkeySettings(); CopyPathLocation = new HotkeySettings();
open_console = new HotkeySettings(); OpenConsole = new HotkeySettings();
search_result_preference = "most_recently_used"; SearchResultPreference = "most_recently_used";
search_type_preference = "application_name"; SearchTypePreference = "application_name";
ignore_hotkeys_in_fullscreen = false; IgnoreHotkeysInFullscreen = false;
disable_drive_detection_warning = false; DisableDriveDetectionWarning = false;
clear_input_on_launch = false; ClearInputOnLaunch = false;
} }
} }
} }

View File

@ -2,35 +2,29 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public class PowerPreviewSettings : BasePTModuleSettings public class PowerPreviewSettings : BasePTModuleSettings
{ {
public PowerPreviewProperties properties { get; set; } public const string ModuleName = "File Explorer";
[JsonPropertyName("Properties")]
public PowerPreviewProperties Properties { get; set; }
public PowerPreviewSettings() public PowerPreviewSettings()
{ {
properties = new PowerPreviewProperties(); Properties = new PowerPreviewProperties();
Version = "1"; Version = "1";
Name = "File Explorer"; Name = ModuleName;
} }
public PowerPreviewSettings(string ptName) public PowerPreviewSettings(string ptName)
{ {
properties = new PowerPreviewProperties(); Properties = new PowerPreviewProperties();
Version = "1"; Version = "1";
Name = ptName; Name = ptName;
} }
public override string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
} }
} }

View File

@ -34,9 +34,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
else else
{ {
settings = new PowerLauncherSettings(); settings = new PowerLauncherSettings();
settings.Properties.open_powerlauncher.Alt = true; settings.Properties.OpenPowerLauncher.Alt = true;
settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space; settings.Properties.OpenPowerLauncher.Code = (int)Windows.System.VirtualKey.Space;
settings.Properties.maximum_number_of_results = 4; settings.Properties.MaximumNumberOfResults = 4;
callback(settings); callback(settings);
} }
@ -87,14 +87,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.search_result_preference; return settings.Properties.SearchResultPreference;
} }
set set
{ {
if (settings.Properties.search_result_preference != value) if (settings.Properties.SearchResultPreference != value)
{ {
settings.Properties.search_result_preference = value; settings.Properties.SearchResultPreference = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -104,14 +104,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.search_type_preference; return settings.Properties.SearchTypePreference;
} }
set set
{ {
if (settings.Properties.search_type_preference != value) if (settings.Properties.SearchTypePreference != value)
{ {
settings.Properties.search_type_preference = value; settings.Properties.SearchTypePreference = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -121,14 +121,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.maximum_number_of_results; return settings.Properties.MaximumNumberOfResults;
} }
set set
{ {
if (settings.Properties.maximum_number_of_results != value) if (settings.Properties.MaximumNumberOfResults != value)
{ {
settings.Properties.maximum_number_of_results = value; settings.Properties.MaximumNumberOfResults = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -138,14 +138,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.open_powerlauncher; return settings.Properties.OpenPowerLauncher;
} }
set set
{ {
if (settings.Properties.open_powerlauncher != value) if (settings.Properties.OpenPowerLauncher != value)
{ {
settings.Properties.open_powerlauncher = value; settings.Properties.OpenPowerLauncher = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -155,14 +155,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.open_file_location; return settings.Properties.OpenFileLocation;
} }
set set
{ {
if (settings.Properties.open_file_location != value) if (settings.Properties.OpenFileLocation != value)
{ {
settings.Properties.open_file_location = value; settings.Properties.OpenFileLocation = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -172,14 +172,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.copy_path_location; return settings.Properties.CopyPathLocation;
} }
set set
{ {
if (settings.Properties.copy_path_location != value) if (settings.Properties.CopyPathLocation != value)
{ {
settings.Properties.copy_path_location = value; settings.Properties.CopyPathLocation = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -189,14 +189,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.override_win_r_key; return settings.Properties.OverrideWinkeyR;
} }
set set
{ {
if (settings.Properties.override_win_r_key != value) if (settings.Properties.OverrideWinkeyR != value)
{ {
settings.Properties.override_win_r_key = value; settings.Properties.OverrideWinkeyR = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -206,14 +206,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.override_win_s_key; return settings.Properties.OverrideWinkeyS;
} }
set set
{ {
if (settings.Properties.override_win_s_key != value) if (settings.Properties.OverrideWinkeyS != value)
{ {
settings.Properties.override_win_s_key = value; settings.Properties.OverrideWinkeyS = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -223,14 +223,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.ignore_hotkeys_in_fullscreen; return settings.Properties.IgnoreHotkeysInFullscreen;
} }
set set
{ {
if (settings.Properties.ignore_hotkeys_in_fullscreen != value) if (settings.Properties.IgnoreHotkeysInFullscreen != value)
{ {
settings.Properties.ignore_hotkeys_in_fullscreen = value; settings.Properties.IgnoreHotkeysInFullscreen = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -240,14 +240,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.clear_input_on_launch; return settings.Properties.ClearInputOnLaunch;
} }
set set
{ {
if (settings.Properties.clear_input_on_launch != value) if (settings.Properties.ClearInputOnLaunch != value)
{ {
settings.Properties.clear_input_on_launch = value; settings.Properties.ClearInputOnLaunch = value;
UpdateSettings(); UpdateSettings();
} }
} }
@ -257,14 +257,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
return settings.Properties.disable_drive_detection_warning; return settings.Properties.DisableDriveDetectionWarning;
} }
set set
{ {
if (settings.Properties.disable_drive_detection_warning != value) if (settings.Properties.DisableDriveDetectionWarning != value)
{ {
settings.Properties.disable_drive_detection_warning = value; settings.Properties.DisableDriveDetectionWarning = value;
UpdateSettings(); UpdateSettings();
} }
} }

View File

@ -27,9 +27,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
} }
this._svgRenderIsEnabled = Settings.properties.EnableSvgPreview; this._svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
this._svgThumbnailIsEnabled = Settings.properties.EnableSvgThumbnail; this._svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
this._mdRenderIsEnabled = Settings.properties.EnableMdPreview; this._mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
} }
private bool _svgRenderIsEnabled = false; private bool _svgRenderIsEnabled = false;
@ -48,7 +48,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (value != _svgRenderIsEnabled) if (value != _svgRenderIsEnabled)
{ {
_svgRenderIsEnabled = value; _svgRenderIsEnabled = value;
Settings.properties.EnableSvgPreview = value; Settings.Properties.EnableSvgPreview = value;
RaisePropertyChanged(); RaisePropertyChanged();
} }
} }
@ -66,7 +66,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (value != _svgThumbnailIsEnabled) if (value != _svgThumbnailIsEnabled)
{ {
_svgThumbnailIsEnabled = value; _svgThumbnailIsEnabled = value;
Settings.properties.EnableSvgThumbnail = value; Settings.Properties.EnableSvgThumbnail = value;
RaisePropertyChanged(); RaisePropertyChanged();
} }
} }
@ -84,7 +84,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (value != _mdRenderIsEnabled) if (value != _mdRenderIsEnabled)
{ {
_mdRenderIsEnabled = value; _mdRenderIsEnabled = value;
Settings.properties.EnableMdPreview = value; Settings.Properties.EnableMdPreview = value;
RaisePropertyChanged(); RaisePropertyChanged();
} }
} }

View File

@ -45,8 +45,8 @@ namespace ViewModelTests
viewModel.SearchTypePreference = "SearchOptionsAreNotValidated"; viewModel.SearchTypePreference = "SearchOptionsAreNotValidated";
Assert.AreEqual(sendCallbackMock.TimesSent, 2); Assert.AreEqual(sendCallbackMock.TimesSent, 2);
Assert.IsTrue(mockSettings.Properties.search_result_preference == "SearchOptionsAreNotValidated"); Assert.IsTrue(mockSettings.Properties.SearchResultPreference == "SearchOptionsAreNotValidated");
Assert.IsTrue(mockSettings.Properties.search_type_preference == "SearchOptionsAreNotValidated"); Assert.IsTrue(mockSettings.Properties.SearchTypePreference == "SearchOptionsAreNotValidated");
} }
public void AssertHotkeySettings(HotkeySettings setting, bool win, bool ctrl, bool alt, bool shift, int code) public void AssertHotkeySettings(HotkeySettings setting, bool win, bool ctrl, bool alt, bool shift, int code)
@ -85,7 +85,7 @@ namespace ViewModelTests
Assert.AreEqual(4, sendCallbackMock.TimesSent); Assert.AreEqual(4, sendCallbackMock.TimesSent);
AssertHotkeySettings( AssertHotkeySettings(
mockSettings.Properties.open_powerlauncher, mockSettings.Properties.OpenPowerLauncher,
true, true,
false, false,
false, false,
@ -93,7 +93,7 @@ namespace ViewModelTests
(int)Windows.System.VirtualKey.S (int)Windows.System.VirtualKey.S
); );
AssertHotkeySettings( AssertHotkeySettings(
mockSettings.Properties.open_file_location, mockSettings.Properties.OpenFileLocation,
false, false,
true, true,
false, false,
@ -101,7 +101,7 @@ namespace ViewModelTests
(int)Windows.System.VirtualKey.A (int)Windows.System.VirtualKey.A
); );
AssertHotkeySettings( AssertHotkeySettings(
mockSettings.Properties.open_console, mockSettings.Properties.OpenConsole,
false, false,
false, false,
true, true,
@ -109,7 +109,7 @@ namespace ViewModelTests
(int)Windows.System.VirtualKey.D (int)Windows.System.VirtualKey.D
); );
AssertHotkeySettings( AssertHotkeySettings(
mockSettings.Properties.copy_path_location, mockSettings.Properties.CopyPathLocation,
false, false,
false, false,
false, false,
@ -127,8 +127,8 @@ namespace ViewModelTests
Assert.AreEqual(1, sendCallbackMock.TimesSent); Assert.AreEqual(1, sendCallbackMock.TimesSent);
Assert.IsTrue(mockSettings.Properties.override_win_r_key); Assert.IsTrue(mockSettings.Properties.OverrideWinkeyR);
Assert.IsFalse(mockSettings.Properties.override_win_s_key); Assert.IsFalse(mockSettings.Properties.OverrideWinkeyS);
} }
[TestMethod] [TestMethod]
@ -139,7 +139,7 @@ namespace ViewModelTests
// Assert // Assert
Assert.AreEqual(1, sendCallbackMock.TimesSent); Assert.AreEqual(1, sendCallbackMock.TimesSent);
Assert.IsTrue(mockSettings.Properties.disable_drive_detection_warning); Assert.IsTrue(mockSettings.Properties.DisableDriveDetectionWarning);
} }
} }
} }

View File

@ -59,7 +59,7 @@ namespace ViewModelTests
ShellPage.DefaultSndMSGCallback = msg => ShellPage.DefaultSndMSGCallback = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableSvgPreview); Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgPreview);
}; };
// act // act
@ -76,7 +76,7 @@ namespace ViewModelTests
ShellPage.DefaultSndMSGCallback = msg => ShellPage.DefaultSndMSGCallback = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableSvgThumbnail); Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail);
}; };
// act // act
@ -93,7 +93,7 @@ namespace ViewModelTests
ShellPage.DefaultSndMSGCallback = msg => ShellPage.DefaultSndMSGCallback = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableMdPreview); Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableMdPreview);
}; };
// act // act

View File

@ -202,8 +202,8 @@ namespace Microsoft.Plugin.Indexer
} }
public void UpdateSettings(PowerLauncherSettings settings) public void UpdateSettings(PowerLauncherSettings settings)
{ {
_settings.MaxSearchCount = settings.Properties.maximum_number_of_results; _settings.MaxSearchCount = settings.Properties.MaximumNumberOfResults;
_driveDetection.IsDriveDetectionWarningCheckBoxSelected = settings.Properties.disable_drive_detection_warning; _driveDetection.IsDriveDetectionWarningCheckBoxSelected = settings.Properties.DisableDriveDetectionWarning;
} }
public Control CreateSettingPanel() public Control CreateSettingPanel()
{ {

View File

@ -43,7 +43,7 @@ namespace PowerLauncher
{ {
var overloadSettings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName); var overloadSettings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
var openPowerlauncher = ConvertHotkey(overloadSettings.Properties.open_powerlauncher); var openPowerlauncher = ConvertHotkey(overloadSettings.Properties.OpenPowerLauncher);
if (_settings.Hotkey != openPowerlauncher) if (_settings.Hotkey != openPowerlauncher)
{ {
_settings.Hotkey = openPowerlauncher; _settings.Hotkey = openPowerlauncher;
@ -56,14 +56,14 @@ namespace PowerLauncher
shellSettings.UpdateSettings(overloadSettings); shellSettings.UpdateSettings(overloadSettings);
} }
if (_settings.MaxResultsToShow != overloadSettings.Properties.maximum_number_of_results) if (_settings.MaxResultsToShow != overloadSettings.Properties.MaximumNumberOfResults)
{ {
_settings.MaxResultsToShow = overloadSettings.Properties.maximum_number_of_results; _settings.MaxResultsToShow = overloadSettings.Properties.MaximumNumberOfResults;
} }
if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.Properties.ignore_hotkeys_in_fullscreen) if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.Properties.IgnoreHotkeysInFullscreen)
{ {
_settings.IgnoreHotkeysOnFullscreen = overloadSettings.Properties.ignore_hotkeys_in_fullscreen; _settings.IgnoreHotkeysOnFullscreen = overloadSettings.Properties.IgnoreHotkeysInFullscreen;
} }
var indexer = PluginManager.AllPlugins.Find(p => p.Metadata.Name.Equals("Windows Indexer Plugin", StringComparison.OrdinalIgnoreCase)); var indexer = PluginManager.AllPlugins.Find(p => p.Metadata.Name.Equals("Windows Indexer Plugin", StringComparison.OrdinalIgnoreCase));
@ -73,9 +73,9 @@ namespace PowerLauncher
indexerSettings.UpdateSettings(overloadSettings); indexerSettings.UpdateSettings(overloadSettings);
} }
if (_settings.ClearInputOnLaunch != overloadSettings.Properties.clear_input_on_launch) if (_settings.ClearInputOnLaunch != overloadSettings.Properties.ClearInputOnLaunch)
{ {
_settings.ClearInputOnLaunch = overloadSettings.Properties.clear_input_on_launch; _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
} }
} }
// the settings application can hold a lock on the settings.json file which will result in a IOException. // the settings application can hold a lock on the settings.json file which will result in a IOException.