STL.natvis: add error_code and error_category#3044
STL.natvis: add error_code and error_category#3044vinniefalco wants to merge 1 commit intomicrosoft:mainfrom
Conversation
StephanTLavavej
left a comment
There was a problem hiding this comment.
Thanks for the PR! The checks are failing with:
.\stl\debugger\STL.natvis(1,1): error : Validation failed: file contains 6 lines with trailing whitespace.
|
You know...I'm just gonna put this out there... I use the Visual Studio IDE editor exclusively... I will update the pull request. |
|
For other reviewers: Paste this program #include <future>
#include <ios>
#include <string>
#include <system_error>
struct my_error_category : public std::error_category {
const char* name() const noexcept override {
return "potato";
}
std::string message(int) const override {
return "message goes here";
}
};
int main() {
auto& generic_cat = std::generic_category();
auto& system_cat = std::system_category();
auto& iostream_cat = std::iostream_category();
auto& future_cat = std::future_category();
const auto& my_cat = my_error_category();
std::error_code generic(42, generic_cat);
std::error_code system(42, system_cat);
std::error_code iostream(42, iostream_cat);
std::error_code future(42, future_cat);
std::error_code my(42, my_cat);
}into a VS project. Add a new natvis file with the new visualizers from the PR. Set a breakpoint at the final |
| <DisplayString Condition="_Addr == 1">[future]</DisplayString> | ||
| <DisplayString Condition="_Addr == 3">[generic]</DisplayString> | ||
| <DisplayString Condition="_Addr == 5">[iostream]</DisplayString> | ||
| <DisplayString Condition="_Addr == 7">[system]</DisplayString> | ||
| <DisplayString>@{((uintptr_t)this),x}</DisplayString> |
There was a problem hiding this comment.
I think we should:
| <DisplayString Condition="_Addr == 1">[future]</DisplayString> | |
| <DisplayString Condition="_Addr == 3">[generic]</DisplayString> | |
| <DisplayString Condition="_Addr == 5">[iostream]</DisplayString> | |
| <DisplayString Condition="_Addr == 7">[system]</DisplayString> | |
| <DisplayString>@{((uintptr_t)this),x}</DisplayString> | |
| <DisplayString>[{name(),sb}]</DisplayString> | |
| <Expand> | |
| <Synthetic Name="hint"> | |
| <DisplayString>Enable "Allow Function Calls In Value Formatting" if you see "???" here</DisplayString> | |
| </Synthetic> | |
| </Expand> |
here. It requires "Allow Function Calls In Value Formatting" to be enabled in the debugger, but produces an identical experience for library-defined and user-defined error_categorys.
|
|
||
|
|
||
| <Type Name="std::error_code"> | ||
| <DisplayString>{_Myval} {*_Mycat}</DisplayString> |
There was a problem hiding this comment.
If we accept the above suggestion, we should also:
| <DisplayString>{_Myval} {*_Mycat}</DisplayString> | |
| <DisplayString>{_Myval} {*_Mycat}</DisplayString> | |
| <Expand> | |
| <Synthetic Name="hint"> | |
| <DisplayString>Enable "Allow Function Calls In Value Formatting" if you see "???" for the category</DisplayString> | |
| </Synthetic> | |
| </Expand> |
for discoverability.
|
This visualizer needs to be updated now that #3139 has been merged. |
|
Closing as this has been superseded by #3204. Thanks again for looking into this! |
Thanks for the low-hanging fruit :)