Skip to content

Generated natvis is invalid XML #3858

Closed
@Avery3R

Description

@Avery3R

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

a3e6e26

Validation

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions