Closed 0x53A closed 8 years ago
Hi,
What is the precise exception that you are getting? I tried the following example:
[<AutoSerializable(false)>]
type Foo = { Foo : string }
type Bar = { Foo : Foo }
type Baz = { Bar : Bar }
FsPickler.GeneratePickler<Baz>()
which gives
Nessos.FsPickler.NonSerializableTypeException: Type 'FSI_0008+Baz' contains non-serializable field of type 'FSI_0008+Bar'.
This seems to contain sufficient debug information, since it points to the correct non-serializable field.
Hi, sorry for not providing a repro earlier.
This code
open Nessos.FsPickler
[<AutoSerializable(false)>]
type Foo = { Foo : string }
[<AutoSerializable(false)>]
type Bar = { Foo : Foo }
type Baz = { Bar : Bar }
[<EntryPoint>]
let main argv =
FsPickler.DeclareSerializable<Bar>()
FsPickler.GeneratePickler<Baz>() |> ignore
printfn "%A" argv
0 // return an integer exit code
fails with
If I add FsPickler.DeclareSerializable<Foo>()
, then it works.
Actual Result: The exception says Bar is not serializable Expected Result: An inner exception which contains a mention of Foo.
Wow that was fast. Thank you!
$exception {"Type 'Program+Baz' contains non-serializable field of type 'Program+Bar'."}
_innerException {"Type 'Program+Bar' contains non-serializable field of type 'Program+Foo'."}
_innerException {"Type 'Program+Foo' is not serializable."}
I am currently trying to serialize a Roslyn compilation using FsPickler. I have manually marked
CSharpCompilation
as Serializable usingFsPickler.DeclareSerializable
. Serialization still fails with the Exception that it can't serialize 'CSharpCompilation'Debugging shows the real non-serializable type, but this information was lost in the topmost exception:
Please pass the original exception through as an inner exception so it is possible to see for which type it failed without needing to attach a debugger.