Enable nullability for Robust.Shared.Maths

This commit is contained in:
Pieter-Jan Briers
2020-01-22 23:56:13 +01:00
parent 766e2c81e2
commit 9b8c122f03
16 changed files with 20 additions and 20 deletions

View File

@@ -152,7 +152,7 @@ namespace Robust.Shared.Maths
}
/// <inheritdoc />
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is Angle angle && Equals(angle);

View File

@@ -173,7 +173,7 @@ namespace Robust.Shared.Maths
Bottom.Equals(other.Bottom);
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is null) return false;
return obj is Box2 box2 && Equals(box2);

View File

@@ -66,7 +66,7 @@ namespace Robust.Shared.Maths
}
/// <inheritdoc />
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is Box2Rotated other && Equals(other);

View File

@@ -79,7 +79,7 @@ namespace Robust.Shared.Maths
}
// override object.Equals
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is Box2i box)
{

View File

@@ -79,7 +79,7 @@ namespace Robust.Shared.Maths
}
/// <inheritdoc />
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is Circle circle && Equals(circle);

View File

@@ -185,7 +185,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">An object to compare to.</param>
/// <returns>True obj is a Color4 structure with the same components as this Color4; false otherwise.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (!(obj is Color))
return false;
@@ -1817,8 +1817,7 @@ namespace Robust.Shared.Maths
private static readonly Dictionary<Color, string> DefaultColorsInverted =
DefaultColors.ToLookup(pair => pair.Value).ToDictionary(i => i.Key, i => i.First().Key);
[CanBeNull]
public string Name()
public string? Name()
{
return DefaultColorsInverted.TryGetValue(this, out var name) ? name : null;
}

View File

@@ -1094,7 +1094,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">The object to compare with this matrix.</param>
/// <returns>True if the instances are equal; false otherwise.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (!(obj is Matrix4))
return false;

View File

@@ -822,12 +822,12 @@ namespace Robust.Shared.Maths
/// <summary>
/// Compares this object instance to another object for equality.
/// </summary>
/// <param name="other">The other object to be used in the comparison.</param>
/// <param name="obj">The other object to be used in the comparison.</param>
/// <returns>True if both objects are Quaternions of equal value. Otherwise it returns false.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is Quaternion == false) return false;
return this == (Quaternion) obj;
if (obj is Quaternion quaternion) return this == quaternion;
return false;
}
#endregion public override bool Equals (object o)

View File

@@ -10,6 +10,7 @@
<Configurations>Debug;Release</Configurations>
<Platforms>x64</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
<Import Project="..\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup>

View File

@@ -126,7 +126,7 @@ namespace Robust.Shared.Maths
Bottom.Equals(other.Bottom);
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is null) return false;
return obj is UIBox2 box2 && Equals(box2);

View File

@@ -88,7 +88,7 @@ namespace Robust.Shared.Maths
}
// override object.Equals
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is UIBox2i box)
{

View File

@@ -302,7 +302,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">Other object to check.</param>
/// <returns>True if Object and vector are equal.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is Vector2 vec && Equals(vec);
}

View File

@@ -58,7 +58,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">Other object to check.</param>
/// <returns>True if Object and vector are equal.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is Vector2i && Equals((Vector2i) obj);

View File

@@ -51,7 +51,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">Other object to check.</param>
/// <returns>True if Object and vector are equal.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is Vector2u vec && Equals(vec);

View File

@@ -1086,7 +1086,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">The object to compare to.</param>
/// <returns>True if the instances are equal; false otherwise.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (!(obj is Vector3))
return false;

View File

@@ -876,7 +876,7 @@ namespace Robust.Shared.Maths
/// </summary>
/// <param name="obj">The object to compare to.</param>
/// <returns>True if the instances are equal; false otherwise.</returns>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (!(obj is Vector4))
return false;