Skip to content

Netstandard1.6 build of FSharp.Core nuget does not have serializable flag in its contained types #4207

@eiriktsarpalis

Description

@eiriktsarpalis

I noticed an interesting behaviour while attempting to port FsPickler to .NET standard. By default F# will add the serializable flag to all types unless declared otherwise (via the AutoSerializableAttribute). It seems that in the netstandard1.6 build of the FSharp.Core nuget many types seem to be lacking the serializable flag. This includes types like

  • F# options, lists, choice, etc
  • Microsoft.FSharp.Control.FSharpAsync
  • Microsoft.FSharp.Quotations.FSharpExpr
  • Microsoft.FSharp.Core.OptimizedClosures+Invoke@3253
  • Microsoft.FSharp.Core.ExtraTopLevelOperators+dictValueType@98

which are serializable in the net45 build of the same nuget package version (4.2.3).

Repro steps

  1. Create and run a nestandard2.0 console application with the following code
[<EntryPoint>]
let main argv =
    printfn "%b" typeof<int option>.IsSerializable
    0

Expected behavior

Should print true to console.

Actual behavior

Prints false to console.

Related information

This issue doesn't seem to affect user-defined F# types. For instance the following program

type Foo = class end

[<EntryPoint>]
let main argv =
    printfn "%b" typeof<Foo>.IsSerializable
    0

will print true for a netcoreapp2.0 application. The same holds for types defined in F# netstandard2.0 types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions