microsoft / microsoft/vscode-cpptools
Handle the "std::error_code" special for watch window because natvis is insufficient
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
Feature Request
The type "std::error_code" is part of the standard library for communicating errors when not using exceptions in C++. When an error is set, it constructs an object that is an integer and a reference to an object that can translate that integer into a string. However, the Watch window by default displays errors like this:
err = std::error_code = {std::_V2::error_category: 2}
I have no idea what that error means. To get the message string, one has to invoke err.message(). That invocation is legal in the watch window. For an error type on the stack, I can do that, although it is annoying that I cannot simply add a watch to err or get that info through hover. When the error is embedded in a cluster of more information, it gets harder.
Currently natvis cannot be taught how to display the message because that involves invoking a function. Is there any way to add the view functionality for err specifically without opening up the full can of worms that is arbitrary function invocation?
I would like the CPP extension to handle std::error_code special in the watch window to display the code and the message translation automatically. I realize this opens the doors to running code with side-effects, but as a fundamental part of the language that is common usage (Google style does not allow exceptions, for example), I think it is worth handling special.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Rendering des C++-Erweiterungsfensters zur Variablenüberwachung und dessen natvis-Verarbeitung zu überprüfen, wobei das std::error_code-Beispiel aus dem Issue als erwarteter Fall dient. Ermittle, an welcher Stelle eine spezielle Darstellung sowohl den numerischen Code als auch die übersetzte Meldung anzeigen könnte, ohne die beliebige Aufrufbarkeit von Funktionen zu aktivieren; als erledigt gilt die Aufgabe, wenn die Ansichten zur Variablenüberwachung und zum Darüberfahren mit dem Mauszeiger diese Informationen zuverlässig anzeigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp, typescript, vscode
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100