-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Structural equals for infer and IUrlParameter types #3126
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - always amazes me the hoops we have to jump to in order to give C# structural equality semantics!
👍 tests
@@ -193,6 +200,16 @@ internal static bool IsNullOrEmpty(this string value) | |||
{ | |||
return string.IsNullOrWhiteSpace(value); | |||
} | |||
internal static bool IsNullOrEmptyCommaSeparatedList(this string value, out string[] split) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a .All(...)
LINQ extension? might save initialising the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...PEBKAC, just noticed the out
parameter!
} | ||
|
||
public static IndexName From<T>() => typeof(T); | ||
public static IndexName From<T>(string clusterName) => From(typeof(T), clusterName); | ||
private static IndexName From(Type t, string clusterName) => new IndexName(t, clusterName); | ||
// TODO private? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left it in there to tackle at a later stage (not related to commit).
Yeah this stuff should come baked cough |
… and not a referential Equals() move equality test folder one level down into Inferrence Trim() is bad on singular types, removed triming from them as it only hides bugs. Moved the trim to plural type parsing of multi valued strings made sure implicit conversion from null/empty string/empty comma separated string all behave the same (return null) for IUrlParameters and Infer types Made sure null flows through all the Equals implementations and fixed existing tests that failed due to the updated implementation
d2d527c
to
ea930b3
Compare
Amended to not take |
* All IUrlParameter and infer types now implement a structural Equals() and not a referential Equals() move equality test folder one level down into Inferrence Trim() is bad on singular types, removed triming from them as it only hides bugs. Moved the trim to plural type parsing of multi valued strings made sure implicit conversion from null/empty string/empty comma separated string all behave the same (return null) for IUrlParameters and Infer types Made sure null flows through all the Equals implementations and fixed existing tests that failed due to the updated implementation * boost should not be part of field equality afterall, (current behaviour)
IIRC, it was to do with field expression caching. If memory serves, the original expression overload did not accept a boost in the early 2.x days, and was added later. |
* Structural equals for infer and IUrlParameter types (#3126) * All IUrlParameter and infer types now implement a structural Equals() and not a referential Equals() move equality test folder one level down into Inferrence Trim() is bad on singular types, removed triming from them as it only hides bugs. Moved the trim to plural type parsing of multi valued strings made sure implicit conversion from null/empty string/empty comma separated string all behave the same (return null) for IUrlParameters and Infer types Made sure null flows through all the Equals implementations and fixed existing tests that failed due to the updated implementation * boost should not be part of field equality afterall, (current behaviour) * undo private EqualsString on RelationName, already public in 6.x
All
IUrlParameter
andInfer
types now implement a structuralEquals()
and not a referentialEquals()
IEquatable<>
Field
now takes boost value into account, this was previously explicitly documented as desired behaviour but I can remember why this was the case, @russcam any ideas?