CompareReadOnly = false still generates diff in IReadOnlyCollection.Count
See original GitHub issueFrom 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:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is a Stack Overflow answer about the process: https://stackoverflow.com/questions/44415291/how-to-create-a-git-pull-request-on-a-public-github-repository
Merged. Thanks so much.