[PreviewPane] Enable analyzer and fix warnings (#16995)

This commit is contained in:
CleanCodeDeveloper
2022-03-14 16:42:32 +01:00
committed by GitHub
parent bf3e427017
commit 7365ba14d0
5 changed files with 90 additions and 83 deletions

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Reflection;
using Common;
using Microsoft.PowerToys.STATestExtension;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PreviewHandlerCommon;

View File

@@ -18,6 +18,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
<PropertyGroup>

View File

@@ -107,7 +107,7 @@ namespace Common.Utilities
if (buffer == null)
{
throw new NullReferenceException("buffer is null");
throw new ArgumentNullException(nameof(buffer), "buffer is null");
}
if (offset < 0 || count < 0 || (offset + count) > buffer.Length)

View File

@@ -4,14 +4,16 @@
using System;
/// <summary>
/// Flags to control download and execution in Web Browser Control.
/// Values of flags are defined in mshtmdid.h in distributed Windows Sdk.
/// </summary>
[Flags]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Interop, keeping stuff in sync")]
public enum WebBrowserDownloadControlFlags : int
namespace Common
{
/// <summary>
/// Flags to control download and execution in Web Browser Control.
/// Values of flags are defined in mshtmdid.h in distributed Windows Sdk.
/// </summary>
[Flags]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Interop, keeping stuff in sync")]
public enum WebBrowserDownloadControlFlags : int
{
/// <summary>
/// Images will be downloaded from the server if this flag is set.
/// </summary>
@@ -106,4 +108,5 @@ public enum WebBrowserDownloadControlFlags : int
/// No user interface will be displayed during downloads.
/// </summary>
SILENT = 0x40000000,
}
}

View File

@@ -6,6 +6,7 @@ using System;
using System.Globalization;
using System.Reflection;
using System.Windows.Forms;
using Common;
namespace PreviewHandlerCommon
{
@@ -52,7 +53,7 @@ namespace PreviewHandlerCommon
{
object result;
if (name != null && name.Equals(DISPIDAMBIENTDLCONTROL, StringComparison.CurrentCulture))
if (name != null && name.Equals(DISPIDAMBIENTDLCONTROL, StringComparison.Ordinal))
{
// Using InvariantCulture since this is used for web browser configurations
result = Convert.ToInt32(