Comments (4)
It's a very good point! Perhaps I can actually check if both the enumerables implement IDictionary<TKey, TValue> and avoid the extra allocation. Cheers for pointing that out!
from generator.equals.
It's a very good point! Perhaps I can actually check if both the enumerables implement IDictionary<TKey, TValue> and avoid the extra allocation. Cheers for pointing that out!
Agreed. You can also add
// If we have two collections with different counts, we can efficiently resolve their inequality
if (x is ICollection<T> xCollection && y is ICollection<T> yCollection && xCollection.Count != yCollection.Count)
return false;
// If we a set, we can use its optimized SetEquals method
if (x is ISet<T> xSet) return xSet.SetEquals(y);
if (y is ISet<T> ySet) return ySet.SetEquals(x);
from generator.equals.
I implemented this and bumped the version to 1.0.0 since it's a breaking change and I think it's decent enough to be called 1.0!
Regarding the SetEquals, I did not use your suggestion as UnorderedEquality is not intended to have set semantics. That would require a new attribute, likely called SetEquality.
from generator.equals.
I actually went ahead and renamed the attributes to OrderedEquality and UnorderedEquality to make it more clear, ended up having to bump to 2.0.0 just to be consistent with SemVer.
from generator.equals.
Related Issues (20)
- Indexers on classes lead to syntactically invalid generated code HOT 1
- Compiler-error with static properties HOT 1
- Suppress obsolete warnings in generated code HOT 2
- Explicit mode HOT 3
- Remove the runtime dependency HOT 3
- Replace MSTest and NUnit with Xunit.
- Support for struct HOT 4
- Support for Record Struct HOT 2
- What if properties of a class are also generated by another code generator? HOT 6
- Inherited classes Equals ignored when called from the base class HOT 6
- Inherited classes Equals ignored when using OrderedEquality on an array of the base class HOT 16
- Cleanup IEquatable<T> implementation for classes HOT 1
- NullReferenceExceptions starting with v2.7.2 HOT 4
- Feature Request: Would be great to be able to enumerate the properties that are different! HOT 5
- Feature Request: Create comparer for strings HOT 2
- `IEnumerable<T>` property marked by `[UnorderedEquality]` causes exception during generation HOT 7
- Probably, the generator is not incremental HOT 2
- Add license information in csproj/Nuget HOT 2
- Compatibility with the mvvm community toolkit HOT 4
- Support StringEqualityAttribute on collections of strings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator.equals.