The following code throws
let x : ValueOption<int> = ValueNone
let y = x.ToString()
System.InvalidOperationException: ValueOption.Value
at Microsoft.FSharp.Core.FSharpValueOption`1.get_Value()
at Microsoft.FSharp.Core.FSharpValueOption`1.ToString()
at Microsoft.FSharp.Core.PrintfImpl.FinalFast1@264.Invoke(FSharpFunc`2 env, A a)
at <StartupCode$FSI_0013>.$FSI_0013.main@()
The behaviour should be comparable to the option type where
let x : Option<int> = None
let y = x.ToString()
Does not throw and sets y = "<null>"
This is a real pain when logging value in text files, as you expect sprintf "%O" to work for all F# types. Perhaps you could simply override .ToString() for ValueOption?
This is FSharp.Core 4.6.2, .Net Framework 4.8
The following code throws
The behaviour should be comparable to the option type where
Does not throw and sets
y = "<null>"This is a real pain when logging value in text files, as you expect sprintf "%O" to work for all F# types. Perhaps you could simply override .ToString() for ValueOption?
This is FSharp.Core 4.6.2, .Net Framework 4.8