Agnel Kurian
Agnel Kurian

Reputation: 59456

DebuggerDisplay Attribute does not work

This is a C++/CLI WinForms project targeting the .NET 2.0 framework. I am using Visual Studio 2008. How do I get it to work?

EDIT: Code snippet

[Serializable]
[DebuggerDisplayAttribute(L"ID={EmployeeID}")]
public ref class Employee
{
    [ReadOnly(true)]
    int nID;
    property int EmployeeID
    {
        int get()
        {
            return nID;
        }
    }
}

Upvotes: 0

Views: 1202

Answers (3)

Hans Passant
Hans Passant

Reputation: 941208

The consensus is that the C++ IDE does not support it.

Upvotes: 1

OJ.
OJ.

Reputation: 29401

I think your problem might be that you're specifying wide strings (L"ID={EmployeeID}") instead of CLR strings (S"ID={EmployeeID}"). So perhaps change the L to an S and see how you go?

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1062494

Define "doesn't work"... it certainly works in C# (I don't know if the C++ editor supports it - just translate the following which works in C# to find out ;-p)

using System.Diagnostics;
[DebuggerDisplay("HiWorld={Bar}")]
class Foo
{
    public string Bar { get; set; }
    static void Main()
    {
        Foo foo = new Foo { Bar = "abc" };
        // breakpoint and hover shows: HiWorld="abc"
    }
}

I don't "do" C++ any more, but reflector says:

[DebuggerDisplay(S"HiWorld={Bar}")]
private __gc class Foo
{
    // Methods
    private: static void __gc* Main()
    {
        Foo __gc* <>g__initLocal0 = __gc new Foo();
        <>g__initLocal0->Bar = S"abc";
        Foo __gc* foo = <>g__initLocal0;
    }


    // Properties
    [CompilerGenerated]
    public: __property String __gc* get_Bar()
    {
        return this-><Bar>k__BackingField;
    }
    [CompilerGenerated]
    public: __property void __gc* set_Bar(String __gc* value)
    {
        this-><Bar>k__BackingField = value;
    }


    // Fields
    [CompilerGenerated]
    private: String __gc* <Bar>k__BackingField;
};

Upvotes: 1

Related Questions