[ImageResizer] Enable analyzer and fix warnings (#16512)

This commit is contained in:
CleanCodeDeveloper
2022-02-22 23:01:48 +01:00
committed by GitHub
parent 6a722e2961
commit 2b747d02d3
4 changed files with 8 additions and 5 deletions

View File

@@ -20,6 +20,8 @@
<Platform Condition="'$(Platform)'==''">x64</Platform> <Platform Condition="'$(Platform)'==''">x64</Platform>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath> <IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

View File

@@ -58,7 +58,7 @@ namespace ImageResizer.Models
[TestMethod] [TestMethod]
public void ProcessAggregatesErrors() public void ProcessAggregatesErrors()
{ {
var batch = CreateBatch(file => throw new Exception("Error: " + file)); var batch = CreateBatch(file => throw new InvalidOperationException("Error: " + file));
batch.Files.Add("Image1.jpg"); batch.Files.Add("Image1.jpg");
batch.Files.Add("Image2.jpg"); batch.Files.Add("Image2.jpg");

View File

@@ -23,6 +23,8 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath> <IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/ // See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System; using System;
using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -17,15 +16,15 @@ namespace ImageResizer.Properties
} }
public override JsonConverter CreateConverter( public override JsonConverter CreateConverter(
Type type, Type typeToConvert,
JsonSerializerOptions options) JsonSerializerOptions options)
{ {
if (type == null) if (typeToConvert == null)
{ {
return null; return null;
} }
Type keyType = type.UnderlyingSystemType; Type keyType = typeToConvert.UnderlyingSystemType;
JsonConverter converter = (JsonConverter)Activator.CreateInstance( JsonConverter converter = (JsonConverter)Activator.CreateInstance(
typeof(WrappedJsonConverter<>).MakeGenericType(keyType)); typeof(WrappedJsonConverter<>).MakeGenericType(keyType));