C#: Implement InvariantCulture on Variant strings

This commit is contained in:
Thaddeus Crews 2024-03-15 19:43:00 -05:00
parent 68ad520da4
commit 300aa202c8
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
17 changed files with 40 additions and 100 deletions

View file

@ -733,10 +733,7 @@ namespace Godot
/// Converts this <see cref="Aabb"/> to a string.
/// </summary>
/// <returns>A string representation of this AABB.</returns>
public override readonly string ToString()
{
return $"{_position}, {_size}";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Aabb"/> to a string with the given <paramref name="format"/>.

View file

@ -1134,10 +1134,7 @@ namespace Godot
/// Converts this <see cref="Basis"/> to a string.
/// </summary>
/// <returns>A string representation of this basis.</returns>
public override readonly string ToString()
{
return $"[X: {X}, Y: {Y}, Z: {Z}]";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Basis"/> to a string with the given <paramref name="format"/>.

View file

@ -1329,10 +1329,7 @@ namespace Godot
/// Converts this <see cref="Color"/> to a string.
/// </summary>
/// <returns>A string representation of this color.</returns>
public override readonly string ToString()
{
return $"({R}, {G}, {B}, {A})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Color"/> to a string with the given <paramref name="format"/>.
@ -1340,9 +1337,7 @@ namespace Godot
/// <returns>A string representation of this color.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({R.ToString(format)}, {G.ToString(format)}, {B.ToString(format)}, {A.ToString(format)})";
#pragma warning restore CA1305
return $"({R.ToString(format, CultureInfo.InvariantCulture)}, {G.ToString(format, CultureInfo.InvariantCulture)}, {B.ToString(format, CultureInfo.InvariantCulture)}, {A.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -424,10 +425,7 @@ namespace Godot
/// Converts this <see cref="Plane"/> to a string.
/// </summary>
/// <returns>A string representation of this plane.</returns>
public override readonly string ToString()
{
return $"{_normal}, {_d}";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Plane"/> to a string with the given <paramref name="format"/>.
@ -435,9 +433,7 @@ namespace Godot
/// <returns>A string representation of this plane.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"{_normal.ToString(format)}, {_d.ToString(format)}";
#pragma warning restore CA1305
return $"{_normal.ToString(format)}, {_d.ToString(format, CultureInfo.InvariantCulture)}";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -1012,10 +1013,7 @@ namespace Godot
/// Converts this <see cref="Projection"/> to a string.
/// </summary>
/// <returns>A string representation of this projection.</returns>
public override readonly string ToString()
{
return $"{X.X}, {X.Y}, {X.Z}, {X.W}\n{Y.X}, {Y.Y}, {Y.Z}, {Y.W}\n{Z.X}, {Z.Y}, {Z.Z}, {Z.W}\n{W.X}, {W.Y}, {W.Z}, {W.W}\n";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Projection"/> to a string with the given <paramref name="format"/>.
@ -1023,12 +1021,10 @@ namespace Godot
/// <returns>A string representation of this projection.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"{X.X.ToString(format)}, {X.Y.ToString(format)}, {X.Z.ToString(format)}, {X.W.ToString(format)}\n" +
$"{Y.X.ToString(format)}, {Y.Y.ToString(format)}, {Y.Z.ToString(format)}, {Y.W.ToString(format)}\n" +
$"{Z.X.ToString(format)}, {Z.Y.ToString(format)}, {Z.Z.ToString(format)}, {Z.W.ToString(format)}\n" +
$"{W.X.ToString(format)}, {W.Y.ToString(format)}, {W.Z.ToString(format)}, {W.W.ToString(format)}\n";
#pragma warning restore CA1305
return $"{X.X.ToString(format, CultureInfo.InvariantCulture)}, {X.Y.ToString(format, CultureInfo.InvariantCulture)}, {X.Z.ToString(format, CultureInfo.InvariantCulture)}, {X.W.ToString(format, CultureInfo.InvariantCulture)}\n" +
$"{Y.X.ToString(format, CultureInfo.InvariantCulture)}, {Y.Y.ToString(format, CultureInfo.InvariantCulture)}, {Y.Z.ToString(format, CultureInfo.InvariantCulture)}, {Y.W.ToString(format, CultureInfo.InvariantCulture)}\n" +
$"{Z.X.ToString(format, CultureInfo.InvariantCulture)}, {Z.Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.Z.ToString(format, CultureInfo.InvariantCulture)}, {Z.W.ToString(format, CultureInfo.InvariantCulture)}\n" +
$"{W.X.ToString(format, CultureInfo.InvariantCulture)}, {W.Y.ToString(format, CultureInfo.InvariantCulture)}, {W.Z.ToString(format, CultureInfo.InvariantCulture)}, {W.W.ToString(format, CultureInfo.InvariantCulture)}\n";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -811,10 +812,7 @@ namespace Godot
/// Converts this <see cref="Quaternion"/> to a string.
/// </summary>
/// <returns>A string representation of this quaternion.</returns>
public override readonly string ToString()
{
return $"({X}, {Y}, {Z}, {W})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Quaternion"/> to a string with the given <paramref name="format"/>.
@ -822,9 +820,7 @@ namespace Godot
/// <returns>A string representation of this quaternion.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)}, {Z.ToString(format)}, {W.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.ToString(format, CultureInfo.InvariantCulture)}, {W.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -469,10 +469,7 @@ namespace Godot
/// Converts this <see cref="Rect2"/> to a string.
/// </summary>
/// <returns>A string representation of this rect.</returns>
public override readonly string ToString()
{
return $"{_position}, {_size}";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Rect2"/> to a string with the given <paramref name="format"/>.

View file

@ -429,10 +429,7 @@ namespace Godot
/// Converts this <see cref="Rect2I"/> to a string.
/// </summary>
/// <returns>A string representation of this rect.</returns>
public override readonly string ToString()
{
return $"{_position}, {_size}";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Rect2I"/> to a string with the given <paramref name="format"/>.

View file

@ -1,8 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.InteropServices;
using Godot.NativeInterop;
#nullable enable
@ -102,6 +101,6 @@ namespace Godot
/// Converts this <see cref="Rid"/> to a string.
/// </summary>
/// <returns>A string representation of this Rid.</returns>
public override string ToString() => $"RID({Id})";
public override readonly string ToString() => $"RID({Id.ToString(null, CultureInfo.InvariantCulture)})";
}
}

View file

@ -650,10 +650,7 @@ namespace Godot
/// Converts this <see cref="Transform2D"/> to a string.
/// </summary>
/// <returns>A string representation of this transform.</returns>
public override readonly string ToString()
{
return $"[X: {X}, Y: {Y}, O: {Origin}]";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Transform2D"/> to a string with the given <paramref name="format"/>.

View file

@ -674,10 +674,7 @@ namespace Godot
/// Converts this <see cref="Transform3D"/> to a string.
/// </summary>
/// <returns>A string representation of this transform.</returns>
public override readonly string ToString()
{
return $"[X: {Basis.X}, Y: {Basis.Y}, Z: {Basis.Z}, O: {Origin}]";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Transform3D"/> to a string with the given <paramref name="format"/>.

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -1016,10 +1017,7 @@ namespace Godot
/// Converts this <see cref="Vector2"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override readonly string ToString()
{
return $"({X}, {Y})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector2"/> to a string with the given <paramref name="format"/>.
@ -1027,9 +1025,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -589,10 +590,7 @@ namespace Godot
/// Converts this <see cref="Vector2I"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override readonly string ToString()
{
return $"({X}, {Y})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector2I"/> to a string with the given <paramref name="format"/>.
@ -600,9 +598,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -1118,10 +1119,7 @@ namespace Godot
/// Converts this <see cref="Vector3"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override readonly string ToString()
{
return $"({X}, {Y}, {Z})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector3"/> to a string with the given <paramref name="format"/>.
@ -1129,9 +1127,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)}, {Z.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -644,10 +645,7 @@ namespace Godot
/// Converts this <see cref="Vector3I"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override readonly string ToString()
{
return $"({X}, {Y}, {Z})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector3I"/> to a string with the given <paramref name="format"/>.
@ -655,9 +653,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)}, {Z.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -894,10 +895,7 @@ namespace Godot
/// Converts this <see cref="Vector4"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override string ToString()
{
return $"({X}, {Y}, {Z}, {W})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector4"/> to a string with the given <paramref name="format"/>.
@ -905,9 +903,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)}, {Z.ToString(format)}, {W.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.ToString(format, CultureInfo.InvariantCulture)}, {W.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
#nullable enable
@ -665,10 +666,7 @@ namespace Godot
/// Converts this <see cref="Vector4I"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override readonly string ToString()
{
return $"({X}, {Y}, {Z}, {W})";
}
public override readonly string ToString() => ToString(null);
/// <summary>
/// Converts this <see cref="Vector4I"/> to a string with the given <paramref name="format"/>.
@ -676,9 +674,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public readonly string ToString(string? format)
{
#pragma warning disable CA1305 // Disable warning: "Specify IFormatProvider"
return $"({X.ToString(format)}, {Y.ToString(format)}, {Z.ToString(format)}, {W.ToString(format)})";
#pragma warning restore CA1305
return $"({X.ToString(format, CultureInfo.InvariantCulture)}, {Y.ToString(format, CultureInfo.InvariantCulture)}, {Z.ToString(format, CultureInfo.InvariantCulture)}, {W.ToString(format, CultureInfo.InvariantCulture)})";
}
}
}