Skip to content

Commit

Permalink
Updating all types in System.Numerics.Vectors, minus Vector<T>, to us…
Browse files Browse the repository at this point in the history
…e the readonly members feature. (dotnet#36702)
  • Loading branch information
tannergooding authored Apr 9, 2019
1 parent 7b320a0 commit 5023c24
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 110 deletions.
110 changes: 55 additions & 55 deletions src/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/System.Numerics.Vectors/src/System/Numerics/Matrix3x2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static Matrix3x2 Identity
/// <summary>
/// Returns whether the matrix is the identity matrix.
/// </summary>
public bool IsIdentity
public readonly bool IsIdentity
{
get
{
Expand All @@ -74,7 +74,7 @@ public bool IsIdentity
/// </summary>
public Vector2 Translation
{
get
readonly get
{
return new Vector2(M31, M32);
}
Expand Down Expand Up @@ -443,7 +443,7 @@ public static Matrix3x2 CreateRotation(float radians, Vector2 centerPoint)
/// The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1).
/// </summary>
/// <returns>The determinant.</returns>
public float GetDeterminant()
public readonly float GetDeterminant()
{
// There isn't actually any such thing as a determinant for a non-square matrix,
// but this 3x2 type is really just an optimization of a 3x3 where we happen to
Expand Down Expand Up @@ -758,7 +758,7 @@ public static Matrix3x2 Multiply(Matrix3x2 value1, float value2)
/// </summary>
/// <param name="other">The other matrix to test equality against.</param>
/// <returns>True if this matrix is equal to other; False otherwise.</returns>
public bool Equals(Matrix3x2 other)
public readonly bool Equals(Matrix3x2 other)
{
return (M11 == other.M11 && M22 == other.M22 && // Check diagonal element first for early out.
M12 == other.M12 &&
Expand All @@ -771,7 +771,7 @@ public bool Equals(Matrix3x2 other)
/// </summary>
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this matrix; False otherwise.</returns>
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj is Matrix3x2)
{
Expand All @@ -785,7 +785,7 @@ public override bool Equals(object obj)
/// Returns a String representing this matrix instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}",
M11, M12,
Expand All @@ -797,7 +797,7 @@ public override string ToString()
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
return unchecked(M11.GetHashCode() + M12.GetHashCode() +
M21.GetHashCode() + M22.GetHashCode() +
Expand Down
14 changes: 7 additions & 7 deletions src/System.Numerics.Vectors/src/System/Numerics/Matrix4x4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static Matrix4x4 Identity
/// <summary>
/// Returns whether the matrix is the identity matrix.
/// </summary>
public bool IsIdentity
public readonly bool IsIdentity
{
get
{
Expand All @@ -127,7 +127,7 @@ public bool IsIdentity
/// </summary>
public Vector3 Translation
{
get
readonly get
{
return new Vector3(M41, M42, M43);
}
Expand Down Expand Up @@ -1260,7 +1260,7 @@ public static Matrix4x4 CreateReflection(Plane value)
/// Calculates the determinant of the matrix.
/// </summary>
/// <returns>The determinant of the matrix.</returns>
public float GetDeterminant()
public readonly float GetDeterminant()
{
// | a b c d | | f g h | | e g h | | e f h | | e f g |
// | e f g h | = a | j k l | - b | i k l | + c | i j l | - d | i j k |
Expand Down Expand Up @@ -2179,20 +2179,20 @@ public static unsafe Matrix4x4 Lerp(Matrix4x4 matrix1, Matrix4x4 matrix2, float
/// </summary>
/// <param name="other">The matrix to compare this instance to.</param>
/// <returns>True if the matrices are equal; False otherwise.</returns>
public bool Equals(Matrix4x4 other) => this == other;
public readonly bool Equals(Matrix4x4 other) => this == other;

/// <summary>
/// Returns a boolean indicating whether the given Object is equal to this matrix instance.
/// </summary>
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this matrix; False otherwise.</returns>
public override bool Equals(object obj) => (obj is Matrix4x4 other) && (this == other);
public override readonly bool Equals(object obj) => (obj is Matrix4x4 other) && (this == other);

/// <summary>
/// Returns a String representing this matrix instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}",
M11, M12, M13, M14,
Expand All @@ -2205,7 +2205,7 @@ public override string ToString()
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
unchecked
{
Expand Down
8 changes: 4 additions & 4 deletions src/System.Numerics.Vectors/src/System/Numerics/Plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static float DotNormal(Plane plane, Vector3 value)
/// <param name="other">The Plane to compare this instance to.</param>
/// <returns>True if the other Plane is equal to this instance; False otherwise.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Plane other)
public readonly bool Equals(Plane other)
{
if (Vector.IsHardwareAccelerated)
{
Expand All @@ -335,7 +335,7 @@ public bool Equals(Plane other)
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Plane; False otherwise.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj is Plane)
{
Expand All @@ -349,7 +349,7 @@ public override bool Equals(object obj)
/// Returns a String representing this Plane instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
CultureInfo ci = CultureInfo.CurrentCulture;

Expand All @@ -360,7 +360,7 @@ public override string ToString()
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
return Normal.GetHashCode() + D.GetHashCode();
}
Expand Down
14 changes: 7 additions & 7 deletions src/System.Numerics.Vectors/src/System/Numerics/Quaternion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static Quaternion Identity
/// <summary>
/// Returns whether the Quaternion is the identity Quaternion.
/// </summary>
public bool IsIdentity
public readonly bool IsIdentity
{
get { return X == 0f && Y == 0f && Z == 0f && W == 1f; }
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public Quaternion(Vector3 vectorPart, float scalarPart)
/// Calculates the length of the Quaternion.
/// </summary>
/// <returns>The computed length of the Quaternion.</returns>
public float Length()
public readonly float Length()
{
float ls = X * X + Y * Y + Z * Z + W * W;

Expand All @@ -90,7 +90,7 @@ public float Length()
/// Calculates the length squared of the Quaternion. This operation is cheaper than Length().
/// </summary>
/// <returns>The length squared of the Quaternion.</returns>
public float LengthSquared()
public readonly float LengthSquared()
{
return X * X + Y * Y + Z * Z + W * W;
}
Expand Down Expand Up @@ -748,7 +748,7 @@ public static Quaternion Divide(Quaternion value1, Quaternion value2)
/// </summary>
/// <param name="other">The Quaternion to compare this instance to.</param>
/// <returns>True if the other Quaternion is equal to this instance; False otherwise.</returns>
public bool Equals(Quaternion other)
public readonly bool Equals(Quaternion other)
{
return (X == other.X &&
Y == other.Y &&
Expand All @@ -761,7 +761,7 @@ public bool Equals(Quaternion other)
/// </summary>
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Quaternion; False otherwise.</returns>
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj is Quaternion)
{
Expand All @@ -775,7 +775,7 @@ public override bool Equals(object obj)
/// Returns a String representing this Quaternion instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X, Y, Z, W);
}
Expand All @@ -784,7 +784,7 @@ public override string ToString()
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
return unchecked(X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode());
}
Expand Down
14 changes: 7 additions & 7 deletions src/System.Numerics.Vectors/src/System/Numerics/Vector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static Vector2 One
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
int hash = this.X.GetHashCode();
hash = HashHelpers.Combine(hash, this.Y.GetHashCode());
Expand All @@ -65,7 +65,7 @@ public override int GetHashCode()
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Vector2; False otherwise.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (!(obj is Vector2))
return false;
Expand All @@ -76,7 +76,7 @@ public override bool Equals(object obj)
/// Returns a String representing this Vector2 instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
Expand All @@ -86,7 +86,7 @@ public override string ToString()
/// </summary>
/// <param name="format">The format of individual elements.</param>
/// <returns>The string representation.</returns>
public string ToString(string format)
public readonly string ToString(string format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
Expand All @@ -98,7 +98,7 @@ public string ToString(string format)
/// <param name="format">The format of individual elements.</param>
/// <param name="formatProvider">The format provider to use when formatting elements.</param>
/// <returns>The string representation.</returns>
public string ToString(string format, IFormatProvider formatProvider)
public readonly string ToString(string format, IFormatProvider formatProvider)
{
StringBuilder sb = new StringBuilder();
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
Expand All @@ -116,7 +116,7 @@ public string ToString(string format, IFormatProvider formatProvider)
/// </summary>
/// <returns>The vector's length.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Length()
public readonly float Length()
{
if (Vector.IsHardwareAccelerated)
{
Expand All @@ -135,7 +135,7 @@ public float Length()
/// </summary>
/// <returns>The vector's length squared.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float LengthSquared()
public readonly float LengthSquared()
{
if (Vector.IsHardwareAccelerated)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Vector2(float x, float y)
/// <param name="array">The destination array.</param>
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void CopyTo(float[] array)
public readonly void CopyTo(float[] array)
{
CopyTo(array, 0);
}
Expand All @@ -64,7 +64,7 @@ public void CopyTo(float[] array)
/// <exception cref="ArgumentException">If number of elements in source vector is greater than those available in destination array
/// or if there are not enough elements to copy.</exception>
[Intrinsic]
public void CopyTo(float[] array, int index)
public readonly void CopyTo(float[] array, int index)
{
if (array == null)
{
Expand All @@ -89,7 +89,7 @@ public void CopyTo(float[] array, int index)
/// <param name="other">The Vector2 to compare this instance to.</param>
/// <returns>True if the other Vector2 is equal to this instance; False otherwise.</returns>
[Intrinsic]
public bool Equals(Vector2 other)
public readonly bool Equals(Vector2 other)
{
return this.X == other.X && this.Y == other.Y;
}
Expand Down
14 changes: 7 additions & 7 deletions src/System.Numerics.Vectors/src/System/Numerics/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Vector3 One
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
public override readonly int GetHashCode()
{
int hash = this.X.GetHashCode();
hash = HashHelpers.Combine(hash, this.Y.GetHashCode());
Expand All @@ -71,7 +71,7 @@ public override int GetHashCode()
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Vector3; False otherwise.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (!(obj is Vector3))
return false;
Expand All @@ -82,7 +82,7 @@ public override bool Equals(object obj)
/// Returns a String representing this Vector3 instance.
/// </summary>
/// <returns>The string representation.</returns>
public override string ToString()
public override readonly string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
Expand All @@ -92,7 +92,7 @@ public override string ToString()
/// </summary>
/// <param name="format">The format of individual elements.</param>
/// <returns>The string representation.</returns>
public string ToString(string format)
public readonly string ToString(string format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
Expand All @@ -104,7 +104,7 @@ public string ToString(string format)
/// <param name="format">The format of individual elements.</param>
/// <param name="formatProvider">The format provider to use when formatting elements.</param>
/// <returns>The string representation.</returns>
public string ToString(string format, IFormatProvider formatProvider)
public readonly string ToString(string format, IFormatProvider formatProvider)
{
StringBuilder sb = new StringBuilder();
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
Expand All @@ -125,7 +125,7 @@ public string ToString(string format, IFormatProvider formatProvider)
/// </summary>
/// <returns>The vector's length.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Length()
public readonly float Length()
{
if (Vector.IsHardwareAccelerated)
{
Expand All @@ -144,7 +144,7 @@ public float Length()
/// </summary>
/// <returns>The vector's length squared.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float LengthSquared()
public readonly float LengthSquared()
{
if (Vector.IsHardwareAccelerated)
{
Expand Down
Loading

0 comments on commit 5023c24

Please sign in to comment.