diff --git a/StyleCopAnalyzers.ruleset b/StyleCopAnalyzers.ruleset new file mode 100644 index 0000000..b0022fc --- /dev/null +++ b/StyleCopAnalyzers.ruleset @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dot.sln.DotSettings b/dot.sln.DotSettings index 205c3ab..ea65e11 100644 --- a/dot.sln.DotSettings +++ b/dot.sln.DotSettings @@ -1,6 +1,6 @@ - + + 1 + 1 <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> <TypePattern> diff --git a/src/Color/MouseHook.cs b/src/Color/MouseHook.cs index 4bd7084..02def20 100644 --- a/src/Color/MouseHook.cs +++ b/src/Color/MouseHook.cs @@ -15,7 +15,6 @@ internal sealed class MouseHook : IDisposable [FieldOffset(4)] public readonly int Y; } - // ReSharper disable once EventNeverSubscribedTo.Global public event MouseEventHandler MouseEvent = delegate { }; private const int _WH_MOUSE_LL = 14; @@ -34,7 +33,6 @@ internal sealed class MouseHook : IDisposable Dispose(false); } - private void Dispose(bool disposing) { if (_disposed) return; @@ -46,7 +44,6 @@ internal sealed class MouseHook : IDisposable _disposed = true; } - private nint HookCallback(int nCode, nint wParam, nint lParam) { if (nCode < 0 || (_WM_MOUSEMOVE != wParam && _WM_LBUTTONDOWN != wParam)) @@ -68,7 +65,6 @@ internal sealed class MouseHook : IDisposable return Win32.SetWindowsHookEx(_WH_MOUSE_LL, proc, Win32.GetModuleHandle(curModule.ModuleName), 0); } - public void Dispose() { Dispose(true); diff --git a/src/Color/WinInfo.cs b/src/Color/WinInfo.cs index aad2d08..79afd5a 100644 --- a/src/Color/WinInfo.cs +++ b/src/Color/WinInfo.cs @@ -33,7 +33,6 @@ internal class WinInfo : Form Controls.Add(_pbox); } - ~WinInfo() { Dispose(false); @@ -58,7 +57,6 @@ internal class WinInfo : Form _disposed = true; } - public void UpdateImage(Bitmap img, int x, int y) { // 计算复制小图的区域 diff --git a/src/CsxEditor.cs b/src/CsxEditor.cs index b87f5d7..ea35c44 100644 --- a/src/CsxEditor.cs +++ b/src/CsxEditor.cs @@ -24,7 +24,6 @@ internal class CsxEditor }) .ToArray(); - Parallel.ForEach(files, file => { var startInfo = new ProcessStartInfo { FileName = "pngquant" diff --git a/src/DirOption.cs b/src/DirOption.cs index cbb4648..ffac2fc 100644 --- a/src/DirOption.cs +++ b/src/DirOption.cs @@ -9,28 +9,24 @@ internal class DirOption : OptionBase [Localization(typeof(Str))] public IEnumerable ExcludeRegexes { get; set; } - [CommandOption("-f|--filter")] [Description(nameof(Str.FileSearchPattern))] [Localization(typeof(Str))] [DefaultValue("*")] public string Filter { get; set; } - [CommandOption("-d|--max-depth")] [Description(nameof(Str.MaxRecursionDepth))] [Localization(typeof(Str))] [DefaultValue(int.MaxValue)] public int MaxRecursionDepth { get; set; } - [CommandArgument(0, "[path]")] [Description(nameof(Str.FolderPath))] [Localization(typeof(Str))] [DefaultValue(".")] public string Path { get; set; } - [CommandOption("-w|--write")] [Description(nameof(Str.WriteMode))] [Localization(typeof(Str))] diff --git a/src/FilesTool.cs b/src/FilesTool.cs index e8b20bc..7cec675 100644 --- a/src/FilesTool.cs +++ b/src/FilesTool.cs @@ -51,7 +51,6 @@ internal abstract class FilesTool : ToolBase where TOption : D AnsiConsole.Write(new Panel(grid).Header(Str.WriteFileStats)); } - // ReSharper disable once ReturnTypeCanBeEnumerable.Local private string[] EnumerateFiles(string path, string searchPattern, out int excludeCnt) { @@ -84,17 +83,14 @@ internal abstract class FilesTool : ToolBase where TOption : D return CoreInternal(); } - protected static FileStream CreateTempFile(out string file) { file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.tmp"); return OpenFileStream(file, FileMode.OpenOrCreate, FileAccess.Write); } - protected abstract ValueTask FileHandle(string file, CancellationToken cancelToken); - protected static FileStream OpenFileStream(string file, FileMode mode, FileAccess access , FileShare share = FileShare.Read) { @@ -130,7 +126,6 @@ internal abstract class FilesTool : ToolBase where TOption : D } } - protected void UpdateStats(string key) { _writeStats.AddOrUpdate(key, 1, (_, oldValue) => oldValue + 1); diff --git a/src/Get/Main.cs b/src/Get/Main.cs index 985676b..803ac86 100644 --- a/src/Get/Main.cs +++ b/src/Get/Main.cs @@ -35,7 +35,6 @@ internal partial class Main : ToolBase