You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#I "../packages/Newtonsoft.Json/lib/net45"
#r "Newtonsoft.Json.dll"
open Newtonsoft.Json
type IFoo = abstract FooMember: int
type IBar =
inherit IFoo
abstract BarMember: int
// Approach 1: Implement IFoo "explicitly".
// In the object browser, you will see both IFoo and IBar as parents of FooBar.
type FooBar =
{Name:string}
interface IFoo with member this.FooMember = 0
interface IBar with member this.BarMember = 0
// Approach 2: Implement IFoo "implicitly" (as part of IBar).
// In the object browser, you will only see IBar as parent of FooBar.
type FooBar2(name : string) =
member x.Name2 = name
interface IBar with
member this.FooMember = 0
member this.BarMember = 0
let one = JsonConvert.SerializeObject({Name="One"})
let two = JsonConvert.SerializeObject(FooBar2("Two"))
Output
val one : string = "{"Name":"One"}"
val two : string = "{"Name2":"Two"}"
Expected output
val one : string = "{"Name":"One", "FooMember":0, "BarMember":0}"
val two : string = "{"Name2":"Two", "FooMember":0, "BarMember":0}"
The text was updated successfully, but these errors were encountered:
Test Script
#I "../packages/Newtonsoft.Json/lib/net45"
#r "Newtonsoft.Json.dll"
open Newtonsoft.Json
type IFoo = abstract FooMember: int
type IBar =
inherit IFoo
abstract BarMember: int
// Approach 1: Implement IFoo "explicitly".
// In the object browser, you will see both IFoo and IBar as parents of FooBar.
type FooBar =
{Name:string}
interface IFoo with member this.FooMember = 0
interface IBar with member this.BarMember = 0
// Approach 2: Implement IFoo "implicitly" (as part of IBar).
// In the object browser, you will only see IBar as parent of FooBar.
type FooBar2(name : string) =
member x.Name2 = name
interface IBar with
member this.FooMember = 0
member this.BarMember = 0
let one = JsonConvert.SerializeObject({Name="One"})
let two = JsonConvert.SerializeObject(FooBar2("Two"))
Output
val one : string = "{"Name":"One"}"
val two : string = "{"Name2":"Two"}"
Expected output
val one : string = "{"Name":"One", "FooMember":0, "BarMember":0}"
val two : string = "{"Name2":"Two", "FooMember":0, "BarMember":0}"
The text was updated successfully, but these errors were encountered: