Skip to content

Nullability #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Maths/Silk.NET.Maths/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System;

[assembly: CLSCompliant(true)]
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Box2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Box2<T> Inflate(Vector2<T> point)
public bool Equals(Box2<T> other)
=> this == other;

public override bool Equals(object obj)
public override bool Equals(object? obj)
=> obj is Box2<T> box && Equals(box);

public override int GetHashCode()
Expand All @@ -92,9 +92,9 @@ public override int GetHashCode()

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
var sb = new StringBuilder();
sb.Append(Min.ToString(format, formatProvider));
Expand Down
7 changes: 4 additions & 3 deletions src/Maths/Silk.NET.Maths/Box3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// of the MIT license. See the LICENSE file for details.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;

Expand Down Expand Up @@ -81,7 +82,7 @@ public Box3<T> Inflate(Vector3<T> point)
public bool Equals(Box3<T> other)
=> this == other;

public override bool Equals(object obj)
public override bool Equals(object? obj)
=> obj is Box3<T> box && Equals(box);

public override int GetHashCode()
Expand All @@ -95,9 +96,9 @@ public override int GetHashCode()

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
var sb = new StringBuilder();
sb.Append(Min.ToString(format, formatProvider));
Expand Down
28 changes: 17 additions & 11 deletions src/Maths/Silk.NET.Maths/Half.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is part of Silk.NET.
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.
Expand Down Expand Up @@ -245,7 +245,7 @@ public static bool IsSubnormal(Half value)
}

public static Half Parse
(string s, NumberStyles style = DefaultParseStyle, IFormatProvider formatProvider = null)
(string s, NumberStyles style = DefaultParseStyle, IFormatProvider? formatProvider = null)
{
if (s is null)
{
Expand All @@ -256,7 +256,7 @@ public static Half Parse
}

public static Half Parse
(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider formatProvider = null)
(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider? formatProvider = null)
{
throw new NotImplementedException();
}
Expand All @@ -271,13 +271,13 @@ public static bool TryParse(ReadOnlySpan<char> s, out Half result)
return TryParse(s, DefaultParseStyle, null, out result);
}

public static bool TryParse(string s, NumberStyles style, IFormatProvider formatProvider, out Half result)
public static bool TryParse(string s, NumberStyles style, IFormatProvider? formatProvider, out Half result)
{
return TryParse(s.AsSpan(), style, formatProvider, out result);
}

public static bool TryParse
(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider formatProvider, out Half result)
(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? formatProvider, out Half result)
{
throw new NotImplementedException();
}
Expand All @@ -303,7 +303,7 @@ private static ushort StripSign(Half value)
return (ushort) (value.m_value & ~SignMask);
}

public int CompareTo(object obj)
public int CompareTo(object? obj)
{
if (!(obj is Half))
{
Expand Down Expand Up @@ -339,7 +339,7 @@ public int CompareTo(Half other)
return 1;
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is Half && Equals((Half) obj);
}
Expand Down Expand Up @@ -367,15 +367,15 @@ public override string ToString()
// TODO: Implement this
}

public string ToString(string format = null, IFormatProvider formatProvider = null)
public string ToString(string? format = null, IFormatProvider? formatProvider = null)
{
return $"0x{m_value:X4}";
// throw new NotImplementedException();
// TODO: Implement this
}

public bool TryFormat
(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider formatProvider)
(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -392,6 +392,7 @@ public static implicit operator Half(int value)
return sign ? new Half((ushort) (h.m_value | SignMask)) : h;
}

[CLSCompliant(false)]
public static implicit operator Half(uint value)
{
var shiftDist = Helpers.LeadingZeroCount(value) - 21;
Expand All @@ -417,6 +418,7 @@ public static implicit operator Half(long value)
return sign ? new Half((ushort) (h.m_value | SignMask)) : h;
}

[CLSCompliant(false)]
public static implicit operator Half(ulong value)
{
var shiftDist = Helpers.LeadingZeroCount(value) - 53;
Expand All @@ -439,6 +441,7 @@ public static implicit operator Half(short value)
return (int) value;
}

[CLSCompliant(false)]
public static implicit operator Half(ushort value)
{
return (uint) value;
Expand All @@ -449,6 +452,7 @@ public static implicit operator Half(byte value)
return (uint) value;
}

[CLSCompliant(false)]
public static implicit operator Half(sbyte value)
{
return (int) value;
Expand Down Expand Up @@ -536,6 +540,7 @@ public static explicit operator int(Half value)
return sign ? -alignedSig : alignedSig;
}

[CLSCompliant(false)]
public static explicit operator uint(Half value) // 0 for every case
{
var sign = IsNegative(value);
Expand Down Expand Up @@ -580,6 +585,7 @@ public static explicit operator long(Half value)
return sign ? -alignedSig : alignedSig;
}

[CLSCompliant(false)]
public static explicit operator ulong(Half value) // 0 for PosInfinity/NaN, long.MinValue for NegInfinity
{
var sign = IsNegative(value);
Expand Down Expand Up @@ -607,6 +613,7 @@ public static explicit operator short(Half value)
return (short) (int) value;
}

[CLSCompliant(false)]
public static explicit operator ushort(Half value)
{
return (ushort) (short) (int) value;
Expand All @@ -617,6 +624,7 @@ public static explicit operator byte(Half value)
return (byte) (sbyte) (int) value;
}

[CLSCompliant(false)]
public static explicit operator sbyte(Half value)
{
return (sbyte) (int) value;
Expand Down Expand Up @@ -873,7 +881,6 @@ public static ulong ShiftRightJam(ulong l, int dist)
/// </summary>
/// <param name="value">The value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
public static int LeadingZeroCount(uint value)
{
// Unguarded fallback contract is 0->31
Expand All @@ -891,7 +898,6 @@ public static int LeadingZeroCount(uint value)
/// </summary>
/// <param name="value">The value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
public static int LeadingZeroCount(ulong value)
{
var hi = (uint) (value >> 32);
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix2x2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ public static Matrix2X2<T> Transpose(Matrix2X2<T> mat)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -249,7 +249,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix2x3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ public static Matrix3x2<T> Transpose(Matrix2X3<T> mat)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -234,7 +234,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix2x4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ public static Matrix4X2<T> Transpose(Matrix2X4<T> mat)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -252,7 +252,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix3X3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public static void Transpose(ref Matrix3X3<T> mat, out Matrix3X3<T> result)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -272,7 +272,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix3X4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public static void Transpose(ref Matrix3X4<T> mat, out Matrix4X3<T> result)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -287,7 +287,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix3x2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ public static Matrix2X3<T> Transpose(Matrix3x2<T> mat)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -230,7 +230,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix4X3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ public static void Transpose(ref Matrix4X3<T> mat, out Matrix3X4<T> result)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -285,7 +285,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix4X4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ public static void Transpose(ref Matrix4X4<T> mat, out Matrix4X4<T> result)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -503,7 +503,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Maths/Silk.NET.Maths/Matrix4x2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ public static Matrix2X4<T> Transpose(Matrix4X2<T> mat)

public override string ToString() => ToString("G");

public string ToString(string format) => ToString(format, CultureInfo.CurrentCulture);
public string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture);

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
throw new NotImplementedException();
}
Expand All @@ -244,7 +244,7 @@ public override int GetHashCode()
throw new NotImplementedException();
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException();
}
Expand Down
Loading