From 1891d9caec0844d54dcc9d05a57a3077edfcb134 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sun, 11 Aug 2019 15:52:05 +1000 Subject: [PATCH] remove unused variables and methods (#963) * remove unused variables and methods * remove some redundant variables * remove some redundant variables * redundant variables * Update DrawTextOnImageTests.cs * Minor optimizations * cleanup --- .../Drawing/Paths/DrawPathCollection.cs | 10 +++++----- tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs | 10 +++++----- .../Drawing/Paths/FillPathCollection.cs | 10 +++++----- .../Drawing/Paths/FillPolygon.cs | 10 +++++----- tests/ImageSharp.Tests/Drawing/Text/DrawText.cs | 16 ++++------------ .../Drawing/Text/DrawTextOnImageTests.cs | 12 ++++-------- tests/ImageSharp.Tests/ImageOperationTests.cs | 4 ++-- 7 files changed, 30 insertions(+), 42 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs index 5ab7894355..ee95bc743b 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -50,7 +50,7 @@ public void CorrectlySetsBrushAndPath() ShapePath region = Assert.IsType(processor.Region); // path is converted to a polygon before filling - ComplexPolygon polygon = Assert.IsType(region.Shape); + Assert.IsType(region.Shape); Assert.Equal(this.pen.StrokeFill, processor.Brush); } @@ -68,7 +68,7 @@ public void CorrectlySetsBrushPathOptions() Assert.Equal(this.noneDefault, processor.Options); ShapePath region = Assert.IsType(processor.Region); - ComplexPolygon polygon = Assert.IsType(region.Shape); + Assert.IsType(region.Shape); Assert.Equal(this.pen.StrokeFill, processor.Brush); } @@ -86,7 +86,7 @@ public void CorrectlySetsColorAndPath() Assert.Equal(GraphicsOptions.Default, processor.Options); ShapePath region = Assert.IsType(processor.Region); - ComplexPolygon polygon = Assert.IsType(region.Shape); + Assert.IsType(region.Shape); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); @@ -105,7 +105,7 @@ public void CorrectlySetsColorPathAndOptions() Assert.Equal(this.noneDefault, processor.Options); ShapePath region = Assert.IsType(processor.Region); - ComplexPolygon polygon = Assert.IsType(region.Shape); + Assert.IsType(region.Shape); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index d65dcd8c64..d12441ac2f 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -35,7 +35,7 @@ public void CorrectlySetsBrushAndPath() // path is converted to a polygon before filling Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -50,7 +50,7 @@ public void CorrectlySetsBrushPathOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -65,7 +65,7 @@ public void CorrectlySetsColorAndPath() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); @@ -81,7 +81,7 @@ public void CorrectlySetsColorPathAndOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs index 1f8e2d423d..17bb7e6ee5 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -51,7 +51,7 @@ public void CorrectlySetsBrushAndPath() // path is converted to a polygon before filling Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -70,7 +70,7 @@ public void CorrectlySetsBrushPathOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -89,7 +89,7 @@ public void CorrectlySetsColorAndPath() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); @@ -109,7 +109,7 @@ public void CorrectlySetsColorPathAndOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index 5af14d6088..22b741ec1e 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -35,7 +35,7 @@ public void CorrectlySetsBrushAndPath() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segment = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -50,7 +50,7 @@ public void CorrectlySetsBrushPathAndOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segment = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); } @@ -66,7 +66,7 @@ public void CorrectlySetsColorAndPath() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segment = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); @@ -82,7 +82,7 @@ public void CorrectlySetsColorPathAndOptions() ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); - LinearLineSegment segment = Assert.IsType(polygon.LineSegments[0]); + Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType(processor.Brush); Assert.Equal(this.color, brush.Color); diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index 572a870a4c..181ec9b9d7 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -14,14 +14,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text { public class DrawText : BaseImageOperationsExtensionTest { - Rgba32 color = Color.HotPink; - - SolidBrush brush = Brushes.Solid(Color.HotPink); - - IPath path = new SixLabors.Shapes.Path( - new LinearLineSegment( - new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), })); - private readonly FontCollection FontCollection; private readonly Font Font; @@ -103,7 +95,7 @@ public void DrawForEachACharacterWhenPenSetAndNotBrush() Pens.Dash(Color.Red, 1), Vector2.Zero); - var processor = this.Verify(0); + this.Verify(0); } [Fact] @@ -111,7 +103,7 @@ public void DrawForEachACharacterWhenPenSetAndNotBrushDefaultOptions() { this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); - var processor = this.Verify(0); + this.Verify(0); } [Fact] @@ -119,7 +111,7 @@ public void DrawForEachACharacterWhenPenSet() { this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero); - var processor = this.Verify(0); + this.Verify(0); } [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs index ebd9cf6448..73a1114d37 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -41,21 +41,17 @@ public void DoesntThrowExceptionWhenOverlappingRightEdge_Issue688(TestIm { Font font = CreateFont("OpenSans-Regular.ttf", 36); Color color = Color.Black; - float padding = 5; var text = "A short piece of text"; using (var img = provider.GetImage()) { - float targetWidth = img.Width - (padding * 2); - float targetHeight = img.Height - (padding * 2); - // measure the text size SizeF size = TextMeasurer.Measure(text, new RendererOptions(font)); //find out how much we need to scale the text to fill the space (up or down) float scalingFactor = Math.Min(img.Width / size.Width, img.Height / size.Height); - //create a new font + //create a new font Font scaledFont = new Font(font, scalingFactor * font.Size); var center = new PointF(img.Width / 2, img.Height / 2); @@ -64,7 +60,7 @@ public void DoesntThrowExceptionWhenOverlappingRightEdge_Issue688(TestIm HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; - + img.Mutate(i => i.DrawText(textGraphicOptions, text, scaledFont, color, center)); } } @@ -241,6 +237,6 @@ private static Font CreateFont(string fontName, int size) return font; } - + } } diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index 455e2c5f1b..7f8b133758 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -83,7 +83,7 @@ public void CloneCallsImageOperationsProvider_ListOfProcessors_WithDuplicateImag [Fact] public void CloneCallsImageOperationsProvider_Func_NotOnOriginal() { - Image returned = this.image.Clone(x => x.ApplyProcessor(this.processorDefinition)); + this.image.Clone(x => x.ApplyProcessor(this.processorDefinition)); Assert.False(this.provider.HasCreated(this.image)); Assert.DoesNotContain( this.processorDefinition, @@ -93,7 +93,7 @@ public void CloneCallsImageOperationsProvider_Func_NotOnOriginal() [Fact] public void CloneCallsImageOperationsProvider_ListOfProcessors_NotOnOriginal() { - Image returned = this.image.Clone(this.processorDefinition); + this.image.Clone(this.processorDefinition); Assert.False(this.provider.HasCreated(this.image)); Assert.DoesNotContain( this.processorDefinition,