Natvis for a type that may be compiled into dll or lib

446 Views Asked by At

I have a solution in visual studio that has one configuration that allows for each project to be statically linked into the main exe, and another configuration that compiles each project as its own dll.

The idea being that I can develop using DLLs, minimising downtime during compilation and linking, but when I release to the public, there's just one exe.

Unfortunately this means that a type created in one of these projects appears to need 2 natvis files so that they can be debugged in either configuration.

These 2 natvis files are otherwise identical except for the myProject.dll! prefix applied to all namespaces in the natvis for the dll configuration. (When running a statically linked exe, the natvis containing the reference to the type in a dll fails, causing the whole file to be ignored, not just that type)

Is the best solution to this situation just to maintain 2 natvis files per type? Is it possible to generate the natvis from a template? Is it possible to make the reference to the dll optional?

(I'm using Visual Studio 2015, but please let me know if 2017+ has a solution for this)

Thanks

1

There are 1 best solutions below

1
On

I'm using Microsoft Visual Studio Community 2017 Version 15.6.2 and it works for me with a single .natvis type decl. I've got my .natvis and header files in a shared project which is referenced by both my shared project's implementation .dll project and my application's .exe project. I just specify the simple type name without the Shared.dll! prefix and it works. I hope this helps. =)