From ec3ea5c4ae19eb9916fd2b1f7771884cab68a610 Mon Sep 17 00:00:00 2001
From: CleanCodeDeveloper
<16760760+CleanCodeDeveloper@users.noreply.github.com>
Date: Tue, 8 Mar 2022 17:46:36 +0100
Subject: [PATCH] [Wox.Plugin] Enable analyzer and fix warnings (#16547)
---
src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs | 4 ++--
src/modules/launcher/Wox.Plugin/Common/Win32/NativeMethods.cs | 4 ++--
src/modules/launcher/Wox.Plugin/Constant.cs | 2 +-
src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj | 2 ++
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs
index 92b5cf4349..45e3578a41 100644
--- a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs
+++ b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs
@@ -187,7 +187,7 @@ namespace Wox.Plugin.Common
if (string.IsNullOrEmpty(Path))
{
- throw new Exception("Browser path is null or empty.");
+ throw new ArgumentOutOfRangeException(nameof(Path), "Browser path is null or empty.");
}
}
catch (Exception e)
@@ -217,7 +217,7 @@ namespace Wox.Plugin.Common
return stringBuilder.ToString();
}
- throw new Exception("Could not load indirect string.");
+ throw new ArgumentNullException(nameof(Path), "Could not load indirect string.");
}
}
}
diff --git a/src/modules/launcher/Wox.Plugin/Common/Win32/NativeMethods.cs b/src/modules/launcher/Wox.Plugin/Common/Win32/NativeMethods.cs
index 9f8b08c4a7..504683d89e 100644
--- a/src/modules/launcher/Wox.Plugin/Common/Win32/NativeMethods.cs
+++ b/src/modules/launcher/Wox.Plugin/Common/Win32/NativeMethods.cs
@@ -801,9 +801,9 @@ namespace Wox.Plugin.Common.Win32
return !r1.Equals(r2);
}
- public bool Equals(RECT r)
+ public bool Equals(RECT other)
{
- return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom;
+ return other.Left == Left && other.Top == Top && other.Right == Right && other.Bottom == Bottom;
}
public override bool Equals(object obj)
diff --git a/src/modules/launcher/Wox.Plugin/Constant.cs b/src/modules/launcher/Wox.Plugin/Constant.cs
index 8aefc427b4..f66d9b36ad 100644
--- a/src/modules/launcher/Wox.Plugin/Constant.cs
+++ b/src/modules/launcher/Wox.Plugin/Constant.cs
@@ -18,7 +18,7 @@ namespace Wox.Plugin
{
if (obj == null)
{
- throw new NullReferenceException();
+ throw new ArgumentNullException(nameof(obj));
}
else
{
diff --git a/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj b/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj
index 0944b1a81f..d946dcc4bf 100644
--- a/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj
+++ b/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj
@@ -14,6 +14,8 @@
false
x64
en-US
+ true
+ Recommended