Skip to content

Commit

Permalink
Add overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Nov 17, 2023
1 parent c51c22a commit 71efe9e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions AssetRipper.Primitives/SequentialUnityVersionComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,72 @@ public static int Compare(UnityVersion x, UnityVersion y)

public static bool LessThan(UnityVersion x, UnityVersion y) => Compare(x, y) < 0;

public static bool LessThan(UnityVersion value, ushort major) => LessThan(value, new UnityVersion(major, ushort.MinValue, ushort.MinValue, UnityVersionTypeMinValue, byte.MinValue));

public static bool LessThan(UnityVersion value, ushort major, ushort minor) => LessThan(value, new UnityVersion(major, minor, ushort.MinValue, UnityVersionTypeMinValue, byte.MinValue));

public static bool LessThan(UnityVersion value, ushort major, ushort minor, ushort build) => LessThan(value, new UnityVersion(major, minor, build, UnityVersionTypeMinValue, byte.MinValue));

public static bool LessThan(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type) => LessThan(value, new UnityVersion(major, minor, build, type, byte.MinValue));

public static bool LessThan(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type, byte typeNumber) => LessThan(value, new UnityVersion(major, minor, build, type, typeNumber));

public static bool LessThanOrEquals(UnityVersion x, UnityVersion y) => Compare(x, y) <= 0;

public static bool LessThanOrEquals(UnityVersion value, ushort major) => LessThanOrEquals(value, new UnityVersion(major, ushort.MaxValue, ushort.MaxValue, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool LessThanOrEquals(UnityVersion value, ushort major, ushort minor) => LessThanOrEquals(value, new UnityVersion(major, minor, ushort.MaxValue, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool LessThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build) => LessThanOrEquals(value, new UnityVersion(major, minor, build, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool LessThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type) => LessThanOrEquals(value, new UnityVersion(major, minor, build, type, byte.MaxValue));

public static bool LessThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type, byte typeNumber) => LessThanOrEquals(value, new UnityVersion(major, minor, build, type, typeNumber));

public static bool Equals(UnityVersion x, UnityVersion y) => x == y;

public static bool Equals(UnityVersion value, ushort major) => Equals(value, new UnityVersion(major, value.Minor, value.Build, value.Type, value.TypeNumber));

public static bool Equals(UnityVersion value, ushort major, ushort minor) => Equals(value, new UnityVersion(major, minor, value.Build, value.Type, value.TypeNumber));

public static bool Equals(UnityVersion value, ushort major, ushort minor, ushort build) => Equals(value, new UnityVersion(major, minor, build, value.Type, value.TypeNumber));

public static bool Equals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type) => Equals(value, new UnityVersion(major, minor, build, type, value.TypeNumber));

public static bool Equals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type, byte typeNumber) => Equals(value, new UnityVersion(major, minor, build, type, typeNumber));

public static bool GreaterThan(UnityVersion x, UnityVersion y) => Compare(x, y) > 0;

public static bool GreaterThan(UnityVersion value, ushort major) => GreaterThan(value, new UnityVersion(major, ushort.MaxValue, ushort.MaxValue, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool GreaterThan(UnityVersion value, ushort major, ushort minor) => GreaterThan(value, new UnityVersion(major, minor, ushort.MaxValue, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool GreaterThan(UnityVersion value, ushort major, ushort minor, ushort build) => GreaterThan(value, new UnityVersion(major, minor, build, UnityVersionTypeMaxValue, byte.MaxValue));

public static bool GreaterThan(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type) => GreaterThan(value, new UnityVersion(major, minor, build, type, byte.MaxValue));

public static bool GreaterThan(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type, byte typeNumber) => GreaterThan(value, new UnityVersion(major, minor, build, type, typeNumber));

public static bool GreaterThanOrEquals(UnityVersion x, UnityVersion y) => Compare(x, y) >= 0;

public static bool GreaterThanOrEquals(UnityVersion value, ushort major) => GreaterThanOrEquals(value, new UnityVersion(major, ushort.MinValue, ushort.MinValue, UnityVersionTypeMinValue, byte.MinValue));

public static bool GreaterThanOrEquals(UnityVersion value, ushort major, ushort minor) => GreaterThanOrEquals(value, new UnityVersion(major, minor, ushort.MinValue, UnityVersionTypeMinValue, byte.MinValue));

public static bool GreaterThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build) => GreaterThanOrEquals(value, new UnityVersion(major, minor, build, UnityVersionTypeMinValue, byte.MinValue));

public static bool GreaterThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type) => GreaterThanOrEquals(value, new UnityVersion(major, minor, build, type, byte.MinValue));

public static bool GreaterThanOrEquals(UnityVersion value, ushort major, ushort minor, ushort build, UnityVersionType type, byte typeNumber) => GreaterThanOrEquals(value, new UnityVersion(major, minor, build, type, typeNumber));

private static bool UsesYearNumbering(UnityVersion version) => version.Major is >= 2017 and <= 2023;

private const int FirstNewVersion = 6;

private const UnityVersionType UnityVersionTypeMinValue = byte.MinValue;

private const UnityVersionType UnityVersionTypeMaxValue = (UnityVersionType)byte.MaxValue;

int IComparer<UnityVersion>.Compare(UnityVersion x, UnityVersion y) => Compare(x, y);

bool IEqualityComparer<UnityVersion>.Equals(UnityVersion x, UnityVersion y) => x == y;
Expand Down

0 comments on commit 71efe9e

Please sign in to comment.