Add BoundNode.Source() method. Improve AssertEx.SetEqual() method#31526
Add BoundNode.Source() method. Improve AssertEx.SetEqual() method#31526jcouv merged 2 commits intodotnet:masterfrom
Conversation
|
test roslyn-CI please |
|
Hiding this PR for now. Our review pipeline is clogged as it is, with higher priority changes. |
| /// <summary> | ||
| /// Gives an approximate printout of a bound node as C# code. | ||
| /// </summary> | ||
| internal string Source() |
There was a problem hiding this comment.
Feel like this should be GetSource or CalculateSource. Given it's not a property expecting some verb.
There was a problem hiding this comment.
This is meant to be similar to Dump(). I'll change to DumpSource().
|
|
||
| void incrementIndent() | ||
| { | ||
| indent += 4; |
There was a problem hiding this comment.
Instead of hard coding 4 everywhere consider making indent size a constant for the outer function.
|
|
||
| public static void SetEqual(IEnumerable<string> expected, IEnumerable<string> actual, IEqualityComparer<string> comparer = null, string message = null, string itemSeparator = "\r\n", Func<string, string> itemInspector = null) | ||
| { | ||
| var indexes = new Dictionary<string, int>(); |
There was a problem hiding this comment.
Shouldn't this take comparer as a parameter (after calculating a default value when null).
|
|
||
| public static void SetEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual, IEqualityComparer<T> comparer = null, string message = null, string itemSeparator = "\r\n", Func<T, string> itemInspector = null) | ||
| { | ||
| var expectedSet = new HashSet<T>(expected, comparer); |
There was a problem hiding this comment.
Shouldn't we be calculating a default here ...
There was a problem hiding this comment.
That's not necessary. Passing null is ok.
That's existing logic and HashSet and Dictionary can handle null comparers.
|
Done with review pass (iteration 1) |
|
@jaredpar Please take another look when you get the chance. Addressed your feedback. Thanks |
Source()is similar toDump(), but it produces a C#-like format. It's not meant to be complete or valid code, but I found it extremely useful for working on lowering async-iterator methods. Below is an example.SetEqual()produces an error message which respects the original ordering of the expectations (more usable diff).Example of output of
Source()on the followingBoundTryStatementafter async rewriting: