Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed generic type declaration. #49

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Fluxera.StronglyTypedId/StronglyTypedId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
/// <typeparam name="TValue">The type of the IDs value.</typeparam>
[PublicAPI]
[TypeConverter(typeof(StronglyTypedIdConverter))]
public abstract class StronglyTypedId<TStronglyTypedId, TValue> : IComparable<TStronglyTypedId>, IEquatable<TStronglyTypedId>
public abstract class StronglyTypedId<TStronglyTypedId, TValue> :
IComparable<StronglyTypedId<TStronglyTypedId, TValue>>,
IEquatable<StronglyTypedId<TStronglyTypedId, TValue>>
where TStronglyTypedId : StronglyTypedId<TStronglyTypedId, TValue>
where TValue : IComparable, IComparable<TValue>, IEquatable<TValue>
{
Expand Down Expand Up @@ -124,7 +126,7 @@ public static bool TryParse(string value, out TStronglyTypedId id)
}

/// <summary>
/// Creates a new instance of the <see cref="TStronglyTypedId"/> with the given value.
/// Creates a new instance of the strongly-typed ID with the given value.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
Expand All @@ -134,7 +136,7 @@ public static TStronglyTypedId Create(TValue value)
}

/// <inheritdoc />
public bool Equals(TStronglyTypedId other)
public bool Equals(StronglyTypedId<TStronglyTypedId, TValue> other)
{
return this.Equals(other as object);
}
Expand All @@ -147,7 +149,7 @@ public sealed override bool Equals(object obj)
return false;
}

if(object.ReferenceEquals(this, obj))
if(ReferenceEquals(this, obj))
{
return true;
}
Expand All @@ -159,7 +161,7 @@ public sealed override bool Equals(object obj)
}

/// <inheritdoc />
public int CompareTo(TStronglyTypedId other)
public int CompareTo(StronglyTypedId<TStronglyTypedId, TValue> other)
{
return (this.Value, other.Value) switch
{
Expand Down Expand Up @@ -201,10 +203,10 @@ public static implicit operator TValue(StronglyTypedId<TStronglyTypedId, TValue>
}

/// <summary>
/// Converts a value explicitly to an instance of TStronglyTypedId.
/// Converts a value implicitly to an instance of TStronglyTypedId.
/// </summary>
/// <param name="value"></param>
public static explicit operator StronglyTypedId<TStronglyTypedId, TValue>(TValue value)
public static implicit operator StronglyTypedId<TStronglyTypedId, TValue>(TValue value)
{
return Create(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task ShouldFindByStronglyTypedId()
linqFilterResult.Should().NotBeNull();
}

[Ignore("Fix this later")]
[Ignore("Fix this later. Drop .NET 7 in november?")]
[Test]
public async Task ShouldFindByValue()
{
Expand Down
Loading