question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making ValueObject.GetEqualityComponents return IComparable is a breaking change

See original GitHub issue

Previously GetEqualityComponents() returned IEnumerable<object>. Now it returns IEnumerable<IComparable>. If the ValueObject holds an Entity and it is used as an Equality Component it causes a compile time error if the Entity doesn’t implement IComparable.

What is the appropriate fix here? Every type that ValueObject uses as an Equality Component must now implement IComparable? Could this extend to the CSharpFunctionalExtensions Entity type so entities have it is available out-of-the-box?

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vkhorikovcommented, Jun 27, 2023

Yes, that’s a good idea. No particular reason why it’s not done yet. Appreciate if you could submit a PR.

0reactions
Szuuukencommented, Aug 22, 2023

Hi, this is also a breaking change for any kind of list or array ValueObjects. The following Examples aren’t possible any more:

Value Object as an byte array
public class FileContent : SimpleValueObject<byte[]>
{
    public FileContent(byte[] value) : base(value)
    {
    }
}

Value Object as a List of ValueObjects
public class Thing: SimpleValueObject<string>
{
    public Thing(string value) : base(value)
    {
    }
}

public class MultpleThings: SimpleValueObject<List<Thing>>
{
    public MultpleThings(List<Thing> value) : base(value)
    {
    }
}

Do you have any suggestions how to solve such scenarios?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IComparable<ValueObject> is Potentially Breaking due to ...
The tests then fail when calling the Be() method from FluentAssertions, because it checks that the comparison returns 0, but my ValueObjects ......
Read more >
Value Object: a better implementation
This post is about a better implementation of Value Object. ... var valueObject = (ValueObject)obj; return GetEqualityComponents().
Read more >
CA1036: Override methods on comparable types
A type implements the System.IComparable interface and does not override System.Object.Equals or does not overload the language-specific ...
Read more >
micro-elements - MicroElements.Functional 1.0.0-beta.4
To implement ValueObject you need: implement Object.Equals; implement Object.GetHashCode; implement Equality operator; implement Inequality operator; implement ...
Read more >
Microservices Architecture for Containerized NET Applications
It discusses architectural design and implementation approaches using .NET and. Docker containers. To make it easier to get started, the guide focuses on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found