Bug 42446 - DataContractSerializer throws NotImplemented exception
Summary: DataContractSerializer throws NotImplemented exception
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.4.0 (C7)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-08 23:46 UTC by Casper Bollen
Modified: 2016-07-08 23:46 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 42446 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Casper Bollen 2016-07-08 23:46:25 UTC
This code runs without problem on .net, but crashes when using mono 4.4.1

#I __SOURCE_DIRECTORY__
#r "System.dll"
#r "System.Net.Http.dll"
#r "System.Runtime.Serialization"

open System
open System.Net.Http
open System.IO
open System.Text
open System.Runtime.Serialization
open System.Runtime.Serialization.Json


[<DataContract(Name="request")>]
[<CLIMutable>]
type Request =
    {
        [<field: DataMember(Name = "act")>]
        Action: string
        [<field: DataMember(Name = "qry")>]
        Query: obj
    }


let fromJson<'T> (json: string) =
    let dcs = DataContractJsonSerializer(typeof<'T>)
    use ms = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(json))
    (new StreamWriter(ms)).Write(json)
    dcs.ReadObject(ms) :?> 'T

let toJson o =
    let dcs = DataContractJsonSerializer(o.GetType())
    use ms = new MemoryStream()
    dcs.WriteObject(ms, o) 
    ms.Position <- 0L
    (new StreamReader(ms)).ReadToEnd()


{ Action = "Test"; Query = new Object() }
|> toJson
|> printfn "%s"

This is a minimal failing test, just throw it to the fsharpi and compare it with the fsi result.