зеркало из https://github.com/dotnet/winforms.git
Merge pull request #12439 from JeremyKuhne/cleananalyze2
More analyzer cleanup
This commit is contained in:
Коммит
f3dbf39e87
|
@ -1255,6 +1255,9 @@ dotnet_diagnostic.CA5404.severity = none
|
|||
# CA5405: Do not always skip token validation in delegates
|
||||
dotnet_diagnostic.CA5405.severity = none
|
||||
|
||||
# CS1573: Parameter has no matching param tag in the XML comment (but other parameters do)
|
||||
dotnet_diagnostic.CS1573.severity = none
|
||||
|
||||
# IL3000: Avoid using accessing Assembly file path when publishing as a single-file
|
||||
dotnet_diagnostic.IL3000.severity = none # TODO: warning
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
||||
<Import Project="$(RepositoryEngineeringDir)CodeStyle.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Analyzer.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)FacadeAssemblies.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)ApiCompatibility\PublicApiAnalyzer.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Test.props" Condition="'$(IsTestProject)' == 'true'"/>
|
||||
|
@ -14,19 +14,7 @@
|
|||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<LangVersion Condition="'$(LangVersion)' == ''">preview</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
|
||||
<IsAnalyzerProject>false</IsAnalyzerProject>
|
||||
<IsAnalyzerProject Condition="!$(IsTestProject) and
|
||||
($(MSBuildProjectName.EndsWith('.Analyzers'))
|
||||
or $(MSBuildProjectName.EndsWith('.CodeFixes.VisualBasic'))
|
||||
or $(MSBuildProjectName.EndsWith('.CodeFixes.CSharp'))
|
||||
or $(MSBuildProjectName.EndsWith('.Analyzers.VisualBasic'))
|
||||
or $(MSBuildProjectName.EndsWith('.Analyzers.CSharp')))"
|
||||
>true</IsAnalyzerProject>
|
||||
|
||||
<!-- Only upgrade NuGetAudit warnings to errors for official builds. -->
|
||||
<WarningsNotAsErrors Condition="'$(OfficialBuild)' != 'true'">$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
|
@ -40,13 +28,6 @@
|
|||
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(IsAnalyzerProject)' == 'true'">
|
||||
<IsRoslynComponent>true</IsRoslynComponent>
|
||||
|
||||
<!-- Mark it so eng/packageContent.targets knows how to correctly package it -->
|
||||
<DefineConstants>WINFORMS_ANALYZERS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- SDK flipped to 'true' by default https://github.com/dotnet/sdk/pull/12720 -->
|
||||
<PropertyGroup>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="$(RepositoryEngineeringDir)CodeStyle.targets" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Analyzer.targets" />
|
||||
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
||||
<Import Project="$(RepositoryEngineeringDir)packageContent.targets" />
|
||||
<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
|
||||
<Import Project="$(RepositoryEngineeringDir)ApiCompatibility\PublicApiAnalyzer.targets" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Test.targets" Condition="'$(IsTestProject)' == 'true' "/>
|
||||
|
||||
<!-- CA1416 Validate platform compatibility. Do not apply to netstandard as it does not have the attribute. -->
|
||||
|
|
|
@ -196,9 +196,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{
|
|||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
eng\CodeAnalysisSource.cs = eng\CodeAnalysisSource.cs
|
||||
eng\Analyzer.targets = eng\Analyzer.targets
|
||||
eng\Analyzer.props = eng\Analyzer.props
|
||||
eng\CodeAnalysisSource.vb = eng\CodeAnalysisSource.vb
|
||||
eng\CodeStyle.props = eng\CodeStyle.props
|
||||
eng\CodeStyle.targets = eng\CodeStyle.targets
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<IsAnalyzerProject Condition="'$(IsAnalyzerProject)' == ''">false</IsAnalyzerProject>
|
||||
|
||||
<!-- Only upgrade NuGetAudit warnings to errors for official builds. -->
|
||||
<WarningsNotAsErrors Condition="'$(OfficialBuild)' != 'true'">$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
|
||||
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
|
||||
<!--
|
||||
Don't let Microsoft.CodeAnalysis.NetAnalyzers complain about the version being older than what is in the SDK.
|
||||
-->
|
||||
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(IsAnalyzerProject)' == 'true'">
|
||||
<IsRoslynComponent>true</IsRoslynComponent>
|
||||
|
||||
<!-- Mark it so eng/packageContent.targets knows how to correctly package it -->
|
||||
<DefineConstants>WINFORMS_ANALYZERS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<Import Project="$(RepositoryEngineeringDir)ApiCompatibility\PublicApiAnalyzer.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<!-- https://github.com/DotNetAnalyzers/StyleCopAnalyzers -->
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
Make sure any documentation comments which are included in code get checked for syntax during the build, but do
|
||||
not report warnings for missing comments.
|
||||
|
||||
CS1573: Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do)
|
||||
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
|
||||
CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do)
|
||||
-->
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn>
|
||||
|
||||
<!-- Do not warn about the version of analyzers being used in this project -->
|
||||
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Language)' == 'C#'">
|
||||
<Compile Include="$(MSBuildThisFileDirectory)CodeAnalysisSource.cs" Visible="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Language)' == 'VB'">
|
||||
<Compile Include="$(MSBuildThisFileDirectory)CodeAnalysisSource.vb" Visible="false" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -3,9 +3,6 @@
|
|||
<PropertyGroup>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>annotations</Nullable>
|
||||
<!-- Code warnings that weren't enabled in dotnet/runtime but are raised in winforms.
|
||||
TODO: Clean the code up and remove the NoWarns. -->
|
||||
<NoWarn>$(NoWarn);CA1825;CA5351;CA1850</NoWarn>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -320,8 +320,8 @@ public class GraphicsPathTests
|
|||
[Fact]
|
||||
public void AddLines_ZeroPoints_ThrowsArgumentException()
|
||||
{
|
||||
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new Point[0]));
|
||||
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new PointF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(Array.Empty<Point>()));
|
||||
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -430,7 +430,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddBeziers_InvalidFloatPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new PointF[0] };
|
||||
yield return new object[] { Array.Empty<PointF>() };
|
||||
yield return new object[] { new PointF[1] { new(1f, 1f) } };
|
||||
yield return new object[] { new PointF[2] { new(1f, 1f), new(2f, 2f) } };
|
||||
yield return new object[] { new PointF[3] { new(1f, 1f), new(2f, 2f), new(3f, 3f) } };
|
||||
|
@ -561,7 +561,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddCurve_InvalidFloatPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new PointF[0] };
|
||||
yield return new object[] { Array.Empty<PointF>() };
|
||||
yield return new object[] { new PointF[1] { new(1f, 1f) } };
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddCurve_InvalidPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new Point[0] };
|
||||
yield return new object[] { Array.Empty<Point>() };
|
||||
yield return new object[] { new Point[1] { new(1, 1) } };
|
||||
}
|
||||
|
||||
|
@ -669,7 +669,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddClosedCurve_InvalidPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new Point[0] };
|
||||
yield return new object[] { Array.Empty<Point>() };
|
||||
yield return new object[] { new Point[1] { new(1, 1) } };
|
||||
yield return new object[] { new Point[2] { new(1, 1), new(2, 2) } };
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddClosedCurve_InvalidFloatPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new PointF[0] };
|
||||
yield return new object[] { Array.Empty<PointF>() };
|
||||
yield return new object[] { new PointF[1] { new(1f, 1f) } };
|
||||
yield return new object[] { new PointF[2] { new(1f, 1f), new(2f, 2f) } };
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddPolygon_InvalidFloadPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new PointF[0] };
|
||||
yield return new object[] { Array.Empty<PointF>() };
|
||||
yield return new object[] { new PointF[1] { new(1f, 1f) } };
|
||||
yield return new object[] { new PointF[2] { new(1f, 1f), new(2f, 2f) } };
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ public class GraphicsPathTests
|
|||
|
||||
public static IEnumerable<object[]> AddPolygon_InvalidPointsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new Point[0] };
|
||||
yield return new object[] { Array.Empty<Point>() };
|
||||
yield return new object[] { new Point[1] { new(1, 1) } };
|
||||
yield return new object[] { new Point[2] { new(1, 1), new(2, 2) } };
|
||||
}
|
||||
|
@ -2059,19 +2059,19 @@ public class GraphicsPathTests
|
|||
Assert.Equal(expectedTypes, actualTypes);
|
||||
}
|
||||
|
||||
private void AssertEmptyGraphicsPath(GraphicsPath gp)
|
||||
private static void AssertEmptyGraphicsPath(GraphicsPath gp)
|
||||
{
|
||||
Assert.Empty(gp.PathData.Points);
|
||||
Assert.Empty(gp.PathData.Types);
|
||||
Assert.Equal(0, gp.PointCount);
|
||||
}
|
||||
|
||||
private void AssertEqual(float expexted, float actual, float tollerance)
|
||||
private static void AssertEqual(float expexted, float actual, float tollerance)
|
||||
{
|
||||
AssertExtensions.LessThanOrEqualTo(Math.Abs(expexted - actual), tollerance);
|
||||
}
|
||||
|
||||
private void AssertLine(GraphicsPath path)
|
||||
private static void AssertLine(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2086,7 +2086,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 1 });
|
||||
}
|
||||
|
||||
private void AssertArc(GraphicsPath path)
|
||||
private static void AssertArc(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2102,7 +2102,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 3, 3, 3 });
|
||||
}
|
||||
|
||||
private void AssertBezier(GraphicsPath path)
|
||||
private static void AssertBezier(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2119,7 +2119,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 3, 3, 3 });
|
||||
}
|
||||
|
||||
private void AssertCurve(GraphicsPath path)
|
||||
private static void AssertCurve(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2135,7 +2135,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 3, 3, 3 });
|
||||
}
|
||||
|
||||
private void AssertClosedCurve(GraphicsPath path)
|
||||
private static void AssertClosedCurve(GraphicsPath path)
|
||||
{
|
||||
path.PathPoints.Should().HaveCount(10);
|
||||
path.PathTypes.Should().HaveCount(10);
|
||||
|
@ -2144,7 +2144,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 131 });
|
||||
}
|
||||
|
||||
private void AssertRectangle(GraphicsPath path)
|
||||
private static void AssertRectangle(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2161,7 +2161,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 1, 1, 129 });
|
||||
}
|
||||
|
||||
private void AssertEllipse(GraphicsPath path)
|
||||
private static void AssertEllipse(GraphicsPath path)
|
||||
{
|
||||
path.PathPoints.Should().HaveCount(13);
|
||||
path.PathTypes.Should().HaveCount(13);
|
||||
|
@ -2170,7 +2170,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131 });
|
||||
}
|
||||
|
||||
private void AssertPie(GraphicsPath path)
|
||||
private static void AssertPie(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2187,7 +2187,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 1, 3, 3, 131 });
|
||||
}
|
||||
|
||||
private void AssertPolygon(GraphicsPath path)
|
||||
private static void AssertPolygon(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2204,7 +2204,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 1, 129 });
|
||||
}
|
||||
|
||||
private void AssertFlats(GraphicsPath flat, GraphicsPath original)
|
||||
private static void AssertFlats(GraphicsPath flat, GraphicsPath original)
|
||||
{
|
||||
flat.PointCount.Should().BeGreaterThanOrEqualTo(original.PointCount);
|
||||
for (int i = 0; i < flat.PointCount; i++)
|
||||
|
@ -2213,7 +2213,7 @@ public class GraphicsPathTests
|
|||
}
|
||||
}
|
||||
|
||||
private void AssertWrapNaN(GraphicsPath path)
|
||||
private static void AssertWrapNaN(GraphicsPath path)
|
||||
{
|
||||
byte[] expectedTypes = [0, 1, 129];
|
||||
|
||||
|
@ -2227,7 +2227,7 @@ public class GraphicsPathTests
|
|||
Assert.Equal(expectedTypes, path.PathTypes);
|
||||
}
|
||||
|
||||
private void AssertWiden3(GraphicsPath path)
|
||||
private static void AssertWiden3(GraphicsPath path)
|
||||
{
|
||||
PointF[] expectedPoints =
|
||||
[
|
||||
|
@ -2242,7 +2242,7 @@ public class GraphicsPathTests
|
|||
path.PathTypes.Should().BeEquivalentTo(new byte[] { 0, 1, 129, 0, 1, 1, 1, 1, 129 });
|
||||
}
|
||||
|
||||
private void AssertIsOutlineVisibleLine(Graphics graphics)
|
||||
private static void AssertIsOutlineVisibleLine(Graphics graphics)
|
||||
{
|
||||
using GraphicsPath gp = new();
|
||||
using Pen pen = new(Color.Red, 3.0f);
|
||||
|
@ -2270,7 +2270,7 @@ public class GraphicsPathTests
|
|||
Assert.True(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
|
||||
}
|
||||
|
||||
private void AssertIsOutlineVisibleRectangle(Graphics graphics)
|
||||
private static void AssertIsOutlineVisibleRectangle(Graphics graphics)
|
||||
{
|
||||
using Pen pen = new(Color.Red, 3.0f);
|
||||
using GraphicsPath gp = new();
|
||||
|
@ -2298,7 +2298,7 @@ public class GraphicsPathTests
|
|||
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
|
||||
}
|
||||
|
||||
private void AssertIsVisibleRectangle(Graphics graphics)
|
||||
private static void AssertIsVisibleRectangle(Graphics graphics)
|
||||
{
|
||||
using GraphicsPath gp = new();
|
||||
gp.AddRectangle(new Rectangle(10, 10, 20, 20));
|
||||
|
@ -2319,7 +2319,7 @@ public class GraphicsPathTests
|
|||
Assert.False(gp.IsVisible(29.4f, 29.5f, graphics));
|
||||
}
|
||||
|
||||
private void AssertIsVisibleEllipse(Graphics graphics)
|
||||
private static void AssertIsVisibleEllipse(Graphics graphics)
|
||||
{
|
||||
using GraphicsPath gp = new();
|
||||
gp.AddEllipse(new Rectangle(10, 10, 20, 20));
|
||||
|
@ -2331,7 +2331,7 @@ public class GraphicsPathTests
|
|||
Assert.False(gp.IsVisible(29.4f, 29.4f, graphics));
|
||||
}
|
||||
|
||||
private void AssertReverse(GraphicsPath gp, PointF[] expectedPoints, byte[] expectedTypes)
|
||||
private static void AssertReverse(GraphicsPath gp, PointF[] expectedPoints, byte[] expectedTypes)
|
||||
{
|
||||
gp.Reverse();
|
||||
PointF[] reversedPoints = gp.PathPoints;
|
||||
|
|
|
@ -735,8 +735,8 @@ public partial class MatrixTests
|
|||
public void TransformPoints_EmptyPoints_ThrowsArgumentException()
|
||||
{
|
||||
using Matrix matrix = new();
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformPoints(new Point[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformPoints(new PointF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformPoints(Array.Empty<Point>()));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformPoints(Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -803,8 +803,8 @@ public partial class MatrixTests
|
|||
{
|
||||
using Matrix matrix = new();
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.VectorTransformPoints([]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformVectors(new Point[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformVectors(new PointF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformVectors(Array.Empty<Point>()));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => matrix.TransformVectors(Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -194,7 +194,7 @@ public class PathGradientBrushTests
|
|||
|
||||
public static IEnumerable<object[]> SurroundColors_InvalidColorsLength_TestData()
|
||||
{
|
||||
yield return new object[] { new Point[2] { new(1, 1), new(2, 2) }, new Color[0] };
|
||||
yield return new object[] { new Point[2] { new(1, 1), new(2, 2) }, Array.Empty<Color>() };
|
||||
yield return new object[] { new Point[2] { new(1, 1), new(2, 2) }, new Color[3] };
|
||||
}
|
||||
|
||||
|
|
|
@ -1879,8 +1879,8 @@ public partial class GraphicsTests
|
|||
{
|
||||
using Bitmap image = new(10, 10);
|
||||
using Graphics graphics = Graphics.FromImage(image);
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new PointF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, Array.Empty<Point>()));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2127,8 +2127,8 @@ public partial class GraphicsTests
|
|||
using Bitmap image = new(10, 10);
|
||||
using Graphics graphics = Graphics.FromImage(image);
|
||||
using Pen pen = new(Color.Red);
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawRectangles(pen, new Rectangle[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawRectangles(pen, new RectangleF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawRectangles(pen, Array.Empty<Rectangle>()));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawRectangles(pen, Array.Empty<RectangleF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -150,8 +150,8 @@ public class Graphics_DrawBezierTests : DrawingTest
|
|||
using Bitmap image = new(10, 10);
|
||||
using Graphics graphics = Graphics.FromImage(image);
|
||||
using Pen pen = new(Color.Red);
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawBeziers(pen, new Point[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawBeziers(pen, new PointF[0]));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawBeziers(pen, Array.Empty<Point>()));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => graphics.DrawBeziers(pen, Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -150,7 +150,7 @@ public class IconTests
|
|||
public static IEnumerable<object[]> Ctor_InvalidBytesInStream_TestData()
|
||||
{
|
||||
// No start entry.
|
||||
yield return new object[] { new byte[0], typeof(ArgumentException) };
|
||||
yield return new object[] { Array.Empty<byte>(), typeof(ArgumentException) };
|
||||
yield return new object[] { new byte[6], typeof(ArgumentException) };
|
||||
yield return new object[] { new byte[21], typeof(ArgumentException) };
|
||||
|
||||
|
@ -374,7 +374,7 @@ public class IconTests
|
|||
ExtractAssociatedIcon_FilePath_Success_Helper(bitmapUncPath);
|
||||
}
|
||||
|
||||
private void ExtractAssociatedIcon_FilePath_Success_Helper(string filePath)
|
||||
private static void ExtractAssociatedIcon_FilePath_Success_Helper(string filePath)
|
||||
{
|
||||
using Icon icon = Icon.ExtractAssociatedIcon(filePath);
|
||||
Assert.Equal(32, icon.Width);
|
||||
|
|
|
@ -161,7 +161,7 @@ public class ImageFormatConverterTest
|
|||
Assert.True(_imgFmtConv.GetStandardValuesSupported(null), "GetStandardValuesSupported(null)");
|
||||
}
|
||||
|
||||
private void CheckStandardValues(ICollection values)
|
||||
private static void CheckStandardValues(ICollection values)
|
||||
{
|
||||
bool memorybmp = false;
|
||||
bool bmp = false;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ColorMatrixTests
|
|||
get
|
||||
{
|
||||
yield return new object[] { null, typeof(NullReferenceException) };
|
||||
yield return new object[] { new float[][] { }, typeof(IndexOutOfRangeException) };
|
||||
yield return new object[] { Array.Empty<float[]>(), typeof(IndexOutOfRangeException) };
|
||||
yield return new object[] { new float[][] { [0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f] }, typeof(IndexOutOfRangeException) };
|
||||
yield return new object[]
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ public class EncoderParameterTests
|
|||
{
|
||||
private static readonly Encoder s_anyEncoder = Encoder.ChrominanceTable;
|
||||
|
||||
private void CheckEncoderParameter(EncoderParameter encoderParameter, Encoder expectedEncoder, EncoderParameterValueType expectedType, int expectedNumberOfValues)
|
||||
private static void CheckEncoderParameter(EncoderParameter encoderParameter, Encoder expectedEncoder, EncoderParameterValueType expectedType, int expectedNumberOfValues)
|
||||
{
|
||||
Assert.Equal(expectedEncoder.Guid, encoderParameter.Encoder.Guid);
|
||||
Assert.Equal(expectedType, encoderParameter.ValueType);
|
||||
|
@ -272,12 +272,12 @@ public class EncoderParameterTests
|
|||
yield return new object[] { new Action(() => new EncoderParameter(null, rangebegin: 0, rangeend: 0)) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, 0, 0, 0, 0)) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, "anyString")) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, new byte[] { })) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, Array.Empty<byte>())) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, [], false)) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, new short[] { })) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, new long[] { })) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, new int[] { }, [])) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, new long[] { }, [])) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, Array.Empty<short>())) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, Array.Empty<long>())) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, Array.Empty<int>(), [])) };
|
||||
yield return new object[] { new Action(() => new EncoderParameter(null, Array.Empty<long>(), [])) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,12 +291,12 @@ public class EncoderParameterTests
|
|||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, rangebegin: 0, rangeend: 0));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, 0, 0, 0, 0));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, "anyString"));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, new byte[] { }));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, Array.Empty<byte>()));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, [], false));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, new short[] { }));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, new long[] { }));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, new int[] { }, []));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, new long[] { }, []));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, Array.Empty<short>()));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, Array.Empty<long>()));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, Array.Empty<int>(), []));
|
||||
Assert.Throws<NullReferenceException>(() => new EncoderParameter(null, Array.Empty<long>(), []));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ImageCodecInfoTests
|
|||
}
|
||||
}
|
||||
|
||||
private void CheckImageCodecInfo(ImageFormat format, string CodecName, string DllName, string FilenameExtension, ImageCodecFlags Flags, string FormatDescription, string MimeType, int signatureLength, string mask, string pattern, string pattern2, ImageCodecInfo codecInfo)
|
||||
private static void CheckImageCodecInfo(ImageFormat format, string CodecName, string DllName, string FilenameExtension, ImageCodecFlags Flags, string FormatDescription, string MimeType, int signatureLength, string mask, string pattern, string pattern2, ImageCodecInfo codecInfo)
|
||||
{
|
||||
Regex extRegex = new(@"^(\*\.\w+(;(\*\.\w+))*;)?" +
|
||||
Regex.Escape(FilenameExtension) + @"(;\*\.\w+(;(\*\.\w+))*)?$",
|
||||
|
|
|
@ -927,7 +927,7 @@ public class MetafileTests
|
|||
metafile.PlayRecord(EmfPlusRecordType.BeginContainer, 0, 1, new byte[1]));
|
||||
}
|
||||
|
||||
private void DeleteFile(string path)
|
||||
private static void DeleteFile(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
|
@ -935,12 +935,12 @@ public class MetafileTests
|
|||
}
|
||||
}
|
||||
|
||||
private string GetPath(string fileName)
|
||||
private static string GetPath(string fileName)
|
||||
{
|
||||
return Helpers.GetTestBitmapPath(fileName);
|
||||
}
|
||||
|
||||
private void AssertEmfType(MetafileHeader metafileHeader, EmfType emfType)
|
||||
private static void AssertEmfType(MetafileHeader metafileHeader, EmfType emfType)
|
||||
{
|
||||
switch (emfType)
|
||||
{
|
||||
|
@ -970,7 +970,7 @@ public class MetafileTests
|
|||
}
|
||||
}
|
||||
|
||||
private void AssertMetafileHeaderIsBlank(MetafileHeader metafileHeader)
|
||||
private static void AssertMetafileHeaderIsBlank(MetafileHeader metafileHeader)
|
||||
{
|
||||
Assert.Equal(new Rectangle(0, 0, 0, 0), metafileHeader.Bounds);
|
||||
Assert.Equal(0, metafileHeader.MetafileSize);
|
||||
|
@ -985,7 +985,7 @@ public class MetafileTests
|
|||
Assert.Equal(GraphicsUnit.Pixel, graphicsUnit);
|
||||
}
|
||||
|
||||
private void AssertMetafileHeader(MetafileHeader header)
|
||||
private static void AssertMetafileHeader(MetafileHeader header)
|
||||
{
|
||||
Assert.Equal(MetafileType.WmfPlaceable, header.Type);
|
||||
Assert.Equal(0x300, header.Version);
|
||||
|
|
|
@ -64,7 +64,7 @@ public class PropertyItemTests
|
|||
{
|
||||
yield return new object[] { int.MaxValue, int.MaxValue, short.MaxValue, new byte[1] { 0 } };
|
||||
yield return new object[] { int.MinValue, int.MinValue, short.MinValue, new byte[2] { 1, 1 } };
|
||||
yield return new object[] { 0, 0, 0, new byte[0] };
|
||||
yield return new object[] { 0, 0, 0, Array.Empty<byte>() };
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -229,7 +229,7 @@ public class PrintDocumentTests : FileCleanupTestBase
|
|||
Assert.Equal(expected, document.ToString());
|
||||
}
|
||||
|
||||
private void AssertDefaultPageSettings(PageSettings pageSettings)
|
||||
private static void AssertDefaultPageSettings(PageSettings pageSettings)
|
||||
{
|
||||
// A4 and Letter are both common default sizes for systems to have.
|
||||
switch (pageSettings.PaperSize.Kind)
|
||||
|
|
|
@ -321,14 +321,14 @@ public class RegionTests
|
|||
{
|
||||
new Region(),
|
||||
new RectangleF[] { RectangleF.Empty },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
{
|
||||
new Region(),
|
||||
new RectangleF[] { new(1, 2, 3, 4) },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ public class RegionTests
|
|||
{
|
||||
new Region(new Rectangle(500, 30, 60, 80)),
|
||||
new RectangleF[] { new(500, 30, 60, 80) },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
|
@ -1067,14 +1067,14 @@ public class RegionTests
|
|||
{
|
||||
new Region(new Rectangle(0, 0, 0, 0)),
|
||||
new RectangleF[] { new(500, 30, 60, 80) },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
{
|
||||
new Region(new Rectangle(500, 30, 60, 80)),
|
||||
new RectangleF[] { RectangleF.Empty },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
|
@ -1088,7 +1088,7 @@ public class RegionTests
|
|||
{
|
||||
new Region(),
|
||||
new RectangleF[] { RectangleF.Empty },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
|
@ -1107,7 +1107,7 @@ public class RegionTests
|
|||
new(70, 360, 30, 50),
|
||||
new(80, 400, 30, 10)
|
||||
},
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1597,9 +1597,9 @@ public class RegionTests
|
|||
},
|
||||
new RectangleF[]
|
||||
{
|
||||
new (10, 20, 50, 50),
|
||||
new (100, 100, 60, 60),
|
||||
new (200, 200, 80, 80)
|
||||
new(10, 20, 50, 50),
|
||||
new(100, 100, 60, 60),
|
||||
new(200, 200, 80, 80)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1974,7 +1974,7 @@ public class RegionTests
|
|||
{
|
||||
new Region(new RectangleF(500, 30, 60, 80)),
|
||||
new RectangleF[] { new(500, 30, 60, 80) },
|
||||
new RectangleF[0]
|
||||
Array.Empty<RectangleF>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
|
|
|
@ -197,7 +197,7 @@ public class StringFormatTests
|
|||
|
||||
public static IEnumerable<object[]> SetMeasurableCharacterRanges_TestData()
|
||||
{
|
||||
yield return new object[] { new CharacterRange[0] };
|
||||
yield return new object[] { Array.Empty<CharacterRange>() };
|
||||
yield return new object[] { new CharacterRange[] { new(1, 2) } };
|
||||
yield return new object[] { new CharacterRange[] { new(-1, -1) } };
|
||||
yield return new object[] { new CharacterRange[32] };
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace System.Drawing.Tests
|
|||
{
|
||||
private static Size s_defaultSize = new(16, 16);
|
||||
|
||||
private void AssertDefaultSize(Image image)
|
||||
private static void AssertDefaultSize(Image image)
|
||||
{
|
||||
Assert.Equal(s_defaultSize, image.Size);
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ public class BmpCodecTest
|
|||
Assert.Equal(-9211799, bmp.GetPixel(160, 160).ToArgb());
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
private static void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.bmp";
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace MonoTests.System.Drawing.Imaging;
|
|||
public class GifCodecTest
|
||||
{
|
||||
/* Checks bitmap features on a known 1bbp bitmap */
|
||||
private void Bitmap8bitsFeatures(string filename)
|
||||
private static void Bitmap8bitsFeatures(string filename)
|
||||
{
|
||||
using Bitmap bmp = new(filename);
|
||||
GraphicsUnit unit = GraphicsUnit.World;
|
||||
|
@ -67,7 +67,7 @@ public class GifCodecTest
|
|||
Bitmap8bitsFeatures(Helpers.GetTestBitmapPath("nature24bits87.gif"));
|
||||
}
|
||||
|
||||
private void Bitmap8bitsPixels(string filename)
|
||||
private static void Bitmap8bitsPixels(string filename)
|
||||
{
|
||||
using Bitmap bmp = new(filename);
|
||||
// sampling values from a well known bitmap
|
||||
|
@ -175,7 +175,7 @@ public class GifCodecTest
|
|||
}
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected, bool exactColorCheck)
|
||||
private static void Save(PixelFormat original, PixelFormat expected, bool exactColorCheck)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.gif";
|
||||
|
||||
|
|
|
@ -1859,7 +1859,7 @@ public class IconCodecTest
|
|||
Assert.Equal(16, bmp.Size.Height);
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
private static void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.ico";
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ public class JpegCodecTest
|
|||
}
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected)
|
||||
private static void Save(PixelFormat original, PixelFormat expected)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.jpeg";
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ public class PngCodecTest
|
|||
}
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
private static void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.png";
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ public class TiffCodecTest
|
|||
}
|
||||
}
|
||||
|
||||
private void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
private static void Save(PixelFormat original, PixelFormat expected, bool colorCheck)
|
||||
{
|
||||
string sOutFile = $"linerect-{expected}.tif";
|
||||
|
||||
|
|
|
@ -292,16 +292,13 @@ public class BitmapTests
|
|||
{
|
||||
string sSub, sRslt;
|
||||
|
||||
if (Environment.GetEnvironmentVariable("MSNet") is null)
|
||||
sSub = "mono/";
|
||||
else
|
||||
sSub = "MSNet/";
|
||||
sSub = Environment.GetEnvironmentVariable("MSNet") is null ? "mono/" : "MSNet/";
|
||||
|
||||
sRslt = Path.GetFullPath(sSub);
|
||||
|
||||
if (!Directory.Exists(sRslt))
|
||||
{
|
||||
sRslt = "Test/System.Drawing/" + sSub;
|
||||
sRslt = $"Test/System.Drawing/{sSub}";
|
||||
}
|
||||
|
||||
if (sRslt.Length > 0)
|
||||
|
@ -389,7 +386,7 @@ public class BitmapTests
|
|||
}
|
||||
}
|
||||
|
||||
hash = SHA256.Create().ComputeHash(pixels);
|
||||
hash = SHA256.HashData(pixels);
|
||||
return ByteArrayToString(hash);
|
||||
}
|
||||
|
||||
|
@ -437,7 +434,7 @@ public class BitmapTests
|
|||
if (pixel_data is null)
|
||||
return "--ERROR--";
|
||||
|
||||
byte[] hash = SHA256.Create().ComputeHash(pixel_data);
|
||||
byte[] hash = SHA256.HashData(pixel_data);
|
||||
return ByteArrayToString(hash);
|
||||
}
|
||||
|
||||
|
@ -500,7 +497,7 @@ public class BitmapTests
|
|||
}
|
||||
}
|
||||
|
||||
return SHA256.Create().ComputeHash(pixels);
|
||||
return SHA256.HashData(pixels);
|
||||
}
|
||||
|
||||
private static byte[] HashLock(Bitmap bmp, int width, int height, PixelFormat fmt, ImageLockMode mode)
|
||||
|
@ -546,7 +543,7 @@ public class BitmapTests
|
|||
bmp.UnlockBits(bd);
|
||||
}
|
||||
|
||||
return SHA256.Create().ComputeHash(pixels);
|
||||
return SHA256.HashData(pixels);
|
||||
}
|
||||
|
||||
// Tests the LockBitmap functions. Makes a hash of the block of pixels that it returns
|
||||
|
|
|
@ -57,7 +57,7 @@ public class GraphicsTest : IDisposable
|
|||
_font?.Dispose();
|
||||
}
|
||||
|
||||
private bool IsEmptyBitmap(Bitmap bitmap, out int x, out int y)
|
||||
private static bool IsEmptyBitmap(Bitmap bitmap, out int x, out int y)
|
||||
{
|
||||
bool result = true;
|
||||
int empty = Color.Empty.ToArgb();
|
||||
|
@ -75,26 +75,24 @@ public class GraphicsTest : IDisposable
|
|||
return result;
|
||||
}
|
||||
|
||||
private void CheckForEmptyBitmap(Bitmap bitmap)
|
||||
private static void CheckForEmptyBitmap(Bitmap bitmap)
|
||||
{
|
||||
int x, y;
|
||||
if (!IsEmptyBitmap(bitmap, out x, out y))
|
||||
if (!IsEmptyBitmap(bitmap, out int x, out int y))
|
||||
Assert.Fail($"Position {x},{y}");
|
||||
}
|
||||
|
||||
private void CheckForNonEmptyBitmap(Bitmap bitmap)
|
||||
private static void CheckForNonEmptyBitmap(Bitmap bitmap)
|
||||
{
|
||||
int x, y;
|
||||
if (IsEmptyBitmap(bitmap, out x, out y))
|
||||
if (IsEmptyBitmap(bitmap, out int x, out int y))
|
||||
Assert.True(false);
|
||||
}
|
||||
|
||||
private void AssertEquals(string msg, object expected, object actual)
|
||||
private static void AssertEquals(string msg, object expected, object actual)
|
||||
{
|
||||
actual.Should().Be(expected, msg);
|
||||
}
|
||||
|
||||
private void AssertEquals(string msg, double expected, double actual, int precision)
|
||||
private static void AssertEquals(string msg, double expected, double actual, int precision)
|
||||
{
|
||||
actual.Should().BeApproximately(expected, precision, msg);
|
||||
}
|
||||
|
@ -366,7 +364,7 @@ public class GraphicsTest : IDisposable
|
|||
public void Dispose() { Graphics.Dispose(); _bitmap.Dispose(); }
|
||||
}
|
||||
|
||||
private void Compare(string msg, RectangleF b1, RectangleF b2)
|
||||
private static void Compare(string msg, RectangleF b1, RectangleF b2)
|
||||
{
|
||||
AssertEquals(msg + ".compare.X", b1.X, b2.X);
|
||||
AssertEquals(msg + ".compare.Y", b1.Y, b2.Y);
|
||||
|
@ -439,7 +437,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Throws<ArgumentException>(() => g.MultiplyTransform(matrix));
|
||||
}
|
||||
|
||||
private void CheckBounds(string msg, RectangleF bounds, float x, float y, float w, float h)
|
||||
private static void CheckBounds(string msg, RectangleF bounds, float x, float y, float w, float h)
|
||||
{
|
||||
AssertEquals(msg + ".X", x, bounds.X, 1);
|
||||
AssertEquals(msg + ".Y", y, bounds.Y, 1);
|
||||
|
@ -904,7 +902,7 @@ public class GraphicsTest : IDisposable
|
|||
bitmap.Dispose();
|
||||
}
|
||||
|
||||
private void CheckDefaultProperties(string message, Graphics g)
|
||||
private static void CheckDefaultProperties(string message, Graphics g)
|
||||
{
|
||||
Assert.True(g.Clip.IsInfinite(g), message + ".Clip.IsInfinite");
|
||||
AssertEquals(message + ".CompositingMode", CompositingMode.SourceOver, g.CompositingMode);
|
||||
|
@ -919,7 +917,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.True(g.Transform.IsIdentity, message + ".Transform.IsIdentity");
|
||||
}
|
||||
|
||||
private void CheckCustomProperties(string message, Graphics g)
|
||||
private static void CheckCustomProperties(string message, Graphics g)
|
||||
{
|
||||
Assert.False(g.Clip.IsInfinite(g), message + ".Clip.IsInfinite");
|
||||
AssertEquals(message + ".CompositingMode", CompositingMode.SourceCopy, g.CompositingMode);
|
||||
|
@ -935,7 +933,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.False(g.Transform.IsIdentity, message + ".Transform.IsIdentity");
|
||||
}
|
||||
|
||||
private void CheckMatrix(string message, Matrix m, float xx, float yx, float xy, float yy, float x0, float y0)
|
||||
private static void CheckMatrix(string message, Matrix m, float xx, float yx, float xy, float yy, float x0, float y0)
|
||||
{
|
||||
float[] elements = m.Elements;
|
||||
AssertEquals(message + ".Matrix.xx", xx, elements[0], 2);
|
||||
|
@ -1046,7 +1044,7 @@ public class GraphicsTest : IDisposable
|
|||
CheckCustomProperties("EndContainer", g);
|
||||
}
|
||||
|
||||
private void BeginContainer_GraphicsUnit(GraphicsUnit unit)
|
||||
private static void BeginContainer_GraphicsUnit(GraphicsUnit unit)
|
||||
{
|
||||
using Bitmap bitmap = new(20, 20);
|
||||
using Graphics g = Graphics.FromImage(bitmap);
|
||||
|
@ -1158,7 +1156,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bitmap = new(20, 20);
|
||||
using Graphics g = Graphics.FromImage(bitmap);
|
||||
Assert.Throws<ArgumentException>(() => g.FillRectangles(Brushes.Red, new Rectangle[0]));
|
||||
Assert.Throws<ArgumentException>(() => g.FillRectangles(Brushes.Red, Array.Empty<Rectangle>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -1182,7 +1180,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bitmap = new(20, 20);
|
||||
using Graphics g = Graphics.FromImage(bitmap);
|
||||
Assert.Throws<ArgumentException>(() => g.FillRectangles(Brushes.Red, new RectangleF[0]));
|
||||
Assert.Throws<ArgumentException>(() => g.FillRectangles(Brushes.Red, Array.Empty<RectangleF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -1207,7 +1205,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Equal(Color.Fuchsia.ToArgb(), bitmap.GetPixel(15, 15).ToArgb());
|
||||
}
|
||||
|
||||
private Bitmap FillDrawRectangle(float width)
|
||||
private static Bitmap FillDrawRectangle(float width)
|
||||
{
|
||||
Bitmap bitmap = new(20, 20);
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
|
@ -1371,7 +1369,7 @@ public class GraphicsTest : IDisposable
|
|||
}
|
||||
|
||||
// reverse, draw the fill over
|
||||
private Bitmap DrawFillRectangle(float width)
|
||||
private static Bitmap DrawFillRectangle(float width)
|
||||
{
|
||||
Bitmap bitmap = new(20, 20);
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
|
@ -1517,7 +1515,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Equal(0xFF008000, (uint)bitmap.GetPixel(5, 9).ToArgb());
|
||||
}
|
||||
|
||||
private Bitmap DrawLines(float width)
|
||||
private static Bitmap DrawLines(float width)
|
||||
{
|
||||
Bitmap bitmap = new(20, 20);
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
|
@ -1783,9 +1781,8 @@ public class GraphicsTest : IDisposable
|
|||
string s = "aaa aa aaaa a aaa";
|
||||
SizeF size = useSpan ? g.MeasureString(s.AsSpan(), _font) : g.MeasureString(s, _font);
|
||||
|
||||
int chars, lines;
|
||||
SizeF size2 = useSpan
|
||||
? g.MeasureString(s.AsSpan(), _font, new SizeF(80, size.Height), null, out chars, out lines)
|
||||
? g.MeasureString(s.AsSpan(), _font, new SizeF(80, size.Height), null, out int chars, out int lines)
|
||||
: g.MeasureString(s, _font, new SizeF(80, size.Height), null, out chars, out lines);
|
||||
|
||||
// in pixels
|
||||
|
@ -2006,7 +2003,7 @@ public class GraphicsTest : IDisposable
|
|||
|
||||
private static readonly CharacterRange[] s_ranges = [new(0, 1), new(1, 1), new(2, 1)];
|
||||
|
||||
private Region[] Measure_Helper(Graphics gfx, RectangleF rect, bool useSpan)
|
||||
private static Region[] Measure_Helper(Graphics gfx, RectangleF rect, bool useSpan)
|
||||
{
|
||||
using StringFormat format = StringFormat.GenericTypographic;
|
||||
format.SetMeasurableCharacterRanges(s_ranges);
|
||||
|
@ -2437,7 +2434,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bmp = new(40, 40);
|
||||
using Graphics g = Graphics.FromImage(bmp);
|
||||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, new PointF[0]));
|
||||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2453,7 +2450,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bmp = new(40, 40);
|
||||
using Graphics g = Graphics.FromImage(bmp);
|
||||
Assert.Throws<ArgumentException>(() => g.DrawImage(bmp, new PointF[0]));
|
||||
Assert.Throws<ArgumentException>(() => g.DrawImage(bmp, Array.Empty<PointF>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2511,7 +2508,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bmp = new(40, 40);
|
||||
using Graphics g = Graphics.FromImage(bmp);
|
||||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, new Point[0]));
|
||||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, Array.Empty<Point>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2527,7 +2524,7 @@ public class GraphicsTest : IDisposable
|
|||
{
|
||||
using Bitmap bmp = new(40, 40);
|
||||
using Graphics g = Graphics.FromImage(bmp);
|
||||
Assert.Throws<ArgumentException>(() => g.DrawImage(bmp, new Point[0]));
|
||||
Assert.Throws<ArgumentException>(() => g.DrawImage(bmp, Array.Empty<Point>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2594,7 +2591,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, default(Rectangle), default, GraphicsUnit.Display));
|
||||
}
|
||||
|
||||
private void DrawImage_ImageRectangleRectangleGraphicsUnit(GraphicsUnit unit)
|
||||
private static void DrawImage_ImageRectangleRectangleGraphicsUnit(GraphicsUnit unit)
|
||||
{
|
||||
using Bitmap bmp = new(40, 40);
|
||||
using Graphics g = Graphics.FromImage(bmp);
|
||||
|
@ -2631,7 +2628,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, pts, r, GraphicsUnit.Pixel));
|
||||
}
|
||||
|
||||
private void DrawImage_ImagePointRectangleGraphicsUnit(Point[] pts)
|
||||
private static void DrawImage_ImagePointRectangleGraphicsUnit(Point[] pts)
|
||||
{
|
||||
Rectangle r = new(1, 2, 3, 4);
|
||||
using Bitmap bmp = new(40, 40);
|
||||
|
@ -2689,7 +2686,7 @@ public class GraphicsTest : IDisposable
|
|||
Assert.Throws<ArgumentNullException>(() => g.DrawImage(null, pts, r, GraphicsUnit.Pixel));
|
||||
}
|
||||
|
||||
private void DrawImage_ImagePointFRectangleGraphicsUnit(PointF[] pts)
|
||||
private static void DrawImage_ImagePointFRectangleGraphicsUnit(PointF[] pts)
|
||||
{
|
||||
Rectangle r = new(1, 2, 3, 4);
|
||||
using Bitmap bmp = new(40, 40);
|
||||
|
|
|
@ -185,7 +185,7 @@ public class MetafileTest
|
|||
|
||||
public class MetafileFulltrustTest
|
||||
{
|
||||
private void CheckEmptyHeader(Metafile mf, EmfType type)
|
||||
private static void CheckEmptyHeader(Metafile mf, EmfType type)
|
||||
{
|
||||
MetafileHeader mh = mf.GetMetafileHeader();
|
||||
Assert.Equal(0, mh.Bounds.X);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<LangVersion>Preview</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<IsAnalyzerProject>true</IsAnalyzerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<NoWarn>$(NoWarn);CA1812</NoWarn>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<IsAnalyzerProject>true</IsAnalyzerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<RootNamespace></RootNamespace>
|
||||
<LangVersion>15.5</LangVersion>
|
||||
<NoWarn>$(NoWarn);CA1812</NoWarn>
|
||||
<IsAnalyzerProject>true</IsAnalyzerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<RootNamespace></RootNamespace>
|
||||
<LangVersion>15.5</LangVersion>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<IsAnalyzerProject>true</IsAnalyzerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<LangVersion>Preview</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<IsAnalyzerProject>true</IsAnalyzerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче