Json files in resx are binary instead of text

I have some test data (json files) that I use when testing some software. This is static data, and I need tests to run locally and on build machines that I don't need to control. To get even access to test data (json files), I put them in a RESX file, and this works fine, except that I had to change the file extension from .json to .txt.

If I left it as .json, it was added to the resx file as a β€œbinary” rather than a β€œtext file”. This in itself is not the end of the path ... I just read the bits and converted them back to a string, but when I tried to deserialize the string (after converting from bytes []), I got an exception for unexpected char at position 0 of line 0.

The only real drawback of the txt extension is that I am losing color coding in the IDE for the JSON file.

Is there a way to get RESX to treat the .json extension as a "text file"?

+8
source share
2 answers

It may be too late, but there is a very simple way to achieve what you want. Just select the desired file in the resource window, press F4 or go to "Properties" and select the correct FileType. It has two options: binary and text.

enter image description here

+12
source

One of my colleagues ran into a similar problem with the .cshtml file. The actual contents of the file did not seem to matter when we renamed the file so that the extension, which was known to work, forced it to add text.

In addition, the Axm proposal worked to fix it, but we skipped it first because you cannot right-click the resource and select properties.

0
source

Source: https://habr.com/ru/post/983800/


All Articles