Replies: 2 comments 1 reply
-
This would be similar to semantic tokens in LSP, which are a bit more complex as there are many different types of tokens, and lines and whitespace are involved, because only part of the document might need to update. Lsp first sends a legend that contains the map from token type to the number (for fluent assertions that would be 1= mesage, 2 = actual, 3 = expected). And then for every request sends back a map of locations to the token type. For fluent assertion there are <5 token types, that will probably rarely expand, and will never change order. So adding an additional legend to every exception seems unnecessary. And whitespace and lines can be safely ignored because we always get the whole string. |
Beta Was this translation helpful? Give feedback.
-
Just played with the ANSI escape codes a bit |
Beta Was this translation helpful? Give feedback.
-
When expected or actual object is big it is very hard to find the assertion message. Could additional data that could be used for formatting be added to the exception Data dictionary?
For example (newlines are mine):
Is really hard for me to read. It would be much easier if the assertion message was printed in a different color than the actual and expected value.
Or if I could have the different colors and print it as:
I think both could be achieved by adding a dictionary<long, int> of markers to the Exception.Data[FormattingMarkers], that would say (example values):
0, 1
120, 2
746, 1
948, 3
Where key is the index in the string, and value is an enum defined in FluentAssertions, but used as a number, meaning 1=message, 2=actual, 3=expected.
The consumer of that exception could then split the string and format it as it sees fit, with different coloring (also using ansi color codes), or by adding newlines between the message and object, or re-organizing the message altogether. It would also have no impact on the current consumers, other than a tiny perf impact on creating the dictionary for a failing test.
Beta Was this translation helpful? Give feedback.
All reactions