1

Topic: Real Life ComparerBuilder

Flooded in github the old subject Except absence Emit there are two more  on a pie: 1. An option "Null go earlier/later not-nallov?" 2. It is more . In an example more low ahead there are doctors, and at first 42-year-old, then all remaining sorted by a name,  and to age. An example public class Demo {class Person {public string Title; public string Name; public int? Age;} public static void Test () {StringComparer ignoreCase = StringComparer.InvariantCultureIgnoreCase; string highlightTitle = "Dr." ; int highlightAge = 42; IComparer <Person> comparer = new ComparerBuilder <Person> ().Compare (x => ignoreCase. Equals (highlightTitle x. Title)).Compare (x = x. Age. HasValue && highlightAge x. Age. Value).CompareString (x = x. Name, ignoreCase).CompareString (x = x. Title, ignoreCase).Compare (x = x. Age, OrderFlavour. Backward | OrderFlavour. NullGoesFinally).GetComparer (); Enumerable. Empty <Person> ().ToList ().Sort (comparer); Enumerable. Empty <Person> ().OrderBy (x => x, comparer).ToList ();}} Itself ComparerBuilder.cs (about 100 lines of the code) it is clear that if to sort ValueTypes that will be short-lived . Other jambs are? P.S. By the way, and why in Enumerable is not present IOrderedEnumerable <TSource> OrderBy <TSource, TKey> (this IEnumerable <TSource> source, IComparer <TSource> comparer)

2

Re: Real Life ComparerBuilder

Looked in ComparerBuilder from CodeJam. 1. He  not IComparer <T> about what  hints a class title, and IEqualityComparer <T>. I.e. title ComparerBuilder misleads. Except me anybody of it does not see? 2. And from tests/inquiries unobviously that in method ComparerBuilder <>.GetEqualityComparer it is possible to transfer the arbitrary function and not just properties/fields More precisely here this help does not represent the facts:///<summary>///Returns implementations of the <see cref = "T:System.Collections.Generic.IEqualityComparer`1"/> generic interface///based on provided object public members equality.///</summary>///<param name = "membersToCompare"> Members to compare. </param>///<returns> Instance of <see cref = "T:System.Collections.Generic.IEqualityComparer`1"/>. </returns> [NotNull, Pure] public static IEqualityComparer <T> GetEqualityComparer ([NotNull] params Expression <Func <T, object>> [] membersToCompare) Here it is written that it is necessary to transfer Memebers, What not  realities. At least here such my test transits (in comaprerbuildertest.cs): [Test] public void EqualityComparer_Can_Use_Any_Expression_as_MembersToCompare_Parameter () {var theAnswer = 42; var comparer = ComparerBuilder <A>.GetEqualityComparer (o => o. Value == theAnswer, o => o. Overridable); {var o1 = new A {Value = 10, Overridable = 20}; var o2 = new A {Value = 11, Overridable = 20}; Assert. That (comparer. Equals (o1, o2), Is. True);} {var o1 = new A {Value = 42, Overridable = 20}; var o2 = new A {Value = 10, Overridable = 20}; Assert. That (comparer. Equals (o1, o2), Is. False);} } To send pull-request with corrected help and one more test above? Or I badly looked? 3. Obviously that  the agreement  for test methods of unit-tests does not approach. The sentence-statement in which words are divided  should be a title the method test. As my test above.

3

Re: Real Life ComparerBuilder

Hello, VladCore, you wrote: VC> to Send pull-request with corrected help and one more test above? Went VC> 3. Obviously that  the agreement  for test methods of unit-tests does not approach. What for standard agreements? VC> the sentence-statement in which words are divided  should be a title the method test. As my test above. To whom should? Agreements on coding RSDN explicitly speak about inadmissibility  in method names.... <<RSDN@Home 1.0.0 alpha 5 rev. 0 on Windows 8 6.2.9200.0>>