mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
added stylecop (#1933)
* added stylecop * removed xml documentation * used common stylecop file
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.Text.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public abstract class BasePTModuleSettings
|
||||
{
|
||||
// Gets or sets name of the powertoy module.
|
||||
public string name { get; set; }
|
||||
|
||||
// Gets or sets the powertoys version.
|
||||
public string version { get; set; }
|
||||
|
||||
// converts the current to a json string.
|
||||
public virtual string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
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;
|
||||
@@ -14,14 +18,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class IntProperty
|
||||
{
|
||||
public int value { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class Contributor
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Link { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
// 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.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class GeneralSettings
|
||||
{
|
||||
public bool packaged { get; set; }
|
||||
// Gets or sets a value indicating whether packaged.
|
||||
public bool Packaged { get; set; }
|
||||
|
||||
// Gets or sets a value indicating whether run powertoys on start-up.
|
||||
public bool startup { get; set; }
|
||||
|
||||
// Gets or sets a value indicating whether the powertoy elevated.
|
||||
public bool is_elevated { get; set; }
|
||||
|
||||
// Gets or sets a value indicating whether powertoys should run elevated.
|
||||
public bool run_elevated { get; set; }
|
||||
|
||||
// Gets or sets a value indicating whether is admin.
|
||||
public bool is_admin { get; set; }
|
||||
|
||||
// Gets or sets theme Name.
|
||||
public string theme { get; set; }
|
||||
|
||||
// Gets or sets system theme name.
|
||||
public string system_theme { get; set; }
|
||||
|
||||
// Gets or sets powertoys version number.
|
||||
public string powertoys_version { get; set; }
|
||||
|
||||
public GeneralSettings()
|
||||
{
|
||||
this.packaged = false;
|
||||
this.Packaged = false;
|
||||
this.startup = false;
|
||||
this.is_admin = false;
|
||||
this.is_elevated = false;
|
||||
@@ -30,29 +43,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
this.powertoys_version = "v0.15.3";
|
||||
}
|
||||
|
||||
// converts the current to a json string.
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class OutGoingGeneralSettings
|
||||
{
|
||||
public GeneralSettings general { get; set; }
|
||||
|
||||
public OutGoingGeneralSettings()
|
||||
{
|
||||
this.general = null;
|
||||
}
|
||||
|
||||
public OutGoingGeneralSettings(GeneralSettings generalSettings)
|
||||
{
|
||||
this.general = generalSettings;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// 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.")]
|
||||
@@ -1,4 +1,8 @@
|
||||
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;
|
||||
|
||||
@@ -7,7 +11,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public interface IPowerToySettings
|
||||
{
|
||||
string name { get; set; }
|
||||
|
||||
string version { get; set; }
|
||||
|
||||
string ToJsonString();
|
||||
}
|
||||
}
|
||||
|
||||
21
src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs
Normal file
21
src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
// 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.Text.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
// Represents the configuration property of the settings that store Integer type.
|
||||
public class IntProperty
|
||||
{
|
||||
// Gets or sets the integer value of the settings configuration.
|
||||
public int value { get; set; }
|
||||
|
||||
// Returns a JSON version of the class settings configuration class.
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="..\..\codeAnalysis\StyleCop.json" Link="StyleCop.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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.Text.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class OutGoingGeneralSettings
|
||||
{
|
||||
public GeneralSettings general { get; set; }
|
||||
|
||||
public OutGoingGeneralSettings()
|
||||
{
|
||||
this.general = null;
|
||||
}
|
||||
|
||||
public OutGoingGeneralSettings(GeneralSettings generalSettings)
|
||||
{
|
||||
this.general = generalSettings;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class PowerPreviewProperties
|
||||
{
|
||||
public BoolProperty IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL { get; set; }
|
||||
public BoolProperty PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID { get; set; }
|
||||
|
||||
public PowerPreviewProperties()
|
||||
{
|
||||
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
|
||||
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
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;
|
||||
@@ -29,37 +33,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class PowerPreviewProperties
|
||||
{
|
||||
public BoolProperty IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL { get; set; }
|
||||
public BoolProperty PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID { get; set; }
|
||||
|
||||
public PowerPreviewProperties()
|
||||
{
|
||||
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
|
||||
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class SndPowerPreviewSettings
|
||||
{
|
||||
[JsonPropertyName("File Explorer Preview")]
|
||||
public PowerPreviewSettings File_Explorer_Preview { get; set; }
|
||||
|
||||
public SndPowerPreviewSettings(PowerPreviewSettings settings)
|
||||
{
|
||||
this.File_Explorer_Preview = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.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();
|
||||
}
|
||||
|
||||
public BoolProperty bool_persist_input { get; set; }
|
||||
public BoolProperty bool_mru_enabled { get; set; }
|
||||
public IntProperty int_max_mru_size { get; set; }
|
||||
public BoolProperty bool_show_icon_on_menu { get; set; }
|
||||
public BoolProperty bool_show_extended_menu { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -29,39 +30,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public BoolProperty bool_persist_input { get; set; }
|
||||
public BoolProperty bool_mru_enabled { get; set; }
|
||||
public IntProperty int_max_mru_size { get; set; }
|
||||
public BoolProperty bool_show_icon_on_menu { get; set; }
|
||||
public BoolProperty bool_show_extended_menu { get; set; }
|
||||
}
|
||||
|
||||
public class SndPowerRenameSettings
|
||||
{
|
||||
[JsonPropertyName("PowerRename")]
|
||||
public PowerRenameSettings PowerRename { get; set; }
|
||||
|
||||
public SndPowerRenameSettings(PowerRenameSettings settings)
|
||||
{
|
||||
this.PowerRename = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,45 +8,34 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public static class SettingsUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Get path to the json settings file.
|
||||
/// </summary>
|
||||
/// <returns>string path.</returns>
|
||||
// Get path to the json settings file.
|
||||
public static string GetSettingsPath(string powertoy)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(powertoy))
|
||||
if (string.IsNullOrWhiteSpace(powertoy))
|
||||
{
|
||||
return Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
$"Microsoft\\PowerToys\\settings.json");
|
||||
}
|
||||
|
||||
return Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
$"Microsoft\\PowerToys\\{powertoy}\\settings.json");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a Deserialized object of the json settings string.
|
||||
/// </summary>
|
||||
/// <returns>Deserialized json settings object.</returns>
|
||||
// Get a Deserialized object of the json settings string.
|
||||
public static T GetSettings<T>(string powertoy)
|
||||
{
|
||||
var jsonSettingsString = System.IO.File.ReadAllText(SettingsUtils.GetSettingsPath(powertoy));
|
||||
return JsonSerializer.Deserialize<T>(jsonSettingsString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save settings to a json file.
|
||||
/// </summary>
|
||||
/// <param name="settings">dynamic json settings object.</param>
|
||||
public static void SaveSettings(string jsonSettings, string powertoy)
|
||||
// Save settings to a json file.
|
||||
public static void SaveSettings(string moduleJsonSettings, string powertoyModuleName)
|
||||
{
|
||||
if(jsonSettings != null)
|
||||
{
|
||||
System.IO.File.WriteAllText(
|
||||
SettingsUtils.GetSettingsPath(powertoy),
|
||||
jsonSettings.ToString());
|
||||
}
|
||||
System.IO.File.WriteAllText(
|
||||
SettingsUtils.GetSettingsPath(powertoyModuleName),
|
||||
moduleJsonSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.Text.Json;
|
||||
|
||||
#pragma warning disable SA1649 // File name should match first type name
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class SndModuleSettings<S>
|
||||
// Represents a powertoys module settings setnt to the runner.
|
||||
public class SndModuleSettings<T>
|
||||
{
|
||||
public S powertoys { get; set; }
|
||||
public T powertoys { get; set; }
|
||||
|
||||
public SndModuleSettings(S settings)
|
||||
public SndModuleSettings(T settings)
|
||||
{
|
||||
this.powertoys = settings;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class SndPowerPreviewSettings
|
||||
{
|
||||
[JsonPropertyName("File Explorer Preview")]
|
||||
public PowerPreviewSettings File_Explorer_Preview { get; set; }
|
||||
|
||||
public SndPowerPreviewSettings(PowerPreviewSettings settings)
|
||||
{
|
||||
this.File_Explorer_Preview = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// 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.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class SndPowerRenameSettings
|
||||
{
|
||||
[JsonPropertyName("PowerRename")]
|
||||
public PowerRenameSettings PowerRename { get; set; }
|
||||
|
||||
public SndPowerRenameSettings(PowerRenameSettings settings)
|
||||
{
|
||||
this.PowerRename = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user