microsoft / microsoft/vscode-cpptools
Handle the "std::error_code" special for watch window because natvis is insufficient
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando il rendering della finestra di watch dell’estensione C++ e la relativa gestione di natvis, usando l’esempio std::error_code dell’issue come caso atteso. Determina dove una visualizzazione speciale potrebbe mostrare sia il codice numerico sia il messaggio tradotto senza abilitare l’invocazione arbitraria di funzioni; il lavoro è concluso quando le viste watch e hover mostrano queste informazioni in modo affidabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, typescript, vscode
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100