Settingsv2 fix warnings (#2076)

* updating a ton of warnings.

* bunch of cleanup

* few smaller ones

* fixed naming

* reversing an oops

* adjusting json to use attribute

* more json properties
This commit is contained in:
Clint Rutkas
2020-04-10 15:22:07 -07:00
committed by GitHub
parent 3a46f4589b
commit 6fbed4ad5c
55 changed files with 354 additions and 357 deletions

View File

@@ -34,13 +34,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public GeneralSettings()
{
this.Packaged = false;
this.startup = false;
this.is_admin = false;
this.is_elevated = false;
this.theme = "system";
this.system_theme = "light";
this.powertoys_version = "v0.15.3";
Packaged = false;
startup = false;
is_admin = false;
is_elevated = false;
theme = "system";
system_theme = "light";
powertoys_version = "v0.15.3";
}
// converts the current to a json string.

View File

@@ -1,10 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "Element should not begin with upper-case letter to keep backward compatibilty with old settings.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Identifiers should contain underscores to keep backward compatibilty with old settings.")]

View File

@@ -24,27 +24,27 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
StringBuilder output = new StringBuilder();
if (this.win)
if (win)
{
output.Append("Win + ");
}
if (this.ctrl)
if (ctrl)
{
output.Append("Ctrl + ");
}
if (this.alt)
if (alt)
{
output.Append("Alt + ");
}
if (this.shift)
if (shift)
{
output.Append("Shift + ");
}
output.Append(this.key);
output.Append(key);
return output.ToString();
}
}

View File

@@ -16,8 +16,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public KeyboardManagerProperties()
{
this.EditShortcut = new BoolProperty();
this.RemapKeyboard = new BoolProperty();
EditShortcut = new BoolProperty();
RemapKeyboard = new BoolProperty();
}
public string ToJsonString()

View File

@@ -1,25 +1,31 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class KeyboardManagerSettings : BasePTModuleSettings
{
public KeyboardManagerProperties properties { get; set; }
[JsonPropertyName("properties")]
public KeyboardManagerProperties Properties { get; set; }
public KeyboardManagerSettings()
public KeyboardManagerSettings()
{
this.properties = new KeyboardManagerProperties();
this.version = "1";
this.name = "_unset_";
Properties = new KeyboardManagerProperties();
version = "1";
name = "_unset_";
}
public KeyboardManagerSettings(string ptName)
{
this.properties = new KeyboardManagerProperties();
this.version = "1";
this.name = ptName;
Properties = new KeyboardManagerProperties();
version = "1";
name = ptName;
}
}
}

View File

@@ -19,6 +19,10 @@
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>

View File

@@ -12,12 +12,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public OutGoingGeneralSettings()
{
this.general = null;
general = null;
}
public OutGoingGeneralSettings(GeneralSettings generalSettings)
{
this.general = generalSettings;
general = generalSettings;
}
public override string ToString()

View File

@@ -28,12 +28,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerLauncherProperties()
{
this.open_powerlauncher = new HotkeySettings();
this.open_file_location = new HotkeySettings();
this.copy_path_location = new HotkeySettings();
this.open_console = new HotkeySettings();
this.search_result_preference = "most_recently_used";
this.search_type_preference = "application_name";
open_powerlauncher = new HotkeySettings();
open_file_location = new HotkeySettings();
copy_path_location = new HotkeySettings();
open_console = new HotkeySettings();
search_result_preference = "most_recently_used";
search_type_preference = "application_name";
}
}
}

View File

@@ -10,9 +10,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerLauncherSettings()
{
this.properties = new PowerLauncherProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerLauncherProperties();
version = "1";
name = "_unset_";
}
}
}

View File

@@ -18,8 +18,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerPreviewProperties()
{
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
}
public override string ToString()

View File

@@ -16,16 +16,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerPreviewSettings()
{
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerPreviewProperties();
version = "1";
name = "_unset_";
}
public PowerPreviewSettings(string ptName)
{
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = ptName;
properties = new PowerPreviewProperties();
version = "1";
name = ptName;
}
public override string ToJsonString()

View File

@@ -2,31 +2,34 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class PowerRenameProperties
{
public PowerRenameProperties()
{
this.bool_persist_input = new BoolProperty();
this.bool_mru_enabled = new BoolProperty();
this.int_max_mru_size = new IntProperty();
this.bool_show_icon_on_menu = new BoolProperty();
this.bool_show_extended_menu = new BoolProperty();
PersistInput = new BoolProperty();
MruEnabled = new BoolProperty();
MaxMruSize = new IntProperty();
ShowIconInMenu = new BoolProperty();
ShowExtendedMenu = new BoolProperty();
}
public BoolProperty bool_persist_input { get; set; }
[JsonPropertyName("bool_persist_input")]
public BoolProperty PersistInput { get; set; }
public BoolProperty bool_mru_enabled { get; set; }
[JsonPropertyName("bool_mru_enabled")]
public BoolProperty MruEnabled { get; set; }
public IntProperty int_max_mru_size { get; set; }
[JsonPropertyName("int_max_mru_size")]
public IntProperty MaxMruSize { get; set; }
public BoolProperty bool_show_icon_on_menu { get; set; }
[JsonPropertyName("bool_show_icon_on_menu")]
public BoolProperty ShowIconInMenu { get; set; }
public BoolProperty bool_show_extended_menu { get; set; }
[JsonPropertyName("bool_show_extended_menu")]
public BoolProperty ShowExtendedMenu { get; set; }
}
}

View File

@@ -13,16 +13,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerRenameSettings()
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerRenameProperties();
version = "1";
name = "_unset_";
}
public PowerRenameSettings(string ptName)
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = ptName;
properties = new PowerRenameProperties();
version = "1";
name = ptName;
}
public override string ToJsonString()

View File

@@ -40,7 +40,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public static bool SettingsExists(string powertoy)
{
return File.Exists(SettingsUtils.GetSettingsPath(powertoy));
return File.Exists(GetSettingsPath(powertoy));
}
/// <summary>
@@ -49,7 +49,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
/// <returns>Deserialized json settings object.</returns>
public static T GetSettings<T>(string powertoy)
{
var jsonSettingsString = System.IO.File.ReadAllText(SettingsUtils.GetSettingsPath(powertoy));
var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy));
return JsonSerializer.Deserialize<T>(jsonSettingsString);
}
@@ -63,9 +63,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
CreateSettingsFolder(powertoy);
}
System.IO.File.WriteAllText(
SettingsUtils.GetSettingsPath(powertoy),
jsonSettings);
File.WriteAllText(GetSettingsPath(powertoy), jsonSettings);
}
}

View File

@@ -10,11 +10,11 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public class SndKeyboardManagerSettings
{
[JsonPropertyName("Keyboard Manager")]
public KeyboardManagerSettings keyboardManagerSettings { get; }
public KeyboardManagerSettings KeyboardManagerSettings { get; }
public SndKeyboardManagerSettings(KeyboardManagerSettings keyboardManagerSettings)
{
this.keyboardManagerSettings = keyboardManagerSettings;
KeyboardManagerSettings = keyboardManagerSettings;
}
public string ToJsonString()

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndModuleSettings(T settings)
{
this.powertoys = settings;
powertoys = settings;
}
public string ToJsonString()

View File

@@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndPowerPreviewSettings(PowerPreviewSettings settings)
{
this.File_Explorer_Preview = settings;
File_Explorer_Preview = settings;
}
public string ToJsonString()

View File

@@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndPowerRenameSettings(PowerRenameSettings settings)
{
this.PowerRename = settings;
PowerRename = settings;
}
public string ToJsonString()