BUG: can't hook up toDump extension method with F# program

per https://www.linqpad.net/CustomizingDump.aspx
I should be able to make it customize the dump of a `Newtonsoft.Json.Linq.JProperty`

However, no matter what I try, (trying not to use MyExtensions since it is C# only) it won't hook up


produces just the value, not the name and value, nor do any of the print statements get hit.


  • The global ToDump hook is only valid in My Extensions, not individual queries.

    I've taken a look at whether it would easy to allow My Extensions to be written in F#, but unfortunately, there's a fair bit of work involved. So the only option right now is to write the ToDump in C#.
  • I was under the impression that you could use C# extension methods to customize dump behavior in individual queries, is that not the case? One of my attempts above should be seen by C# as toDump extension methods on object.
  • Any word on this possibility? Are all the ToDump hooks, available to F#, only available per type, with no ability to hook in or inject?
    type Newtonsoft.Json.Linq.JProperty with
        member x.ToDump() = x.Name
        member x.toDump() = x.Name
    is something like this possible?
  • edited December 2018
    Can we please have a way to hook/override type-specific (for types we aren't creating) (or global) dumping in linqpad for F#?
  • @JoeAlbahari is this still entirely unavailable in F# to localized types?

  • ToDump is recognized in two places the moment:

    • As a static method is My Extensions. Then it executes for all types.
    • As an instance method on the type itself being dumped.

    LINQPad does not look for ToDump methods defined via F# type extensions. It could end up being quite a lot of work to implement this in LINQPad reliably. FWIW, there's no C# solution for this either: right now, a static ToDump method is recognized only in My Extensions and not in individual queries.

Sign In or Register to comment.