|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Debugger and watch issue with strings and own defined typeobjects underneath. So, a String is an object as well. Now, when when we are debugging and we examine the contents of a String object - the debugger actually shows the value of containing string object when you keep a watch on the instance variable. But when I create my OWN type which holds a string inside - and get this 1) Have an implicit conversion from string -> object 2) Have an implicit conversion from object -> string AND 3) Have the ToString() method overridden The debugger still shows me the value of my object as the fully qualified class name! How is the String class object built so that the debugger knows to show the internal string/byte array, whatever as the value and not the fully qualified name of the class which should be "System.String" i think. The code for my class is below. Thanks, Girish StringWrapper --------------- using System; namespace test1 { public class StringWrapper { private String _val; public String val { get { return _val; } } public StringWrapper(String val) { this._val = val; } public override string ToString() { return val; } static public implicit operator StringWrapper(String val) { val += " (im changed)"; return new StringWrapper(val); } static public implicit operator string(StringWrapper val) { return val.val; } } } >How is the String class object built so that the debugger knows to show the The debugger probably has built in special handling of strings.>internal string/byte array, whatever as the value and not the fully >qualified name of the class which should be "System.String" i think. But you should check out the file Visual Studio\Common7\Packages\Debugger\mcee_cs.dat. In it you can modify how a certain type shows up in the debugger windows. Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Mattias,
can you use that technique to force the debugger tooltip to display stringbuilder variables? I really need the ability to hover over a stringbuilder object and find its values. -- Show quoteRegards, Alvin Bruney [Shameless Author Plug] The Microsoft Office Web Components Black Book with .NET available at www.lulu.com/owc _________________________ "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message news:uOBdvQSMFHA.732@TK2MSFTNGP12.phx.gbl... > >How is the String class object built so that the debugger knows to show > >the >>internal string/byte array, whatever as the value and not the fully >>qualified name of the class which should be "System.String" i think. > > The debugger probably has built in special handling of strings. > > But you should check out the file Visual > Studio\Common7\Packages\Debugger\mcee_cs.dat. In it you can modify how > a certain type shows up in the debugger windows. > > > > Mattias > > -- > Mattias Sjögren [MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. >can you use that technique to force the debugger tooltip to display I've never tried so I don't know for sure, but I don't see why not.>stringbuilder variables? I really need the ability to hover over a >stringbuilder object and find its values. Try it! Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Other interesting topics
|
|||||||||||||||||||||||