Reputation: 2556
When I am debugging code in Visual Studio, I can change values of variables by clicking on the overlay that pops up when I hover over my variable of choice. The label which displays the value turns into a text box and I can enter a new value which gets assigned as soon as I hit enter.
What do I have to implement in my own types in order to support this kind of workflow? Currently Visual Studio shouts at me that there is no implicit conversion from string to my type. If I add such an implicit operator it works fine, but is there another way of achieving the same without having to add the implicit conversion to my type (well, I could mark the conversion as [Obsolete]
so that nobody can call it from code - but that's not the cleanest way I guess) just like [DebuggerDisplay]
can achieve to display something else while debugging while leaving ToString()
independent to whatever business logic demands?
Upvotes: 0
Views: 256
Reputation: 6436
The label which displays the value turns into a text box and I can enter a new value which gets assigned as soon as I hit enter.
The workaround you show is the Data ToolTips in the code editor, it is the usual way we edit the value during VS debugging.
Other workarounds I know is that:
(1) Custom the debugging view with the natvis extension.
For example, you could create a type visualizer for a custom data type like the sample in following blog:
(2) Use certain debugging window like Watch windows or others, but my understanding it is not convenient, I mean that use the ToolTips(the way you provide) would be better.
https://msdn.microsoft.com/en-us/library/aa6fy2x5(v=vs.120).aspx
Hope it could provide useful information or a path.
Upvotes: 1