From what I can gather, the DebuggerDisplayAttribute cannot be applied to individual levels of a discriminated union, only to the top-level class.
The corresponding documentation suggests that overriding the ToString() method is an alternative way.
Taking the following example:
type Target =
| Output of int
| Bot of int
override this.ToString () =
match this with
| Output idx -> $"output #{idx}"
| Bot idx -> $"bot #{idx}"
[<EntryPoint>]
let main _ =
let test = Bot 15
0
When breaking on the return from main and placing a watch on test, the VS2019 debugger is showing Bot 15 rather than bot #15.
The documentation also suggests that:
Whether the debugger evaluates this implicit ToString() call depends on a user setting in the Tools / Options / Debugging dialog box.
I cannot figure out what user setting it is referring to.
Is this not available in VS2019 or am I just missing the point?