mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
Allow null input in TimeSpanParser.TryParse
This commit is contained in:
parent
fdc9e64cbe
commit
94a841b2fc
@ -108,6 +108,7 @@
|
||||
- X10D.Unity: Added `WaitForTimeSpanRealtimeNoAlloc` yield instruction
|
||||
|
||||
### Changed
|
||||
- X10D: `TimeSpanParser.TryParse` now accepts a nullable string, and returns false if this input is null or empty
|
||||
- X10D.Unity: Obsolesced `Singleton<T>`
|
||||
|
||||
## [3.1.0]
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace X10D.Time;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace X10D.Time;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a class which contains a <see cref="string" /> parser which converts into <see cref="TimeSpan" />.
|
||||
@ -54,15 +56,15 @@ public static class TimeSpanParser
|
||||
/// </param>
|
||||
/// <param name="result">When this method returns, contains the parsed result.</param>
|
||||
/// <returns><see langword="true" /> if the parse was successful, <see langword="false" /> otherwise.</returns>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||
public static bool TryParse(string value, out TimeSpan result)
|
||||
public static bool TryParse([NotNullWhen(true)] string? value, out TimeSpan result)
|
||||
{
|
||||
if (value is null)
|
||||
result = TimeSpan.Zero;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
return false;
|
||||
}
|
||||
|
||||
result = TimeSpan.Zero;
|
||||
var unitValue = 0;
|
||||
|
||||
for (var index = 0; index < value.Length; index++)
|
||||
|
Loading…
Reference in New Issue
Block a user