Skip to content

Commit

Permalink
Temporarily add back old TryParse signatures (dotnet#14893)
Browse files Browse the repository at this point in the history
My previous change updated the primitive TryParse signatures based on
the new design, but until corefx consumes that change, live corefx bits
won't work with the latest coreclr bits.  Until it can be consumed, I'm
putting back the old signatures as well.
  • Loading branch information
stephentoub authored Nov 7, 2017
1 parent 6a5b0e5 commit c92a1ed
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public static bool TryParse(ReadOnlySpan<char> s, out byte result)
return TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out byte result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Byte result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out double result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out double result)
{
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Int16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out Int16 result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out short result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Int32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return Number.TryParseInt32(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out int result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out int result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Int64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
return Number.TryParseInt64(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out long result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out long result)
{
NumberFormatInfo.ValidateParseStyleInteger(style);
Expand Down
5 changes: 5 additions & 0 deletions src/mscorlib/shared/System/SByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, out sbyte result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out sbyte result)
{
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/shared/System/Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static Boolean TryParse(ReadOnlySpan<char> s, out Single result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out float result)
{
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
Expand Down
15 changes: 15 additions & 0 deletions src/mscorlib/shared/System/TimeSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ public static bool TryParse(ReadOnlySpan<char> s, out TimeSpan result)
{
return TimeSpanParse.TryParse(s, null, out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> input, out TimeSpan result, IFormatProvider formatProvider = null) =>
TryParse(input, formatProvider, out result);

public static Boolean TryParse(String input, IFormatProvider formatProvider, out TimeSpan result)
{
if (input == null)
Expand Down Expand Up @@ -409,6 +414,11 @@ public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFo
{
return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, TimeSpanStyles.None, out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParseExact(ReadOnlySpan<char> input, string format, IFormatProvider formatProvider, out TimeSpan result, TimeSpanStyles styles = TimeSpanStyles.None) =>
TryParseExact(input, format, formatProvider, styles, out result);

public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
{
ValidateStyles(styles, nameof(styles));
Expand All @@ -434,6 +444,11 @@ public static Boolean TryParseExact(String input, String[] formats, IFormatProvi
}
return TimeSpanParse.TryParseExactMultiple(input.AsReadOnlySpan(), formats, formatProvider, styles, out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, out TimeSpan result, TimeSpanStyles styles = TimeSpanStyles.None) =>
TryParseExact(input, formats, formatProvider, styles, out result);

public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
{
ValidateStyles(styles, nameof(styles));
Expand Down
5 changes: 5 additions & 0 deletions src/mscorlib/shared/System/UInt16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, out ushort result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out ushort result)
{
Expand Down
5 changes: 5 additions & 0 deletions src/mscorlib/shared/System/UInt32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
return Number.TryParseUInt32(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, out UInt32 result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out uint result)
{
Expand Down
5 changes: 5 additions & 0 deletions src/mscorlib/shared/System/UInt64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
return Number.TryParseUInt64(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
[CLSCompliant(false)]
public static Boolean TryParse(ReadOnlySpan<char> s, out UInt64 result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

[CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out ulong result)
{
Expand Down
4 changes: 4 additions & 0 deletions src/mscorlib/src/System/Decimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
return Number.TryParseDecimal(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
public static bool TryParse(ReadOnlySpan<char> s, out decimal result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
TryParse(s, style, provider, out result);

public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out decimal result)
{
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
Expand Down

0 comments on commit c92a1ed

Please sign in to comment.