I've been digging into ASPNET 5 and MVC6. A major change from previous versions is that in the new version, many of the configuration files are .json rather than .xml.
Trouble is two-fold:
It would be a big step backwards in developer experience if each developer chose their own comment hack, or simply stopped adding readability comments into config files. Additionally, Visual Studio has comment/uncomment shortcuts that work in all languages that support comments that are used heavily by many developers during development and debugging cycles. The dev world doesn't need another "Don't forget that in this one situation that the regular stuff doesn't work and you need to do this other thing."
Is there any Microsoft (or similar) guidance on what method of hacking comments into the .json configuration files is "best" with Visual Studio and the MS tool chain?
The standard AddJsonFile
configuration extension in dotnet core allows comments and trailing commas in the JSON: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Configuration.Json/src/JsonConfigurationFileParser.cs#L26-L27
And you can configure that in your own JSON parsing too: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-invalid-json?pivots=dotnet-core-3-1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With