News for hackers. Stuff that matters.
Re:A simple tip to make your debugging sessions go easier by Sukotto on Thursday November 17, 2011 @01:24PM (#3248610)
I had no idea I could do this and can hardly wait to try it.

[edit: The author says it works for C#, F#, VB.NET, etc) in VisualStudio]

The related article goes into more depth including a list of DOs and DON'Ts: http://blogs.msdn.com/b/jaredpar/archive/2011/03/18/debugger...

(Quoting the above link)

Preferred Pattern

My personal preferred pattern for DebuggerDisplay attributes is to have the entire item be an expression: DebuggerDisplay. I then add a private instance property to my type named DebuggerDisplay and do all of my custom formatting in this property. Having the property be private is fine because nothing is private in the debugger.

  [DebuggerDisplay("{DebuggerDisplay,nq}")]
  public sealed class Student {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      private string DebuggerDisplay {
          get { return string.Format("Student: {0} {1}", FirstName, LastName); }
      }
  }
The ,nq suffix here just asks the expression evaluator to remove the quotes when displaying the final value (nq = no quotes).

I prefer this pattern because it’s only requires a single function to be evaluated, I can still have language specific expressions (which are nicely type checked by the compiler) and it doesn’t contribute to the public API of my type.

Re:A simple tip to make your debugging sessions go easier by CJefferson on Thursday November 17, 2011 @01:25PM (#3248614)
Amazingly, even after reading the article I'm still not sure what language this refers to. I think it's C#, when debugged in Visual Studio.
Re:A simple tip to make your debugging sessions go easier by JoelMcCracken on Thursday November 17, 2011 @01:46PM (#3248706)
I had the same problem. This leads to two situations:

1) The language looks java-derived, so I am probably /not/ interested. However, this would be a useful tip, and it might be useful with something I would use (jruby or clojure).

2) If it is specific to the MS stack, I have zero interest.

3) For all I know, this could apply (somehow) to the XCode ide in general, which would also be useful for me to know.

Always include information in the link that shows what sub-group of developers something pertains to.

Re:A simple tip to make your debugging sessions go easier by jf on Thursday November 17, 2011 @01:41PM (#3248694)
You are correct sir.
Re:A simple tip to make your debugging sessions go easier by szcukg on Thursday November 17, 2011 @10:32PM (#3250469)
It's for the MS stack
Re:A simple tip to make your debugging sessions go easier by Zev on Thursday November 17, 2011 @02:41PM (#3248929)
You can do something similar with iOS development as well, by implementing a -debugDescription method to return a NSString * object that is then printed out when you use print-object (or po) from GDB/LLDB.

If -debugDescription is not implemented, than the debugger will print out whatever -description returns, instead. -description is the same method that is called when an object is printed out with NSLog().

(more info: http://www.ultrasaurus.com/sarahblog/2011/11/debugging-objec...)

Re:A simple tip to make your debugging sessions go easier by drusellers on Thursday November 17, 2011 @02:06PM (#3248793)
Sorry guys, mostly .net peeps reading my blog. I cleared it up a bit in the post.