-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Natvis for C++/WinRT doesn't work #2809
Comments
This is 4 months old, and still no reply and nobody else encountered it? Btw, I think it could be solved by modifing the project template to add a custom post build step, that copies the whatever |
I'm hitting it often. |
Yeah, I encounter this fairly often as well. The workaround mentioned in the report works for some of the stuff, but where I struggle is collections with custom types, or just collections in general. |
Enabling diagnostics shows that nativs only searches within the This does not make sense because, as far as I understand it, the Therefore, it is save to say that the debugging experience for custom types is broken. Why this does not receive more attention is beyond me. Especially because it seems to be fixable by just changing the search paths for |
@ackh You're correct, we don't want to load up the AppX folder with debugging support files like pdbs and winmds, which aren't required at runtime. In my experiments, I don't see any Windows App SDK winmd files being copied to the parent of the AppX folder, so I don't think we can rely on that. Fortunately, while the diagnostics don't indicate it, the %TEMP% folder is also searched as a cache location. So, a short-term workaround is to add a custom target that copies all the Windows App SDK metadata to the %TEMP% folder. I've confirmed this works with the LaunchActivatedEventArgs repro, and it doesn't impact the AppX folder. directory.build.targets:
|
This works for me as well. However I am wondering, are the winmd files for collections located elsewhere? For instance if I do: |
@torleifat Unfortunately, debug visualization does not support generics (collections). The work to implement this is quite involved, so I can't give any estimate if/when it will be done. |
@DefaultRyan any thoughts on supporting generics in the debug visualizer? |
Same thoughts as Kenny stated in the linked issue. It's not really a technical barrier, but a time+resources barrier. Even more so lately. We don't have any funding allocated for a feature like this right now. At least, not without some sort of signal that this is an impactful issue for lots of customers. Could make a fun spare time hack project, and cppwinrt regularly accepts outside contributions. |
@Scottj1s @DefaultRyan Thanks for the insight guys. Can't speak for anyone but myself with regards to impact on customers, but it does make things a bit harder to debug at least when I am used to being able to inspect collections while debugging. But I am certainly sympathetic to time/resources being a constraint. |
What strikes me as really odd about this statement is that WinUI and I assume large parts of the Windows App SDK is written in C++/WinRT, isn't it? If Microsoft internally writes that stuff in C++/WinRT, how would the lack of ability to inspect collections in the debugger not be a daily PITA for you guys? It's just that I'm really having a hard time understanding why we customers need to point out the obvious need for this if you guys have more C++/WinRT code to debug than everybody else. I might be wrong here and Microsoft's code base was authored in C++/CX. At least that would explain the hesitance of releasing it as open source. |
@ackh That's a good insight. I've seen a few internal complaints, but nothing compelling. Given that the visualizer is restricted to properties, adding support for generics still wouldn't provide much. You'd see the Size of IMap(View) and IVector(View), but not much else. We'd need to find a new technique to iterate over collections, in order to observe elements as you can with C# client code. |
@Scottj1s good callout there. C# has indexed properties, while the WinRT type system does not. Thinking about how to solve this in the general case, my first instinct would be to add a custom attribute to some types to tell diagnostic and debug tooling to treat certain methods as quasi-"indexed properties". Lacking that, one could special case the commonly-used types we know about: The vector-like collections shouldn't be too hard - Size is already a property, and we could iterate over the collection from 0 to Size-1. Map-like collections don't provide a getter for the set of keys, so I think we'd have to use its |
Update! I got a few free days and was able to get basic generics visualization up and running in a branch: https://github.com/microsoft/cppwinrt/tree/feature/generic_natvis This required synthesizing parsing generic type names, synthesizing type signatures for those generic types, plumbing in these more fully-fledged type signatures (over the existing There's still some work to be done:
|
@DefaultRyan I'm actually excited about what you did here! Having support for generics would be really helpful when debugging. Now I'm actively hoping that this makes it into a C++/WinRT release eventually. |
Any update on this? It has been a year now and we would still like to see this feature before we can further commit to using WinRT in our product. |
Hey all, I've finally been able to carve out enough time to get the fundamentals into a PR - microsoft/cppwinrt#1472 This allows visualizing properties, and has the aforementioned heavy lifting of type lookup, signature synthesis, and property retrieval. Does not yet have the fakery required for iterating collections, but I've got that provisionally working in a prototype state that I'm currently working to clean up for production. But first, things first, I'm going to get the foundation committed. |
Describe the bug
Natvis for C++/WinRT doesn't work because the *.winmd files aren't deployed alonside the process *.exe. This affects both SDK and user authored types.
Steps to reproduce the bug
Blank App, Packaged (WinUI 3 in Desktop)
template.App::OnLaunched()
LaunchActivatedEventArgs
argument.Expected behavior
The debug visualizer shows object properties based on metadata.
Screenshots
Notice the output message. To enable natvis diagnostics see documentation.
NuGet package version
1.1.3
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 21H2 (22000)
IDE
Visual Studio 2022
Additional context
A workaround is to manually copy the *.winmd files from
Microsoft.WindowsAppSDK
to the executable folder.The text was updated successfully, but these errors were encountered: