[fxcop] Wox.Infrastructure (#7590)

* CA1052: Static holder types should be Static or NotInheritable

* CA1041: Provide ObsoleteAttribute message

* CA1062: Validate arguments of public methods

* CA1304: Specify CultureInfo / CA1305: Specify IFormatProvider / CA1307: Specify StringComparison for clarity

* CA1802: Use Literals Where Appropriate

* CA1820: Test for empty strings using string length

* CA1707: Identifiers should not contain underscores

* CA1805: Do not initialize unnecessarily.

* CA1822: Mark members as static

* CA2227: Collection properties should be read only

* CA1054: URI parameters should not be strings

* CA1031: Do not catch general exception types

* CA1060: Move P/Invokes to NativeMethods class

* CA1308: Normalize strings to uppercase

* CA2000: Dispose objects before losing scope / CA2234: Pass System.Uri objects instead of strings

* CA2234: Pass System.Uri objects instead of strings

* CA1044: Properties should not be write only

* CA1716: Identifiers should not match keywords

* CA2007: Do not directly await a Task

* CA2007: Do not directly await a Task (Suppressed)

* CA5350: Do Not Use Weak Cryptographic Algorithms (Suppressed)

* CA1724: Type names should not match namespaces (renamed Settings.cs to PowerToysRunSettings.cs)

* CA1033: Interface methods should be callable by child types (Added sealed modifier to class)

* CA1724: Type names should not match namespaces (Renamed Plugin.cs to RunPlugin.cs)

* CA1724: Type names should not match namespaces (Renamed Http.cs to HttpClient.cs)

* CA5364: Do not use deprecated security protocols (Remove unused code)

* Enabled FxCopAnalyzer for Wox.Infrastructure

* fixed comment

* Addressed comments

- Changed Ordinal to InvariantCulture
- Added comments
- Removed unused obsolete code
- Removed unused method (CA2007: Do not directly await a Task)

* Addressed comments - fixed justification for CA1031 suppression

* Addressed comments - Fixed justification for CA1031 suppression in Wox.Core/Wox.Plugin
This commit is contained in:
Avneet Kaur
2020-10-29 17:52:35 -07:00
committed by GitHub
parent 5015642b6d
commit ec8ead8183
41 changed files with 293 additions and 227 deletions

View File

@@ -6,7 +6,7 @@ namespace Wox.Infrastructure.UserSettings
{
public class HttpProxy
{
public bool Enabled { get; set; } = false;
public bool Enabled { get; set; }
public string Server { get; set; }

View File

@@ -2,6 +2,7 @@
// 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 Wox.Plugin;
@@ -9,30 +10,34 @@ namespace Wox.Infrastructure.UserSettings
{
public class PluginSettings : BaseModel
{
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
public Dictionary<string, RunPlugin> Plugins { get; private set; } = new Dictionary<string, RunPlugin>();
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
{
if (metadatas == null)
{
throw new ArgumentNullException(nameof(metadatas));
}
foreach (var metadata in metadatas)
{
if (Plugins.ContainsKey(metadata.ID))
{
var settings = Plugins[metadata.ID];
if (settings.ActionKeywords?.Count > 0)
if (settings.GetActionKeywords()?.Count > 0)
{
metadata.SetActionKeywords(settings.ActionKeywords);
metadata.ActionKeyword = settings.ActionKeywords[0];
metadata.SetActionKeywords(settings.GetActionKeywords());
metadata.ActionKeyword = settings.GetActionKeywords()[0];
}
metadata.Disabled = settings.Disabled;
}
else
{
Plugins[metadata.ID] = new Plugin
Plugins[metadata.ID] = new RunPlugin(metadata.GetActionKeywords())
{
ID = metadata.ID,
Name = metadata.Name,
ActionKeywords = metadata.GetActionKeywords(),
Disabled = metadata.Disabled,
};
}

View File

@@ -12,7 +12,7 @@ using Wox.Plugin;
namespace Wox.Infrastructure.UserSettings
{
public class Settings : BaseModel
public class PowerToysRunSettings : BaseModel
{
private string _hotkey = "Alt + Space";
private string _previousHotkey = string.Empty;
@@ -95,7 +95,7 @@ namespace Wox.Infrastructure.UserSettings
}
}
public bool AutoUpdates { get; set; } = false;
public bool AutoUpdates { get; set; }
public double WindowLeft { get; set; }
@@ -126,13 +126,7 @@ namespace Wox.Infrastructure.UserSettings
[JsonProperty(Order = 1)]
public PluginSettings PluginSettings { get; set; } = new PluginSettings();
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
[Obsolete]
public double Opacity { get; set; } = 1;
[Obsolete]
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; } = new ObservableCollection<CustomPluginHotkey>();
public bool DontPromptUpdateMsg { get; set; }
@@ -162,7 +156,7 @@ namespace Wox.Infrastructure.UserSettings
public bool HideWhenDeactivated { get; set; } = true;
public bool ClearInputOnLaunch { get; set; } = false;
public bool ClearInputOnLaunch { get; set; }
public bool RememberLastLaunchLocation { get; set; }
@@ -182,12 +176,4 @@ namespace Wox.Infrastructure.UserSettings
Empty,
Preserved,
}
[Obsolete]
public enum OpacityMode
{
Normal = 0,
LayeredWindow = 1,
DWM = 2,
}
}

View File

@@ -6,13 +6,28 @@ using System.Collections.Generic;
namespace Wox.Infrastructure.UserSettings
{
public class Plugin
public class RunPlugin
{
public string ID { get; set; }
public string Name { get; set; }
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
private List<string> _actionKeywords;
public RunPlugin(List<string> actionKeywords = null)
{
_actionKeywords = actionKeywords;
}
public List<string> GetActionKeywords()
{
return _actionKeywords;
}
public void SetActionKeywords(List<string> value)
{
_actionKeywords = value;
}
/// <summary>
/// Gets or sets a value indicating whether used only to save the state of the plugin in settings