Implement NormalizeLineEndings - #4976
Conversation
| /// </summary> | ||
| internal sealed class LineEndingNormalizingStringComparer : IEqualityComparer<string> | ||
| { | ||
| /// <summary> |
There was a problem hiding this comment.
Only two of these are used, but I just created singletons for all 6 StringComparison values.
| return x.Equals(y, ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.Ordinal); | ||
| IEqualityComparer<string> comparer = (ignoreCase, NormalizeLineEndings) switch | ||
| { | ||
| (true, true) => LineEndingNormalizingStringComparer.CurrentCultureIgnoreCase, |
There was a problem hiding this comment.
CurrentCultureIgnoreCase and Ordinal to be consistent with the existing code.
| _contents = new List<object?>(source); | ||
| } | ||
|
|
||
| public override string ToString() => $"SimpleObjectCollection [{string.Join(", ", _contents)}]"; |
There was a problem hiding this comment.
Updated because I found Test Explorer misleading without this.
manfred-brands
left a comment
There was a problem hiding this comment.
Thanks @Bartleby2718 for your contribution.
You already found your casing problem in parameters and fields.
It would have been easier if you had just fixed the instead of putting a comment on your own PR that you need to fix it.
The actual comparer looks good.
The main change I would like is to rename the word "Normalize" and "Normalizing"
One what is normal for one might not be normal for another.
But more to match the other modifiers that it "Ignore" an aspect.
It doesn't change any strings but ignores different style line endings.
manfred-brands
left a comment
There was a problem hiding this comment.
Thanks @Bartleby2718. mostly fine.
A few things remain.
This returned the same number for every string, which is technically allowed. It just cuased the unit test to slow down dramatically.
|
@Bartleby2718 There is a serious performance degradation: I have traced it down to a subtle line I missed in my review: |
This fixes #4975.