How can I trouble-shoot this?
I combined the natvis example in this question with the C++/WinRT console template and succeeded in getting the natvis for the Matrix2d
to work but not for the Uri
.
#include "pch.h"
using namespace winrt;
using namespace Windows::Foundation;
struct Matrix2d
{
Matrix2d(int r, int c) : m_numRows(r), m_numCols(c), m_elements(r* c, 0) {}
// Column first ordered elements
std::vector<int> m_elements;
int m_numRows;
int m_numCols;
};
int main()
{
init_apartment();
Uri uri(L"http://aka.ms/cppwinrt");
Matrix2d g(4, 3);
printf("Hello, %ls!\n", uri.AbsoluteUri().c_str());
}
I'm unsure what natvis files cppwinrt is expected to produce (.natvis or .pdb) and where they would be located.
Below is the Natvis debug output. It show that only my custom Natvis file (\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis) and the system-wide Natvis files (%VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers) are being loaded.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\atlmfc.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\concurrency.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\cpp_rest.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\ObjectiveC.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\Windows.Data.Json.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\windows.devices.geolocation.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\windows.devices.sensors.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\windows.media.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\windows.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\winrt.natvis. Natvis: Parsing natvis xml file: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis. Natvis: Ignoring NatvisFile.natvis from ConsoleApplication2.pdb; a file of the same name already exists in a loaded project. Natvis: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis(17,6): Successfully parsed expression '0' in type context 'Matrix2d'. Natvis: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis(18,6): Successfully parsed expression 'i < m_numRows' in type context 'Matrix2d'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1063,6): Successfully parsed expression '_Mypair._Myval2._Myend - _Mypair._Myval2._Myfirst' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1062,6): Successfully parsed expression '_Mypair._Myval2._Mylast - _Mypair._Myval2._Myfirst' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1064,29): Successfully parsed expression 'size()' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1066,52): Successfully parsed expression 'capacity()' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1067,53): Successfully parsed expression '_Mypair' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1069,15): Successfully parsed expression 'size()' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers\stl.natvis(1070,23): Successfully parsed expression '_Mypair._Myval2._Myfirst' in type context 'std::vector<int,std::allocator >'. Natvis: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis(19,23): Successfully parsed expression '&m_elements[i * m_numCols],[m_numCols]na' in type context 'Matrix2d'. Natvis: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis(19,8): Successfully parsed expression 'i' in type context 'Matrix2d'. Natvis: C:\Users\a\source\repos\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis(20,12): Successfully parsed expression '++i' in type context 'Matrix2d'.
This is on a fresh install of Windows 10 and VS19 (16.8.2).
It looks like the cppwinrt team has removed the Visualizer from the vsix plugin:
Remove Visualizer from vsix #792 - https://github.com/microsoft/cppwinrt/pull/792
I don't know why they decided to remove the Visualizer, but I managed to get the Visualizer working again by