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.

CompareReadOnly = false still generates diff in IReadOnlyCollection.Count

See original GitHub issue

From IReadOnlyCollection:

//
// Summary:
//     Represents a strongly-typed, read-only collection of elements.
//
// Type parameters:
//   T:
//     The type of the elements.
public interface IReadOnlyCollection<out T> : IEnumerable<T>, IEnumerable
{
    //
    // Summary:
    //     Gets the number of elements in the collection.
    //
    // Returns:
    //     The number of elements in the collection.
    int Count
    {
        get;
    }
}

Since Count is readonly, I thought it would not generate a diff when comparing 2 instances of CompanyDTO, when I have added a new address:

CompanyDTO
{
    IReadOnlyCollection<AddressDTO> Addresses { get; init; }
 }

It does generate a diff for the added address, which is fine, but I’m seeing another diff saying that Addresses.Count has changed as well.

Is there some way of avoiding this form being output?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GregFinzercommented, Mar 10, 2022
0reactions
GregFinzercommented, Mar 18, 2022

Merged. Thanks so much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IReadOnlyCollection vs ReadOnlyCollection
ReadOnlyCollection however cannot be cast into a List , but it means returning a concrete class.
Read more >
ReadOnlyCollection<T> Class
Produces the set difference of two sequences by using the specified IEqualityComparer<T> to compare values. Produces the set difference of two sequences ...
Read more >
IEnumerable vs IReadOnlyList
The only difference between IEnumerable and IReadOnlyList is that the latter provides a richer API (Count, and accessing elements by index). In ...
Read more >
Example of why IReadOnlyList<T> is better than public List ...
This by itself has nothing to do with lists, regardless of whether they're readonly or not. So your example is not good. Not...
Read more >
C# Read-Only Collections and LSP
Despite the design became simpler, it still had a significant disadvantage: you had to check the IsReadOnly flag in order to find out...
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