Closed JasonBock closed 2 weeks ago
I'm thinking that I'll need to expose a formatter method in Rocks (or emit it like I do RefStructArgument
). For a mocked method like this:
void DoStuff(string data, MyEnum switcher, int[] content);
I currently generate this:
throw new global::Rocks.Exceptions.ExpectationException($"No handlers were found for {this.GetType().GetMemberDescription(0)})");
I would generate code that looks something like this:
throw new global::Rocks.Exceptions.ExpectationException(
$$"""
No handlers were found for {this.GetType().GetMemberDescription(0)})
data: {global::Rocks.ParameterFormatter.Format(@data)}
switcher: {global::Rocks.ParameterFormatter.Format(@switcher)}
content: {global::Rocks.ParameterFormatter.Format(@content)}
""");
As a side note, I should start to consider moving everything in Rocks that is needed by the user to IncrementalGeneratorInitializationContextExtensions
. That way I can change the NuGet package so that I don't have to copy the assembly into another location so types within it can be referenced. I'll put that in a different issue to track.
Also consider what needs to show with type arguments (if any).
Describe the solution you'd like
Right now the message is formatted like this:
That's somewhat helpful, but what would be even better is:
I'm not sure if can handle custom renderings for all types, but maybe I do something where I get the enum name and put strings in double-quotes. But the point is, log the values seen that don't have an expectation associated with it.