Skip to content

Commit 5a82141

Browse files
committed
IReadOnlyList<T> code gen.
1 parent a4b8a6c commit 5a82141

10 files changed

Lines changed: 90 additions & 55 deletions

File tree

sources/Maths/Maths/Vector2F.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ public Vector2F(ReadOnlySpan<T> values)
5454
/// <summary>Gets the length of the vector.</summary>
5555
public T Length => T.Sqrt(LengthSquared);
5656

57-
/// <summary>The number of elements in the vector.</summary>
58-
public int Count => 2;
59-
60-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
61-
public IEnumerator<T> GetEnumerator()
62-
{
63-
yield return X;
64-
yield return Y;
65-
}
66-
6757
/// <summary> Computes the dot product of this vector with another vector. </summary>
6858
public T Dot(Vector2F<T> other) => (X * other.X) + (Y * other.Y);
6959

@@ -335,9 +325,6 @@ static bool ISpanParsable<Vector2F<T>>.TryParse(ReadOnlySpan<char> s, IFormatPro
335325
static bool IParsable<Vector2F<T>>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F<T> result) =>
336326
TryParse(s, provider, out result);
337327

338-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
339-
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
340-
341328
/// <summary>Formats the vector as a UTF-8 string using the specified format and format provider.</summary>
342329
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
343330
{

sources/Maths/Maths/Vector2F.gen.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -41,6 +42,19 @@ public ref T this[int index]
4142
}
4243
}
4344

45+
/// <summary>The number of elements in the vector.</summary>
46+
public int Count => 2;
47+
48+
/// <inheritdoc/>
49+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
50+
51+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
52+
public IEnumerator<T> GetEnumerator()
53+
{
54+
yield return X;
55+
yield return Y;
56+
}
57+
4458
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
4559
/// <param name="left">The first vector to compare.</param>
4660
/// <param name="right">The second vector to compare.</param>

sources/Maths/Maths/Vector2I.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ public Vector2I(ReadOnlySpan<T> values)
4949
/// <summary>Gets the squared length of the vector (dot product with itself).</summary>
5050
public T LengthSquared => (X * X) + (Y * Y);
5151

52-
/// <summary>The number of elements in the vector.</summary>
53-
public int Count => 2;
54-
55-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
56-
public IEnumerator<T> GetEnumerator()
57-
{
58-
yield return X;
59-
yield return Y;
60-
}
61-
6252
/// <summary> Computes the dot product of this vector with another vector. </summary>
6353
public T Dot(Vector2I<T> other) => (X * other.X) + (Y * other.Y);
6454

@@ -288,9 +278,6 @@ static bool ISpanParsable<Vector2I<T>>.TryParse(ReadOnlySpan<char> s, IFormatPro
288278
static bool IParsable<Vector2I<T>>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I<T> result) =>
289279
TryParse(s, provider, out result);
290280

291-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
292-
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
293-
294281
/// <summary>Formats the vector as a UTF-8 string using the specified format and format provider.</summary>
295282
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
296283
{

sources/Maths/Maths/Vector2I.gen.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -41,6 +42,19 @@ public ref T this[int index]
4142
}
4243
}
4344

45+
/// <summary>The number of elements in the vector.</summary>
46+
public int Count => 2;
47+
48+
/// <inheritdoc/>
49+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
50+
51+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
52+
public IEnumerator<T> GetEnumerator()
53+
{
54+
yield return X;
55+
yield return Y;
56+
}
57+
4458
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
4559
/// <param name="left">The first vector to compare.</param>
4660
/// <param name="right">The second vector to compare.</param>

sources/Maths/Maths/Vector3F.gen.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -46,6 +47,20 @@ public ref T this[int index]
4647
}
4748
}
4849

50+
/// <summary>The number of elements in the vector.</summary>
51+
public int Count => 3;
52+
53+
/// <inheritdoc/>
54+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
55+
56+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
57+
public IEnumerator<T> GetEnumerator()
58+
{
59+
yield return X;
60+
yield return Y;
61+
yield return Z;
62+
}
63+
4964
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
5065
/// <param name="left">The first vector to compare.</param>
5166
/// <param name="right">The second vector to compare.</param>

