Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 30, 2024
1 parent 24c930e commit 821bfa7
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 138 deletions.
30 changes: 15 additions & 15 deletions src/Polyfill/Numbers/BytePolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static partial class BytePolyfill
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-string-system-iformatprovider-system-byte@)")]
public static bool TryParse(string? target, IFormatProvider? provider, out byte result) =>
#if !NET7_0_OR_GREATER
byte.TryParse(target, NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
byte.TryParse(target, provider, out result);
#else
byte.TryParse(target, NumberStyles.Integer, provider, out result);
#endif

#if FeatureMemory
Expand All @@ -34,10 +34,10 @@ public static bool TryParse(string? target, IFormatProvider? provider, out byte
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-byte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out byte result) =>
#if !NET8_0_OR_GREATER
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#else
#if NET8_0_OR_GREATER
byte.TryParse(target, provider, out result);
#else
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
Expand All @@ -56,32 +56,32 @@ public static bool TryParse(ReadOnlySpan<char> target, out byte result) =>
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-byte@)")]
public static bool TryParse(ReadOnlySpan<char> target, IFormatProvider? provider, out byte result) =>
#if !NET7_0_OR_GREATER
byte.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
byte.TryParse(target, provider, out result);
#else
byte.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
/// Tries to parse a span of UTF-8 characters into a value.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-byte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, NumberStyles style, IFormatProvider? provider, out byte result) =>
#if !NET8_0_OR_GREATER
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#else
#if NET8_0_OR_GREATER
byte.TryParse(target, style, provider, out result);
#else
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#endif

/// <summary>
/// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-byte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, out byte result) =>
#if !NET8_0_OR_GREATER
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#else
#if NET8_0_OR_GREATER
byte.TryParse(target, out result);
#else
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#endif

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions src/Polyfill/Numbers/DoublePolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static partial class DoublePolyfill
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse#system-double-tryparse(system-string-system-iformatprovider-system-double@)")]
public static bool TryParse(string? target, IFormatProvider? provider, out double result) =>
#if !NET7_0_OR_GREATER
double.TryParse(target, NumberStyles.Float, provider, out result);
#else
#if NET7_0_OR_GREATER
double.TryParse(target, provider, out result);
#else
double.TryParse(target, NumberStyles.Float, provider, out result);
#endif

#if FeatureMemory
Expand All @@ -34,10 +34,10 @@ public static bool TryParse(string? target, IFormatProvider? provider, out doubl
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse#system-double-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-double@)")]
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out double result) =>
#if !NET8_0_OR_GREATER
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Float, provider, out result);
#else
#if NET8_0_OR_GREATER
double.TryParse(target, provider, out result);
#else
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Float, provider, out result);
#endif

/// <summary>
Expand All @@ -56,32 +56,32 @@ public static bool TryParse(ReadOnlySpan<char> target, out double result) =>
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse#system-double-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-double@)")]
public static bool TryParse(ReadOnlySpan<char> target, IFormatProvider? provider, out double result) =>
#if !NET7_0_OR_GREATER
double.TryParse(target.ToString(), NumberStyles.Float, provider, out result);
#else
#if NET7_0_OR_GREATER
double.TryParse(target, provider, out result);
#else
double.TryParse(target.ToString(), NumberStyles.Float, provider, out result);
#endif

/// <summary>
/// Tries to parse a span of UTF-8 characters into a value.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse#system-double-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-double@)")]
public static bool TryParse(ReadOnlySpan<byte> target, NumberStyles style, IFormatProvider? provider, out double result) =>
#if !NET8_0_OR_GREATER
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#else
#if NET8_0_OR_GREATER
double.TryParse(target, style, provider, out result);
#else
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#endif

