mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[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:
@@ -20,7 +20,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public class BinaryStorage<T> : IStorage<T>
|
||||
{
|
||||
// This storage helper returns whether or not to delete the binary storage items
|
||||
private static readonly int _binaryStorage = 0;
|
||||
private const int _binaryStorage = 0;
|
||||
private StoragePowerToysVersionInfo _storageHelper;
|
||||
|
||||
public BinaryStorage(string filename)
|
||||
@@ -75,6 +75,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
private T Deserialize(FileStream stream, T defaultData)
|
||||
{
|
||||
// http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.IO;
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
// File System Watcher Wrapper class which implements the IFileSystemWatcherWrapper interface
|
||||
public class FileSystemWatcherWrapper : FileSystemWatcher, IFileSystemWatcherWrapper
|
||||
public sealed class FileSystemWatcherWrapper : FileSystemWatcher, IFileSystemWatcherWrapper
|
||||
{
|
||||
public FileSystemWatcherWrapper()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Wox.Infrastructure.Storage
|
||||
event RenamedEventHandler Renamed;
|
||||
|
||||
// Properties of File System watcher
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Abstract properties can not have private set")]
|
||||
Collection<string> Filters { get; set; }
|
||||
|
||||
bool EnableRaisingEvents { get; set; }
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
bool Contains(T item);
|
||||
|
||||
void Set(IList<T> list);
|
||||
void SetList(IList<T> list);
|
||||
|
||||
bool Any();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public string DirectoryPath { get; set; }
|
||||
|
||||
// This storage helper returns whether or not to delete the json storage items
|
||||
private static readonly int _jsonStorage = 1;
|
||||
private const int _jsonStorage = 1;
|
||||
private StoragePowerToysVersionInfo _storageHelper;
|
||||
|
||||
internal JsonStorage()
|
||||
@@ -106,7 +106,8 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
private void BackupOriginFile()
|
||||
{
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff", CultureInfo.CurrentUICulture);
|
||||
// Using CurrentCulture since this is user facing
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff", CultureInfo.CurrentCulture);
|
||||
var directory = Path.GetDirectoryName(FilePath).NonNull();
|
||||
var originName = Path.GetFileNameWithoutExtension(FilePath);
|
||||
var backupName = $"{originName}-{timestamp}{FileSuffix}";
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
}
|
||||
|
||||
public void Set(IList<T> items)
|
||||
public void SetList(IList<T> items)
|
||||
{
|
||||
// enforce that internal representation
|
||||
try
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public class StoragePowerToysVersionInfo
|
||||
{
|
||||
// This detail is accessed by the storage items and is used to decide if the cache must be deleted or not
|
||||
public bool ClearCache { get; set; } = false;
|
||||
public bool ClearCache { get; set; }
|
||||
|
||||
private readonly string currentPowerToysVersion = string.Empty;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFilePath(string associatedFilePath, int type)
|
||||
private static string GetFilePath(string associatedFilePath, int type)
|
||||
{
|
||||
string suffix = string.Empty;
|
||||
string cacheSuffix = ".cache";
|
||||
@@ -102,6 +102,11 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
public StoragePowerToysVersionInfo(string associatedFilePath, int type)
|
||||
{
|
||||
if (associatedFilePath == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(associatedFilePath));
|
||||
}
|
||||
|
||||
FilePath = GetFilePath(associatedFilePath, type);
|
||||
|
||||
// Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file
|
||||
|
||||
Reference in New Issue
Block a user