Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all JSON strings valid in tests #367

Merged
merged 2 commits into from
Mar 16, 2023
Merged

Conversation

0xced
Copy link
Member

@0xced 0xced commented Mar 16, 2023

So that we can get rid of the ToValidJson extension method.

Now that raw string literals have been introduced (in #354) having valid readable JSON in strings for tests becomes easy. There is no need to escape quotes anymore with either \" or "".

This will also make it easier for newcomers to understand the tests at first glance. I had my WTF moment when I first saw JSON with single quotes. 🤔

So that we can get rid of the `ToValidJson` extension method.

Now that raw string literals have been introduced (in serilog#354) having valid _readable_ JSON in strings for tests becomes easy. There is no need to escape quotes anymore with either `\"` or `""`.

This will also make it easier for newcomers to understand the tests at first glance. I had my WTF moment when I first saw JSON with single quotes. 🤔
So that your Integrated Development Environment (IDE) can perform nice syntax highlighting.

See [Language injections in C#][1] in Rider for example.

Also remove some trailing commas that were highlighted after adding the // language=json comment

[1]: https://www.jetbrains.com/help/rider/Language_Injections.html
@0xced
Copy link
Member Author

0xced commented Mar 16, 2023

In the second commit I have also enabled JSON language injection (with // language=json comments) so that Rider can perform nice syntax highlighting. See Language injections in C# in Rider.

How nice is it?

image

@sungam3r
Copy link
Contributor

VS has syntax highlighting for JSON in raw string literals OOTB.

@nblumhardt nblumhardt merged commit 79ecfe6 into serilog:dev Mar 16, 2023
@0xced 0xced deleted the valid-json branch March 16, 2023 21:58
@nblumhardt nblumhardt mentioned this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants