Assert.AreEqual string: consider replacing whitespaces by a symbol
Describe the bug
When reviewing diffs for Assert.AreEqual of strings, it's sometimes uneasy to understand how many spaces there are. Let's take:
Assert.AreEqual failed. Expected string length 199 but was 139. 'expected' expression: 'Normalize(expected)', 'actual' expression: 'Normalize(actual)'.
Expected: "...n 1; }␊ #endregion␊␊ #region ..."
But was: "...n 1; }␊ #endregion␊ #endregion␊}"
Expected behavior
Space is replaced with a symbol:
-
␣- Space (U+2423 OPEN BOX) -
·- Middle dot
Nit: if that's not already handled, also consider replacing tabs:
→ - Tab (can also use ⇥ or ␉)
Since v4 we replace common formatting characters with their visible version. Except for spaces and tabs. We don't control how they are rendered, we just change the character to visible.
Space is not replaced because it impacts readability of longer text when spaces are not the difference.
Tab is not replaced because it would break formatting of text. But in this case it probably does not matter as much since it is 1 line only.
We do however have the indicator of where the difference is, which should make it even more obvious where the difference is.
I think we could have a heuristic here specific to multi-line diffing, similar to how the diffing from Roslyn testing library works. I think Roslyn testing uses https://github.com/mmanela/diffplex. I'm not sure how feasible it is to add such extra dependency to MSTest. Or alternatively, we copy the needed parts from DiffPlex with license notice (we might want to confirm with CELA about the licensing stuff and whether we can copy from DiffPlex).
We might even consider if DiffPlex provides good diffing for single-line and use that instead.
Related: https://github.com/microsoft/testfx/issues/6771