ringcentral / RingCentral.Net

RingCentral SDK for .NET
MIT License
19 stars 26 forks source link

Debugger Display #24

Closed TonyValenti closed 3 years ago

TonyValenti commented 4 years ago

Hi @tylerlong Can you please annotate the various classes with the [DebuggerDisplayAttribute]? This will make inspecting them in the Visual Studio much easier. Here's example code:

using System;
using System.Diagnostics;

namespace ConsoleApp58 {
    class Program {
        static void Main(string[] args) {
            var MyExample = new Example() {
                UserName = "User@User.com",
                Password = "P@$$w0rd"
            };
        }
    }

    public class Example : RcObject {
        public string UserName { get; set; }
        public string Password { get; set; }

        protected override string GetDebuggerDisplay() {
            return $@"{UserName}: {Password}";
        }

    }

    [DebuggerDisplay("{GetDebuggerDisplay(),nq}")]
    public abstract class RcObject {
        protected abstract string GetDebuggerDisplay();
    }

}

And this makes it so that when you mouse-over a variable of that type, you get a nice UI: image

tylerlong commented 4 years ago

Thanks for the suggestions. This is kind of new to me.

What is nq in [DebuggerDisplay("{GetDebuggerDisplay(),nq}")]?

tylerlong commented 4 years ago

I guess without [DebuggerDisplayAttribute], you can still inspect the variable in local variables window. It's just the "hover and show" feature is missing.

TonyValenti commented 4 years ago

The nq means "don't show quotes around the value."

In the screen shot, if it did not have nq, it would show the value as "User@User.com: P@$$w0rd" instead of User@User.com: P@$$w0rd

tylerlong commented 3 years ago

Overall this is nice-to-have feature but not essentials. We won't implement this because classes in this project doesn't have a ready to be used GetDebuggerDisplay() method.

As a workaround, you can always inspect the data using local variables debugging window.