Skip to content

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

Merged
merged 2 commits into from
Mar 19, 2018
Merged

Conversation

Mpdreamz
Copy link
Member

All IUrlParameter and Infer types now implement a structural Equals() and not a referential Equals()

  • Trim() is bad on singular types, removed this from them as it only hides bugs. Moved the trim to plural type parsing of multi valued comma separated strings.
  • Made sure all implementations implement IEquatable<>
  • 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

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?

@Mpdreamz Mpdreamz requested review from russcam and codebrain March 13, 2018 13:29
Copy link
Contributor

@codebrain codebrain left a 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)
Copy link
Contributor

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.

Copy link
Contributor

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?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO?

Copy link
Member Author

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).

@Mpdreamz
Copy link
Member Author

Mpdreamz commented Mar 19, 2018

Yeah this stuff should come baked cough F# 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
@Mpdreamz
Copy link
Member Author

Mpdreamz commented Mar 19, 2018

Amended to not take boost into account on Field this would cause fields with different boost values to be cached separately which is undesirable. Conceptually i can live with field^1 == field^3 too.

@Mpdreamz Mpdreamz merged commit 897b2c6 into master Mar 19, 2018
Mpdreamz added a commit that referenced this pull request Mar 19, 2018
* 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)
@Mpdreamz Mpdreamz deleted the fix/op-overload branch March 19, 2018 12:49
@Mpdreamz Mpdreamz mentioned this pull request Mar 19, 2018
@russcam
Copy link
Contributor

russcam commented Mar 19, 2018

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?

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.

codebrain pushed a commit that referenced this pull request Apr 13, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants