Menu

Decompiling F#-Compiled Assemblies in a C# Decompiler: Reading Unions, Records, and Modules
πŸ“°

Decompiling F#-Compiled Assemblies in a C# Decompiler: Reading Unions, Records, and Modules

DEV Community: dotnetΒ·Zero HeartbeatΒ·5 days ago
#hbHyUPXO
#devtodotnet#devto#dev#shape#compilationmapping
Reading 0:00
15s threshold

If you have ever opened an F#-built DLL in a decompiler expecting to see let and match and instead found classes with names like Tag and NewCircle , this post is for you. F# and C# are different languages, but they share one back end: both compile to ECMA-335 CLI metadata and IL. A decompiler reconstructs C# from that IL, so pointing a C# decompiler like Glass at an F# assembly gives you a faithful, readable β€” if slightly unusual β€” C# rendering of the F# compiler's output. Knowing how each F# construct is lowered turns that rendering from confusing into obvious.

The fingerprint: FSharp.Core and CompilationMapping

Two things immediately mark an assembly as F#-origin. First, a reference to FSharp.Core.dll , the runtime every F# program depends on. Second, the [CompilationMapping] attribute sprinkled across types and members. That attribute carries a SourceConstructFlags enum value β€” Module , SumType , RecordType , UnionCase , Field , Value , and friends β€” that records what the element was in F# source.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.