Allow Action<T> as input to Dump()
Sometimes you don't need to Dump() the entire object graph, but instead just a portion thereof. Of course, you can (if in Statements or Program mode) assign a variable, and them Dump() something derived from the variable currently. But wouldn't it be nice, for example if you could do this:
/* some really complex query / .Dump(x => x.Select(y => y.EmailAddress, "Email Addresses")
./ some other operations on the complex query */
This wouldn't be hard to code:
public static T Dump<T>(this T toDump, Func<T> filter, string description)
{
toDump.filter().Dump(description);
return toDump;
}
Of course, you'd want to have other overloads as well to match the existing Dump() overloads with the additional second parameter.
-
Dave Mackersie commented
Why not just put a Select in front of the Dump?
.Select(x => x.EmailAddress).Dump();
-
Paul Reeder commented
oops, not Action<T> as stated in the title, but Func<T>