I've declared a tuple like this:
module MyModule =
let private INVALID_TUPLE = ("0", DateTime.MinValue)
When I reference it lower in the module, it's always null:
let private invalidForNone someOtherTuple =
match someOtherTuple with
| None -> INVALID_TUPLE // it's null
| Some(t) -> t
Further, when I place a breakpoint on the tuple declaration, it never hits.
If I do the exact same thing in a script (fsx) file, start debugging, execute, the breakpoint on the tuple declaration hits and the reference to the tuple is good.
ILSpy for my module shows that there is some startup code generated that has a Main method that creates INVALID_TUPLE. Apparently, that's not running for some reason?
Here is a sample that reproduces the behavior (now that I realize it has something to do with the way MSTest executes the code). Call this from a C# unit test; result will be null. In fact, no breakpoint in the F# code will execute at all.
module NullTupleTest
open System
let private INVALID_TUPLE = ("invalid", DateTime.MinValue)
let private TupleTest someTuple =
match someTuple with
| None -> INVALID_TUPLE
| Some(dt) -> dt
let Main = TupleTest None