CommonFSharp (Polyglot)¶
In [ ]:
#!import ../../lib/fsharp/Notebooks.dib
#!import ../../lib/fsharp/Testing.dib
In [ ]:
#!import ../../lib/fsharp/Common.fs
In [ ]:
open Common
getUnionCaseName¶
In [ ]:
let inline getUnionCaseName<'T> (x: 'T) =
match Reflection.FSharpValue.GetUnionFields(x, typeof<'T>) with
| case, _ -> case.Name
In [ ]:
//// test
TraceLevel.Critical
|> getUnionCaseName
|> _assertEqual (nameof TraceLevel.Critical)
"Critical"