Skip to content

Commit

Permalink
Add comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Nov 12, 2023
1 parent b9d3a25 commit d4fe612
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/guid-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/int-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/long-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/newid-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/nullablestring-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other)
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds.Templates/string-full.typedid
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other)
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds/EmbeddedSources.Guid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public override bool Equals(object? obj)
public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;
/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds/EmbeddedSources.Int.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public override bool Equals(object? obj)
public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;
/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds/EmbeddedSources.Long.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public override bool Equals(object? obj)
public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;
/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other) => Value.CompareTo(other.Value);
Expand Down
4 changes: 4 additions & 0 deletions src/StronglyTypedIds/EmbeddedSources.String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public override bool Equals(object? obj)
public static bool operator ==(PLACEHOLDERID a, PLACEHOLDERID b) => a.Equals(b);
public static bool operator !=(PLACEHOLDERID a, PLACEHOLDERID b) => !(a == b);
public static bool operator > (PLACEHOLDERID a, PLACEHOLDERID b) => return a.CompareTo(b) > 0;
public static bool operator < (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) < 0;
public static bool operator >= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) >= 0;
public static bool operator <= (PLACEHOLDERID a, PLACEHOLDERID b) => a.CompareTo(b) <= 0;
/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(PLACEHOLDERID other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace MyContracts.V1

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down Expand Up @@ -264,6 +268,10 @@ namespace MyContracts.V2

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ namespace SomeNamespace

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

public static bool operator ==(MyId a, MyId b) => a.Equals(b);
public static bool operator !=(MyId a, MyId b) => !(a == b);
public static bool operator > (MyId a, MyId b) => return a.CompareTo(b) > 0;
public static bool operator < (MyId a, MyId b) => a.CompareTo(b) < 0;
public static bool operator >= (MyId a, MyId b) => a.CompareTo(b) >= 0;
public static bool operator <= (MyId a, MyId b) => a.CompareTo(b) <= 0;

/// <inheritdoc cref="global::System.IComparable{TSelf}"/>
public int CompareTo(MyId other) => Value.CompareTo(other.Value);
Expand Down

0 comments on commit d4fe612

Please sign in to comment.