Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ae753cb

Browse files
stephentoubsafern
authored andcommitted
Temporarily add back old TryParse signatures (dotnet/coreclr#14893)
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. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 7848223 commit ae753cb

File tree

11 files changed

+59
-0
lines changed

11 files changed

+59
-0
lines changed

src/Common/src/CoreLib/System/Byte.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ public static bool TryParse(ReadOnlySpan<char> s, out byte result)
137137
return TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
138138
}
139139

140+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
141+
public static bool TryParse(ReadOnlySpan<char> s, out byte result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
142+
TryParse(s, style, provider, out result);
143+
140144
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Byte result)
141145
{
142146
NumberFormatInfo.ValidateParseStyleInteger(style);

src/Common/src/CoreLib/System/Double.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
324324
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
325325
}
326326

327+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
328+
public static bool TryParse(ReadOnlySpan<char> s, out double result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
329+
TryParse(s, style, provider, out result);
330+
327331
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out double result)
328332
{
329333
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);

src/Common/src/CoreLib/System/Int16.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
185185
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
186186
}
187187

188+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
189+
public static bool TryParse(ReadOnlySpan<char> s, out Int16 result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
190+
TryParse(s, style, provider, out result);
191+
188192
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out short result)
189193
{
190194
NumberFormatInfo.ValidateParseStyleInteger(style);

src/Common/src/CoreLib/System/Int32.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
171171
return Number.TryParseInt32(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
172172
}
173173

174+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
175+
public static bool TryParse(ReadOnlySpan<char> s, out int result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
176+
TryParse(s, style, provider, out result);
177+
174178
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out int result)
175179
{
176180
NumberFormatInfo.ValidateParseStyleInteger(style);

src/Common/src/CoreLib/System/Int64.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
159159
return Number.TryParseInt64(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
160160
}
161161

162+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
163+
public static bool TryParse(ReadOnlySpan<char> s, out long result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
164+
TryParse(s, style, provider, out result);
165+
162166
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out long result)
163167
{
164168
NumberFormatInfo.ValidateParseStyleInteger(style);

src/Common/src/CoreLib/System/SByte.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
205205
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
206206
}
207207

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

src/Common/src/CoreLib/System/Single.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ public static Boolean TryParse(String s, NumberStyles style, IFormatProvider pro
314314
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
315315
}
316316

317+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
318+
public static Boolean TryParse(ReadOnlySpan<char> s, out Single result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) =>
319+
TryParse(s, style, provider, out result);
320+
317321
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out float result)
318322
{
319323
NumberFormatInfo.ValidateParseStyleFloatingPoint(style);

src/Common/src/CoreLib/System/TimeSpan.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ public static bool TryParse(ReadOnlySpan<char> s, out TimeSpan result)
370370
{
371371
return TimeSpanParse.TryParse(s, null, out result);
372372
}
373+
374+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
375+
public static bool TryParse(ReadOnlySpan<char> input, out TimeSpan result, IFormatProvider formatProvider = null) =>
376+
TryParse(input, formatProvider, out result);
377+
373378
public static Boolean TryParse(String input, IFormatProvider formatProvider, out TimeSpan result)
374379
{
375380
if (input == null)
@@ -409,6 +414,11 @@ public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFo
409414
{
410415
return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, TimeSpanStyles.None, out result);
411416
}
417+
418+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
419+
public static bool TryParseExact(ReadOnlySpan<char> input, string format, IFormatProvider formatProvider, out TimeSpan result, TimeSpanStyles styles = TimeSpanStyles.None) =>
420+
TryParseExact(input, format, formatProvider, styles, out result);
421+
412422
public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
413423
{
414424
ValidateStyles(styles, nameof(styles));
@@ -434,6 +444,11 @@ public static Boolean TryParseExact(String input, String[] formats, IFormatProvi
434444
}
435445
return TimeSpanParse.TryParseExactMultiple(input.AsReadOnlySpan(), formats, formatProvider, styles, out result);
436446
}
447+
448+
// TODO https://github.com/dotnet/corefx/issues/23642: Remove once corefx has been updated with new overloads.
449+
public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, out TimeSpan result, TimeSpanStyles styles = TimeSpanStyles.None) =>
450+
TryParseExact(input, formats, formatProvider, styles, out result);
451+
437452
public static bool TryParseExact(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
438453
{
439454
ValidateStyles(styles, nameof(styles));

src/Common/src/CoreLib/System/UInt16.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
174174
return TryParse(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
175175
}
176176

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

src/Common/src/CoreLib/System/UInt32.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ public static bool TryParse(String s, NumberStyles style, IFormatProvider provid
166166
return Number.TryParseUInt32(s.AsReadOnlySpan(), style, NumberFormatInfo.GetInstance(provider), out result);
167167
}
168168

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

0 commit comments

Comments
 (0)