/// <summary>
/// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent..
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse#system-double-tryparse(system-readonlyspan((system-byte))-system-double@)")]
public static bool TryParse(ReadOnlySpan<byte> target, out double result) =>
#if !NET8_0_OR_GREATER
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Float, null, out result);
#else
#if NET8_0_OR_GREATER
double.TryParse(target, out result);
#else
double.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Float, null, out result);
#endif

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions src/Polyfill/Numbers/IntPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static partial class IntPolyfill
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-string-system-iformatprovider-system-int32@)")]
public static bool TryParse(string? target, IFormatProvider? provider, out int result) =>
#if !NET7_0_OR_GREATER
int.TryParse(target, NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(target, NumberStyles.Integer, provider, out result);
#endif

#if FeatureMemory
Expand All @@ -34,10 +34,10 @@ public static bool TryParse(string? target, IFormatProvider? provider, out int r
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int32@)")]
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
Expand All @@ -56,32 +56,32 @@ public static bool TryParse(ReadOnlySpan<char> target, out int result) =>
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int32@)")]
public static bool TryParse(ReadOnlySpan<char> target, IFormatProvider? provider, out int result) =>
#if !NET7_0_OR_GREATER
int.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
/// Tries to parse a span of UTF-8 characters into a value.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int32@)")]
public static bool TryParse(ReadOnlySpan<byte> target, NumberStyles style, IFormatProvider? provider, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, style, provider, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#endif

/// <summary>
/// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int32@)")]
public static bool TryParse(ReadOnlySpan<byte> target, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#endif

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions src/Polyfill/Numbers/LongPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static partial class LongPolyfill
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-string-system-iformatprovider-system-int64@)")]
public static bool TryParse(string? target, IFormatProvider? provider, out int result) =>
#if !NET7_0_OR_GREATER
int.TryParse(target, NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(target, NumberStyles.Integer, provider, out result);
#endif

#if FeatureMemory
Expand All @@ -34,10 +34,10 @@ public static bool TryParse(string? target, IFormatProvider? provider, out int r
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int64@)")]
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
Expand All @@ -56,32 +56,32 @@ public static bool TryParse(ReadOnlySpan<char> target, out int result) =>
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int64@)")]
public static bool TryParse(ReadOnlySpan<char> target, IFormatProvider? provider, out int result) =>
#if !NET7_0_OR_GREATER
int.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
int.TryParse(target, provider, out result);
#else
int.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
/// Tries to parse a span of UTF-8 characters into a value.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int64@)")]
public static bool TryParse(ReadOnlySpan<byte> target, NumberStyles style, IFormatProvider? provider, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, style, provider, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#endif

/// <summary>
/// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int64@)")]
public static bool TryParse(ReadOnlySpan<byte> target, out int result) =>
#if !NET8_0_OR_GREATER
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#else
#if NET8_0_OR_GREATER
int.TryParse(target, out result);
#else
int.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#endif

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions src/Polyfill/Numbers/SBytePolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static partial class SBytePolyfill
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@)")]
public static bool TryParse(string? target, IFormatProvider? provider, out sbyte result) =>
#if !NET7_0_OR_GREATER
sbyte.TryParse(target, NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
sbyte.TryParse(target, provider, out result);
#else
sbyte.TryParse(target, NumberStyles.Integer, provider, out result);
#endif

#if FeatureMemory
Expand All @@ -34,10 +34,10 @@ public static bool TryParse(string? target, IFormatProvider? provider, out sbyte
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-sbyte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out sbyte result) =>
#if !NET8_0_OR_GREATER
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#else
#if NET8_0_OR_GREATER
sbyte.TryParse(target, provider, out result);
#else
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
Expand All @@ -56,32 +56,32 @@ public static bool TryParse(ReadOnlySpan<char> target, out sbyte result) =>
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-sbyte@)")]
public static bool TryParse(ReadOnlySpan<char> target, IFormatProvider? provider, out sbyte result) =>
#if !NET7_0_OR_GREATER
sbyte.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#else
#if NET7_0_OR_GREATER
sbyte.TryParse(target, provider, out result);
#else
sbyte.TryParse(target.ToString(), NumberStyles.Integer, provider, out result);
#endif

/// <summary>
/// Tries to parse a span of UTF-8 characters into a value.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, NumberStyles style, IFormatProvider? provider, out sbyte result) =>
#if !NET8_0_OR_GREATER
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#else
#if NET8_0_OR_GREATER
sbyte.TryParse(target, style, provider, out result);
#else
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), style, provider, out result);
#endif

/// <summary>
/// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent.
/// </summary>
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@)")]
public static bool TryParse(ReadOnlySpan<byte> target, out sbyte result) =>
#if !NET8_0_OR_GREATER
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#else
#if NET8_0_OR_GREATER
sbyte.TryParse(target, out result);
#else
sbyte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, null, out result);
#endif

/// <summary>
Expand Down
Loading

0 comments on commit 821bfa7

Please sign in to comment.