Skip to content

Commit 34a8fb1

Browse files
author
Dirk Lemstra
committed
Use Asserts instead of null checks because this class is internal.
1 parent 6721f61 commit 34a8fb1

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Source/Magick.NET/Core/Drawables/DrawingWand.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17+
using System.Diagnostics;
18+
using System.Diagnostics.CodeAnalysis;
1719
using System.Text;
1820

1921
namespace ImageMagick
@@ -100,8 +102,8 @@ public void Density(PointD value)
100102

101103
public void Dispose()
102104
{
103-
if (_NativeInstance != null)
104-
_NativeInstance.Dispose();
105+
Debug.Assert(_NativeInstance != null);
106+
_NativeInstance.Dispose();
105107
}
106108

107109
public void Ellipse(double originX, double originY, double radiusX, double radiusY, double startDegrees, double endDegrees)
@@ -154,21 +156,21 @@ public void Line(double startX, double startY, double endX, double endY)
154156
_NativeInstance.Line(startX, startY, endX, endY);
155157
}
156158

159+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Using assert instead.")]
157160
public void PathArcAbs(IEnumerable<PathArc> pathArcs)
158161
{
159-
if (pathArcs == null)
160-
return;
162+
Debug.Assert(pathArcs != null);
161163

162164
foreach (PathArc pathArc in pathArcs)
163165
{
164166
_NativeInstance.PathArcAbs(pathArc.X, pathArc.Y, pathArc.RadiusX, pathArc.RadiusY, pathArc.RotationX, pathArc.UseLargeArc, pathArc.UseSweep);
165167
}
166168
}
167169

170+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Using assert instead.")]
168171
public void PathArcRel(IEnumerable<PathArc> pathArcs)
169172
{
170-
if (pathArcs == null)
171-
return;
173+
Debug.Assert(pathArcs != null);
172174

173175
foreach (PathArc pathArc in pathArcs)
174176
{
@@ -196,10 +198,10 @@ public void PathFinish()
196198
_NativeInstance.PathFinish();
197199
}
198200

201+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Using assert instead.")]
199202
public void PathLineToAbs(IEnumerable<PointD> coordinates)
200203
{
201-
if (coordinates == null)
202-
return;
204+
Debug.Assert(coordinates != null);
203205

204206
foreach (PointD coordinate in coordinates)
205207
{
@@ -227,10 +229,10 @@ public void PathLineToVerticalAbs(double y)
227229
_NativeInstance.PathLineToVerticalAbs(y);
228230
}
229231

232+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Using assert instead.")]
230233
public void PathLineToRel(IEnumerable<PointD> coordinates)
231234
{
232-
if (coordinates == null)
233-
return;
235+
Debug.Assert(coordinates != null);
234236

235237
foreach (PointD coordinate in coordinates)
236238
{
@@ -290,8 +292,7 @@ public void Point(double x, double y)
290292

291293
public void Polygon(IList<PointD> coordinates)
292294
{
293-
if (coordinates == null)
294-
return;
295+
Debug.Assert(coordinates != null);
295296

296297
using (PointInfoCollection pointInfo = new PointInfoCollection(coordinates))
297298
{
@@ -301,8 +302,7 @@ public void Polygon(IList<PointD> coordinates)
301302

302303
public void Polyline(IList<PointD> coordinates)
303304
{
304-
if (coordinates == null)
305-
return;
305+
Debug.Assert(coordinates != null);
306306

307307
using (PointInfoCollection pointInfo = new PointInfoCollection(coordinates))
308308
{
@@ -380,10 +380,12 @@ public void StrokeColor(MagickColor color)
380380
_NativeInstance.StrokeColor(color);
381381
}
382382

383+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Using assert instead.")]
383384
public void StrokeDashArray(double[] dash)
384385
{
385-
if (dash != null)
386-
_NativeInstance.StrokeDashArray(dash, dash.Length);
386+
Debug.Assert(dash != null);
387+
388+
_NativeInstance.StrokeDashArray(dash, dash.Length);
387389
}
388390

389391
public void StrokeDashOffset(double value)

0 commit comments

Comments
 (0)