C++/WinRT natvis 在全新安装中不起作用
C++/WinRT natvis doesn't work in fresh install
我该如何解决这个问题?
我将 this question 中的 natvis 示例与 C++/WinRT 控制台模板相结合,并成功地让 Matrix2d
的 natvis 工作但不用于 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());
}
我不确定 cppwinrt 应该生成哪些 natvis 文件(.natvis 或 .pdb)以及它们的位置。
下面是 Natvis 调试输出。它显示只有我的自定义 Natvis 文件 (\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis) 和系统范围的 Natvis 文件 (%VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers) 正在加载。
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\atlmfc.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\concurrency.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\cpp_rest.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\ObjectiveC.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\stl.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\Windows.Data.Json.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.devices.geolocation.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.devices.sensors.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.media.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.natvis.
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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'.
这是 Windows 10 和 VS19 (16.8.2) 的全新安装。
看起来 cppwinrt 团队已经从 vsix 插件中删除了 Visualizer:
从 vsix #792 中删除可视化工具 - https://github.com/microsoft/cppwinrt/pull/792
我不知道他们为什么决定删除 Visualizer,但我设法让 Visualizer 重新工作
- 从 https://github.com/microsoft/cppwinrt
下载 cppwinrt 项目
- 还原在 https://github.com/microsoft/cppwinrt/pull/792/commits/8a945371b26d3f1ed1a105e8ebb1e3c0e90a54bd 中指定的所有更改
(基本上是 3 个文件 build_vsix.cmd、source.extension.vsixmanifest 和 vsix.csproj)
- 将“call .nuget\nuget.exe restore vsix\vsix.sln”添加到“build_vsix.cmd”,否则我在第 4 步收到一些 nuget 包丢失的错误。
- 使用 2019 开发人员提示使用文件“build_vsix.cmd”创建。
- 删除当前的 C++/WinRT 插件并安装创建的插件(位于 ./vsix/bin/x86/Release/ )
我该如何解决这个问题?
我将 this question 中的 natvis 示例与 C++/WinRT 控制台模板相结合,并成功地让 Matrix2d
的 natvis 工作但不用于 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());
}
我不确定 cppwinrt 应该生成哪些 natvis 文件(.natvis 或 .pdb)以及它们的位置。
下面是 Natvis 调试输出。它显示只有我的自定义 Natvis 文件 (\ConsoleApplication2\ConsoleApplication2\NatvisFile.natvis) 和系统范围的 Natvis 文件 (%VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers) 正在加载。
Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\atlmfc.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\concurrency.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\cpp_rest.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\ObjectiveC.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\stl.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\Windows.Data.Json.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.devices.geolocation.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.devices.sensors.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.media.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\Packages\Debugger\Visualizers\windows.natvis. Natvis: Parsing natvis xml file: C:\Program Files (x86)\Microsoft Visual Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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 Studio19\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'.
这是 Windows 10 和 VS19 (16.8.2) 的全新安装。
看起来 cppwinrt 团队已经从 vsix 插件中删除了 Visualizer:
从 vsix #792 中删除可视化工具 - https://github.com/microsoft/cppwinrt/pull/792
我不知道他们为什么决定删除 Visualizer,但我设法让 Visualizer 重新工作
- 从 https://github.com/microsoft/cppwinrt 下载 cppwinrt 项目
- 还原在 https://github.com/microsoft/cppwinrt/pull/792/commits/8a945371b26d3f1ed1a105e8ebb1e3c0e90a54bd 中指定的所有更改 (基本上是 3 个文件 build_vsix.cmd、source.extension.vsixmanifest 和 vsix.csproj)
- 将“call .nuget\nuget.exe restore vsix\vsix.sln”添加到“build_vsix.cmd”,否则我在第 4 步收到一些 nuget 包丢失的错误。
- 使用 2019 开发人员提示使用文件“build_vsix.cmd”创建。
- 删除当前的 C++/WinRT 插件并安装创建的插件(位于 ./vsix/bin/x86/Release/ )