C#: Remove/deprecate unnecessary string extensions

- Removed `UnicodeAt`
- Removed `EndsWith`
- Removed `LPad` and `RPad`
- Deprecated `BeginsWith` in favor of `string.StartsWith`
- Deprecated `LStrip` and `RStrip` in favor of `string.TrimStart` and `string.TrimEnd`
This commit is contained in:
Raul Santos 2022-11-27 23:25:48 +01:00
parent d0b166d8e4
commit dc2ceef0ec
No known key found for this signature in database
GPG key ID: B532473AE3A803E4

View file

@ -75,6 +75,7 @@ namespace Godot
/// <param name="instance">The string to check.</param> /// <param name="instance">The string to check.</param>
/// <param name="text">The beginning string.</param> /// <param name="text">The beginning string.</param>
/// <returns>If the string begins with the given string.</returns> /// <returns>If the string begins with the given string.</returns>
[Obsolete("Use string.StartsWith instead.")]
public static bool BeginsWith(this string instance, string text) public static bool BeginsWith(this string instance, string text)
{ {
return instance.StartsWith(text); return instance.StartsWith(text);
@ -502,18 +503,6 @@ namespace Godot
} }
} }
/// <summary>
/// Returns <see langword="true"/> if the strings ends
/// with the given string <paramref name="text"/>.
/// </summary>
/// <param name="instance">The string to check.</param>
/// <param name="text">The ending string.</param>
/// <returns>If the string ends with the given string.</returns>
public static bool EndsWith(this string instance, string text)
{
return instance.EndsWith(text);
}
/// <summary> /// <summary>
/// Returns the extension without the leading period character (<c>.</c>) /// Returns the extension without the leading period character (<c>.</c>)
/// if the string is a valid file name or path. If the string does not contain /// if the string is a valid file name or path. If the string does not contain
@ -1209,19 +1198,6 @@ namespace Godot
return instance.Substring(0, pos); return instance.Substring(0, pos);
} }
/// <summary>
/// Formats a string to be at least <paramref name="minLength"/> long by
/// adding <paramref name="character"/>s to the left of the string.
/// </summary>
/// <param name="instance">String that will be padded.</param>
/// <param name="minLength">Minimum length that the resulting string must have.</param>
/// <param name="character">Character to add to the left of the string.</param>
/// <returns>String padded with the specified character.</returns>
public static string LPad(this string instance, int minLength, char character = ' ')
{
return instance.PadLeft(minLength, character);
}
/// <summary> /// <summary>
/// Returns a copy of the string with characters removed from the left. /// Returns a copy of the string with characters removed from the left.
/// The <paramref name="chars"/> argument is a string specifying the set of characters /// The <paramref name="chars"/> argument is a string specifying the set of characters
@ -1233,6 +1209,7 @@ namespace Godot
/// <param name="instance">The string to remove characters from.</param> /// <param name="instance">The string to remove characters from.</param>
/// <param name="chars">The characters to be removed.</param> /// <param name="chars">The characters to be removed.</param>
/// <returns>A copy of the string with characters removed from the left.</returns> /// <returns>A copy of the string with characters removed from the left.</returns>
[Obsolete("Use string.TrimStart instead.")]
public static string LStrip(this string instance, string chars) public static string LStrip(this string instance, string chars)
{ {
return instance.TrimStart(chars.ToCharArray()); return instance.TrimStart(chars.ToCharArray());
@ -1526,19 +1503,6 @@ namespace Godot
return instance.Substring(pos, instance.Length - pos); return instance.Substring(pos, instance.Length - pos);
} }
/// <summary>
/// Formats a string to be at least <paramref name="minLength"/> long by
/// adding <paramref name="character"/>s to the right of the string.
/// </summary>
/// <param name="instance">String that will be padded.</param>
/// <param name="minLength">Minimum length that the resulting string must have.</param>
/// <param name="character">Character to add to the right of the string.</param>
/// <returns>String padded with the specified character.</returns>
public static string RPad(this string instance, int minLength, char character = ' ')
{
return instance.PadRight(minLength, character);
}
/// <summary> /// <summary>
/// Returns a copy of the string with characters removed from the right. /// Returns a copy of the string with characters removed from the right.
/// The <paramref name="chars"/> argument is a string specifying the set of characters /// The <paramref name="chars"/> argument is a string specifying the set of characters
@ -1550,6 +1514,7 @@ namespace Godot
/// <param name="instance">The string to remove characters from.</param> /// <param name="instance">The string to remove characters from.</param>
/// <param name="chars">The characters to be removed.</param> /// <param name="chars">The characters to be removed.</param>
/// <returns>A copy of the string with characters removed from the right.</returns> /// <returns>A copy of the string with characters removed from the right.</returns>
[Obsolete("Use string.TrimEnd instead.")]
public static string RStrip(this string instance, string chars) public static string RStrip(this string instance, string chars)
{ {
return instance.TrimEnd(chars.ToCharArray()); return instance.TrimEnd(chars.ToCharArray());
@ -1885,17 +1850,6 @@ namespace Godot
return instance; return instance;
} }
/// <summary>
/// Returns the character code at position <paramref name="at"/>.
/// </summary>
/// <param name="instance">The string to check.</param>
/// <param name="at">The position int the string for the character to check.</param>
/// <returns>The character code.</returns>
public static int UnicodeAt(this string instance, int at)
{
return instance[at];
}
/// <summary> /// <summary>
/// Decodes a string in URL encoded format. This is meant to /// Decodes a string in URL encoded format. This is meant to
/// decode parameters in a URL when receiving an HTTP request. /// decode parameters in a URL when receiving an HTTP request.