sources/Maths/Maths/Vector3I.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,6 @@ public Vector3I(ReadOnlySpan<T> values)
5757
/// <summary>Gets the squared length of the vector (dot product with itself).</summary>
5858
public T LengthSquared => (X * X) + (Y * Y) + (Z * Z);
5959

60-
/// <summary>The number of elements in the vector.</summary>
61-
public int Count => 3;
62-
63-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
64-
public IEnumerator<T> GetEnumerator()
65-
{
66-
yield return X;
67-
yield return Y;
68-
yield return Z;
69-
}
70-
7160
/// <summary> Computes the dot product of this vector with another vector. </summary>
7261
public T Dot(Vector3I<T> other) => (X * other.X) + (Y * other.Y) + (Z * other.Z);
7362

@@ -345,9 +334,6 @@ static bool ISpanParsable<Vector3I<T>>.TryParse(ReadOnlySpan<char> s, IFormatPro
345334
static bool IParsable<Vector3I<T>>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I<T> result) =>
346335
TryParse(s, provider, out result);
347336

348-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
349-
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
350-
351337
/// <summary>Formats the vector as a UTF-8 string using the specified format and format provider.</summary>
352338
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
353339
{

sources/Maths/Maths/Vector3I.gen.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -46,6 +47,20 @@ public ref T this[int index]
4647
}
4748
}
4849

50+
/// <summary>The number of elements in the vector.</summary>
51+
public int Count => 3;
52+
53+
/// <inheritdoc/>
54+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
55+
56+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
57+
public IEnumerator<T> GetEnumerator()
58+
{
59+
yield return X;
60+
yield return Y;
61+
yield return Z;
62+
}
63+
4964
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
5065
/// <param name="left">The first vector to compare.</param>
5166
/// <param name="right">The second vector to compare.</param>

sources/Maths/Maths/Vector4F.gen.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -51,6 +52,21 @@ public ref T this[int index]
5152
}
5253
}
5354

55+
/// <summary>The number of elements in the vector.</summary>
56+
public int Count => 4;
57+
58+
/// <inheritdoc/>
59+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
60+
61+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
62+
public IEnumerator<T> GetEnumerator()
63+
{
64+
yield return X;
65+
yield return Y;
66+
yield return Z;
67+
yield return W;
68+
}
69+
5470
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
5571
/// <param name="left">The first vector to compare.</param>
5672
/// <param name="right">The second vector to compare.</param>

sources/Maths/Maths/Vector4I.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@ public Vector4I(ReadOnlySpan<T> values)
6363
/// <summary>Gets the squared length of the vector (dot product with itself).</summary>
6464
public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W);
6565

66-
/// <summary>The number of elements in the vector.</summary>
67-
public int Count => 4;
68-
69-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
70-
public IEnumerator<T> GetEnumerator()
71-
{
72-
yield return X;
73-
yield return Y;
74-
yield return Z;
75-
yield return W;
76-
}
77-
7866
/// <summary> Computes the dot product of this vector with another vector. </summary>
7967
public T Dot(Vector4I<T> other) => (X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W);
8068

@@ -353,9 +341,6 @@ static bool ISpanParsable<Vector4I<T>>.TryParse(ReadOnlySpan<char> s, IFormatPro
353341
static bool IParsable<Vector4I<T>>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I<T> result) =>
354342
TryParse(s, provider, out result);
355343

356-
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
357-
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
358-
359344
/// <summary>Formats the vector as a UTF-8 string using the specified format and format provider.</summary>
360345
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
361346
{

sources/Maths/Maths/Vector4I.gen.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Silk.NET.Maths
22
{
3+
using System.Collections;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Numerics;
56

@@ -51,6 +52,21 @@ public ref T this[int index]
5152
}
5253
}
5354

55+
/// <summary>The number of elements in the vector.</summary>
56+
public int Count => 4;
57+
58+
/// <inheritdoc/>
59+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
60+
61+
/// <summary> Returns an enumerator that iterates through the vector components.</summary>
62+
public IEnumerator<T> GetEnumerator()
63+
{
64+
yield return X;
65+
yield return Y;
66+
yield return Z;
67+
yield return W;
68+
}
69+
5470
/// <summary>Returns a boolean indicating whether the given two vectors are equal.</summary>
5571
/// <param name="left">The first vector to compare.</param>
5672
/// <param name="right">The second vector to compare.</param>

0 commit comments

Comments
 (0)