6

Can anyone explain me why debugger of VS2012 is showing different values for same member of object? (See the figure)

http://s2.uploads.ru/jlkw0.png (Sorry for nonEnglish interface of VS, but I think the situation is clear.)

Here the code:

http://pastie.org/7186239

4

1 回答 1

8

The debugging experience seems to do a poor job of identifying the correct binding for identifiers. In your example, this means that any identifier called Source is really showing the value of this.Source, rather than the corresponding property of the correct object. Note that you can get the right value by hovering over y and expanding the members (although this is obviously not a great experience).

There are even more confusing ways that this issue manifests itself:

type T() =
    member val P = 1

    member this.DoSomething() =
        let P = "test"      // set breakpoint here, hover over P
        printfn "%i" this.P // set breakpoint here, hover over P

T().DoSomething()

Now, whichever instance of P you hover over, you get the wrong thing!

于 2013-03-30T18:57:43.220 回答