1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 23:58:48 +00:00

Fix CA1602 violations

This commit is contained in:
Oliver Booth 2022-11-29 17:12:39 +00:00
parent 398b0c58b1
commit deb1f2edd8
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
3 changed files with 26 additions and 22 deletions

View File

@ -1,4 +1,4 @@
using System.Drawing;
using System.Drawing;
namespace X10D.Drawing;
@ -20,7 +20,7 @@ public class Polygon : IEquatable<Polygon>
/// Initializes a new instance of the <see cref="Polygon" /> class by copying the specified polygon.
/// </summary>
public Polygon(Polygon polygon)
: this(polygon._vertices)
: this(polygon?._vertices ?? throw new ArgumentNullException(nameof(polygon)))
{
}
@ -114,9 +114,9 @@ public class Polygon : IEquatable<Polygon>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static bool operator ==(Polygon left, Polygon right)
public static bool operator ==(Polygon? left, Polygon? right)
{
return left.Equals(right);
return Equals(left, right);
}
/// <summary>
@ -130,7 +130,7 @@ public class Polygon : IEquatable<Polygon>
/// </returns>
public static bool operator !=(Polygon left, Polygon right)
{
return !left.Equals(right);
return !(left == right);
}
/// <summary>
@ -223,9 +223,9 @@ public class Polygon : IEquatable<Polygon>
/// <see langword="true" /> if this instance and <paramref name="other" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public bool Equals(Polygon other)
public bool Equals(Polygon? other)
{
return _vertices.SequenceEqual(other._vertices);
return other is not null && _vertices.SequenceEqual(other._vertices);
}
/// <inheritdoc />

View File

@ -21,8 +21,9 @@ public class PolygonF
/// <summary>
/// Initializes a new instance of the <see cref="PolygonF" /> class by copying the specified polygon.
/// </summary>
/// <exception cref="ArgumentNullException"><paramref name="polygon" /> is <see langword="null" />.</exception>
public PolygonF(PolygonF polygon)
: this(polygon._vertices)
: this(polygon?._vertices ?? throw new ArgumentNullException(nameof(polygon)))
{
}
@ -30,6 +31,7 @@ public class PolygonF
/// Initializes a new instance of the <see cref="PolygonF" /> class by constructing it from the specified vertices.
/// </summary>
/// <param name="vertices">An enumerable collection of vertices from which the polygon should be constructed.</param>
/// <exception cref="ArgumentNullException"><paramref name="vertices" /> is <see langword="null" />.</exception>
public PolygonF(IEnumerable<Vector2> vertices)
: this(vertices.Select(p => p.ToPointF()))
{
@ -143,9 +145,9 @@ public class PolygonF
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static bool operator ==(PolygonF left, PolygonF right)
public static bool operator ==(PolygonF? left, PolygonF? right)
{
return left.Equals(right);
return Equals(left, right);
}
/// <summary>
@ -157,9 +159,9 @@ public class PolygonF
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static bool operator !=(PolygonF left, PolygonF right)
public static bool operator !=(PolygonF? left, PolygonF? right)
{
return !left.Equals(right);
return !(left == right);
}
/// <summary>
@ -283,9 +285,9 @@ public class PolygonF
/// <see langword="true" /> if this instance and <paramref name="other" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public bool Equals(PolygonF other)
public bool Equals(PolygonF? other)
{
return _vertices.SequenceEqual(other._vertices);
return other is not null && _vertices.SequenceEqual(other._vertices);
}
/// <inheritdoc />

View File

@ -1,4 +1,4 @@
using System.Drawing;
using System.Drawing;
using System.Numerics;
namespace X10D.Drawing;
@ -20,8 +20,9 @@ public class Polyhedron : IEquatable<Polyhedron>
/// <summary>
/// Initializes a new instance of the <see cref="Polyhedron" /> class by copying the specified polyhedron.
/// </summary>
/// <exception cref="ArgumentNullException"><paramref name="polyhedron" /> is <see langword="null" />.</exception>
public Polyhedron(Polyhedron polyhedron)
: this(polyhedron._vertices)
: this(polyhedron?._vertices ?? throw new ArgumentNullException(nameof(polyhedron)))
{
}
@ -29,6 +30,7 @@ public class Polyhedron : IEquatable<Polyhedron>
/// Initializes a new instance of the <see cref="Polyhedron" /> class by constructing it from the specified vertices.
/// </summary>
/// <param name="vertices">An enumerable collection of vertices from which the polyhedron should be constructed.</param>
/// <exception cref="ArgumentNullException"><paramref name="vertices" /> is <see langword="null" />.</exception>
public Polyhedron(IEnumerable<Vector3> vertices)
{
#if NET6_0_OR_GREATER
@ -112,9 +114,9 @@ public class Polyhedron : IEquatable<Polyhedron>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static bool operator ==(Polyhedron left, Polyhedron right)
public static bool operator ==(Polyhedron? left, Polyhedron? right)
{
return left.Equals(right);
return Equals(left, right);
}
/// <summary>
@ -126,9 +128,9 @@ public class Polyhedron : IEquatable<Polyhedron>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />.
/// </returns>
public static bool operator !=(Polyhedron left, Polyhedron right)
public static bool operator !=(Polyhedron? left, Polyhedron? right)
{
return !left.Equals(right);
return !(left == right);
}
/// <summary>
@ -262,9 +264,9 @@ public class Polyhedron : IEquatable<Polyhedron>
/// <see langword="true" /> if this instance and <paramref name="other" /> are considered equal; otherwise,
/// <see langword="false" />.
/// </returns>
public bool Equals(Polyhedron other)
public bool Equals(Polyhedron? other)
{
return _vertices.SequenceEqual(other._vertices);
return other is not null && _vertices.SequenceEqual(other._vertices);
}
/// <inheritdoc />