Fsharp: [From VSTS] Display None as "None" instead of "null" in Data Tips

Created on 9 Oct 2017  路  7Comments  路  Source: dotnet/fsharp

From here: https://developercommunity.visualstudio.com/content/problem/44030/f-debugging-option-types-returns-null.html

The behavior described is also the same in VS2015 Update 3:

null-vs2015

So this is not a regression.

Area-IDE Debug Feature Improvement

All 7 comments

We could only do this with our own debugger engine which was aware of F# types

@gregg-miskelly just to check - is this another case of "F# needs its own EE"?

Correct

link #2544

I just wasted an hour due to this issue.

> printfn "%A" None;;
<null>
val it : unit = ()

> printfn "%A" null;;
<null>
val it : unit = ()

>

Supremely confusing when you're looking at server logs for things that you think should be Options.

@samuela What you describe is not this issue. This issue is about the representation of None in debugging tools.

What you're observing is thatNone emits as null in IL, which explains why you'd see that as the value in logs. As a remediation, I'd recommend sending all logs through a function that does a check for options, emitting something else for the None case. You can check like this:

let inline isOptionType (t:System.Type) =
    t.GetTypeInfo().IsGenericType && t.GetGenericTypeDefinition() = typedefof<option<_>>
Was this page helpful?
0 / 5 - 0 ratings