1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 03:42:57 +08:00

Use ArgumentOutOfRangeException throw helper methods

This commit is contained in:
Berkan Diler 2024-03-05 10:20:30 +01:00
parent 9bac60a98f
commit a891303484
8 changed files with 10 additions and 15 deletions

View File

@ -58,9 +58,9 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
private void applyStacking(Beatmap<OsuHitObject> beatmap, int startIndex, int endIndex)
{
if (startIndex > endIndex) throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} cannot be greater than {nameof(endIndex)}.");
if (startIndex < 0) throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} cannot be less than 0.");
if (endIndex < 0) throw new ArgumentOutOfRangeException(nameof(endIndex), $"{nameof(endIndex)} cannot be less than 0.");
ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex, endIndex);
ArgumentOutOfRangeException.ThrowIfNegative(startIndex);
ArgumentOutOfRangeException.ThrowIfNegative(endIndex);
int extendedEndIndex = endIndex;

View File

@ -334,7 +334,7 @@ namespace osu.Game.Rulesets.Osu.Edit
/// <returns>The <see cref="OsuDistanceSnapGrid"/> from a selected <see cref="HitObject"/> to a target <see cref="HitObject"/>.</returns>
private OsuDistanceSnapGrid createGrid(Func<HitObject, bool> sourceSelector, int targetOffset = 1)
{
if (targetOffset < 1) throw new ArgumentOutOfRangeException(nameof(targetOffset));
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(targetOffset);
int sourceIndex = -1;

View File

@ -23,8 +23,7 @@ namespace osu.Game.Beatmaps.Timing
public TimeSignature(int numerator)
{
if (numerator < 1)
throw new ArgumentOutOfRangeException(nameof(numerator), numerator, "The numerator of a time signature must be positive.");
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(numerator);
Numerator = numerator;
}

View File

@ -27,8 +27,7 @@ namespace osu.Game.Rulesets.Difficulty.Utils
public ReverseQueue(int initialCapacity)
{
if (initialCapacity <= 0)
throw new ArgumentOutOfRangeException(nameof(initialCapacity));
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(initialCapacity);
items = new T[initialCapacity];
capacity = initialCapacity;

View File

@ -40,8 +40,7 @@ namespace osu.Game.Rulesets.Objects.Types
public static PathType BSpline(int degree)
{
if (degree <= 0)
throw new ArgumentOutOfRangeException(nameof(degree), "The degree of a B-Spline path must be greater than zero.");
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(degree);
return new PathType { Type = SplineType.BSpline, Degree = degree };
}

View File

@ -33,8 +33,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// <param name="items">The <see cref="SimpleStatisticItem"/>s to display in this row.</param>
public SimpleStatisticTable(int columnCount, [ItemNotNull] IEnumerable<SimpleStatisticItem> items)
{
if (columnCount < 1)
throw new ArgumentOutOfRangeException(nameof(columnCount));
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(columnCount);
this.columnCount = columnCount;
this.items = items.ToArray();

View File

@ -35,8 +35,7 @@ namespace osu.Game.Utils
/// <param name="capacity">The number of items the queue can hold.</param>
public LimitedCapacityQueue(int capacity)
{
if (capacity < 0)
throw new ArgumentOutOfRangeException(nameof(capacity));
ArgumentOutOfRangeException.ThrowIfNegative(capacity);
this.capacity = capacity;
array = new T[capacity];

View File

@ -58,7 +58,7 @@ namespace osu.Game.Utils
/// </param>
public static int NextInt(int maxValue, int seed, int series = 0)
{
if (maxValue <= 0) throw new ArgumentOutOfRangeException(nameof(maxValue));
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(maxValue);
return (int)(NextULong(seed, series) % (ulong)maxValue);
}