Skip to content

Commit

Permalink
Do some cleanup on TimeSpan to ensure better inlining and clearer sem…
Browse files Browse the repository at this point in the history
…antics
  • Loading branch information
tannergooding committed Oct 31, 2023
1 parent f2e4ddf commit c687355
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpres
}
}

internal static void ThrowIfNull([NotNull] object? argument, ExceptionArgument paramName)
{
if (argument is null)
{
ThrowHelper.ThrowArgumentNullException(paramName);
}
}

/// <summary>Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is null.</summary>
/// <param name="argument">The pointer argument to validate as non-null.</param>
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
Expand Down
18 changes: 18 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ internal static void ThrowArgumentException_DestinationTooShort()
throw new ArgumentException(SR.Argument_DestinationTooShort, "destination");
}

[DoesNotReturn]
internal static void ThrowArgumentException_InvalidTimeSpanStyles()
{
throw new ArgumentException(SR.Argument_InvalidTimeSpanStyles, "styles");
}

[DoesNotReturn]
internal static void ThrowArgumentException_OverlapAlignmentMismatch()
{
Expand Down Expand Up @@ -224,12 +230,24 @@ internal static void ThrowOverflowException()
throw new OverflowException();
}

[DoesNotReturn]
internal static void ThrowOverflowException_NegateTwosCompNum()
{
throw new OverflowException(SR.Overflow_NegateTwosCompNum);
}

[DoesNotReturn]
internal static void ThrowOverflowException_TimeSpanTooLong()
{
throw new OverflowException(SR.Overflow_TimeSpanTooLong);
}

[DoesNotReturn]
internal static void ThrowOverflowException_TimeSpanDuration()
{
throw new OverflowException(SR.Overflow_Duration);
}

[DoesNotReturn]
internal static void ThrowArgumentException_Arg_CannotBeNaN()
{
Expand Down
Loading

0 comments on commit c687355

Please sign in to comment.