When you write an inline function, the compiler builds the body of the function into the calling code. As discussed in the comments, it also does not output debugging information for this built-in body (and therefore you cannot enter the function - I think this can be fixed - send a request to fsbugs to microsoft dot com ).
However, the compiler also generates a dynamic version of the code - if you write say:
let inline add ab = a + b
then the compiled code actually has an add method. The method will be general ( 'a -> 'b -> 'c ) and uses dynamic search to find the appropriate implementation of the + operator (since .NET generators cannot represent such restrictions).
A dynamic implementation will be called when using reflection or quotes:
open Microsoft.FSharp.Linq.RuntimeHelpers <@ add 1 2 @> |> LeafExpressionConverter.EvaluateQuotation |> printfn "Got: %A"
If you set a breakpoint inside add and run the code above, the breakpoint will be deleted (and I believe that the code coverage tool will report the function as being covered).
But keep in mind that this is not the code that actually runs when you write add 1 2 in normal code - the executable code here is a different implementation (which uses slow dynamic search, not inlining).
source share