Closed
Description
Description
The natvis generator inserts comments before the xml node, which is invalid and causes parsing to fail.
Reproduction steps
- Using VS2022
- Add the generated natvis to your project
- Go to Tools -> Options -> Debugger -> Output Window
- Set Natvis diagnostic messages to verbose
- Attempt to debug project and have natvis work
json\nlohmann_json.natvis(4,3): Fatal error: Invalid xml declaration.
appears in the output window
Opening up the generated natvis in the editor within visual studio shows a red squiggly, hovering over it reveals:
Unexpected XML declaration. The XML declaration must
be the first node in the document and no white space
characters are allowed to appear before it.
Expected vs. actual results
Expected:
generated natvis starts with:
<?xml version="1.0" encoding="utf-8"?>
Reality:
generated natvis starts with:
<!-- * * * * * * * * AUTO-GENERATED FILE * * * * * * * * -->
<!-- Edit ./tools/generate_natvis/nlohmann_json.natvis.j2 -->
<!-- * * * * * * * * AUTO-GENERATED FILE * * * * * * * * -->
<?xml version="1.0" encoding="utf-8"?>
Minimal code example
No response
Error messages
`json\nlohmann_json.natvis(4,3): Fatal error: Invalid xml declaration.`
Compiler and operating system
Microsoft Visual Studio Community 2022 Version 17.4.2
Library version
Validation
- The bug also occurs if the latest version from the
develop
branch is used. - I can successfully compile and run the unit tests.