Add Python script for generating Natvis file and update file for 3.11.2 by falbrechtskirchinger · Pull Request #3697 · nlohmann/json
I updated GDB pretty printer for the new inline namespace but forgot Natvis. This PR adds a small Python script to generate the Natvis file from a Jinja2 template and generates the file for the 3.11.2 release. In the future, the release script should call ./tools/generate_natvis/generate_natvis.py --version X.Y.Z . (the trailing dot denoting the output directory).
Fixes #3696.
| </Type> | ||
|
|
||
| <!-- Namespace nlohmann::json_abi --> | ||
| <Type Name="nlohmann::json_abi::basic_json<*>"> |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use wildcards for the namespace? nlohmann::*::basic_json...? If so, could we also hardcode the values for nlohmann::*::detail::value_t::*? This would allow a single natvis file that would work for any version?
Otherwise, would it make sense to include the version number in the filename so that users could have multiple version files installed?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcards are only supported for template parameters according to the documentation.
Users will have to comment on whether versioning the Natvis file would be helpful. (ping @jheydebrand)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcards are only supported for template parameters according to the documentation.
I saw documentation that said that they worked for templates, but it didn't specifically say that it was only used there, so I wasn't sure if it was limited to templates or just poorly documented.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fully qualified name of each Type element is specified in its Name attribute.
and
Templated classes
The Name attribute of the Type element accepts an asterisk * as a wildcard character that can be used for templated class names.
In the following example, the same visualization is used whether the object is a CAtlArray or a CAtlArray. If there's a specific visualization entry for a CAtlArray, then it takes precedence over the generic one.
The very specific wording suggests to me it only works for templates. 🤷♂️
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that it only works for templates. :(
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the swift responses.
Versioning the natvis file would not provide any benefit for me.
When consuming the library via its CMake integration the correct / matching natvis file will be included anyway and I have no desire to copy the file to some system-wide directory (which is supported by Visual Studio and might have been the use-case for versioned natvis files you were thinking about?).
@nlohmann This should be included in 3.11.2 if possible. I could open a PR with just the updated Natvis file if you prefer.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters