tags:

views:

41

answers:

2

http://msdn.microsoft.com/en-us/library/x810d419.aspx

From what we can see on MSDN, it says to be careful about which expressions we put as they change from language to language. My question is: what are the supported languages for writing those expressions? If various languages can do it, how does it detect which language is being used?

I've made my class in CLI, and coded the expression in c#, being that it works. I've tried in c++/CLI, but that way it doesn't.

Here is my code:

[DebuggerDisplay("z = {ToString()} Norm = {System.Math.Round(Norm,2)} Angle = {System.Math.Round(Angle, 2)}")]

Now, trying it the c++/CLI way:

[DebuggerDisplay("z = {ToString()} Norm = {System::Math::Round(Norm,2)} Angle = {System::Math::Round(Angle, 2)}")]

My assumption is that it will always read the expression as c# code. Is this true?

+2  A: 

My interpretation is that it will always interpret it in a format that happens to look a lot like C#, yes. So . for members-access, etc (the same as data-binding uses . for member-access, regardless of the caller's language). It is also a lot like the string.Format pattern, if you see the relationship ("{0} - {1}" etc).

Of course, if the expression gets too complex you could consider a debugger type proxy.

Marc Gravell
+2  A: 

I found this link

There is a down-side to this power though - because evaluation of the DebuggerDisplayAttribute format string is compiler-specific, the first example will work fine most other debuggers such as VB, but the second one will not evaluate due to its use of the C#-specific ternary operator. Depending on the debugger this will cause it to display either the default value of the class name, or an error indicating which part of the syntax could not be evaluated; this may be important if you work in a multi-language environment, or if you ship your classes as a library to customers.

astander