__SOURCE_FILE__ are built-in values that enable you to access the source line number, directory and file name in your code.
__LINE__ __SOURCE_DIRECTORY__ __SOURCE_FILE__
Each of these values has type
The following table summarizes the source line, file, and path identifiers that are available in F#. These identifiers are not preprocessor macros; they are built-in values that are recognized by the compiler.
||Evaluates to the current line number, considering
||Evaluates to the current full path of the source directory, considering
||Evaluates to the current source file name and its path, considering
For more information about the
#line directive, see Compiler Directives.
The following code example demonstrates the use of these values.
let printSourceLocation() = printfn "Line: %s" __LINE__ printfn "Source Directory: %s" __SOURCE_DIRECTORY__ printfn "Source File: %s" __SOURCE_FILE__ printSourceLocation()
Line: 4 Source Directory: C:\Users\username\Documents\Visual Studio 2017\Projects\SourceInfo\SourceInfo Source File: C:\Users\username\Documents\Visual Studio 2017\Projects\SourceInfo\SourceInfo\Program.fs