Home
Options

LPRun inconsistently outputs F# compiler information when called from LINQPad

edited October 2018
LPRun is generating extra output with F# compiler information when an LPRun command is executed from LINQPad.

This seems to be a bug because:
(1) There doesn't appear to be any way to disable the behavior (other than post-processing the output);
(2) It appears inconsistently. When a batch file is called from LINQPad using Util.Cmd then the F# compiler info is output, but this does not happened when called from command prompt. Similarly, no compiler info is included in the output for any non-F# language arguments.

Here is a screenshot of a LINQPad script that executes equivalent commands using F# and C# programs and expressions:
image

Here is the code for a batch file that will execute each equivalent command using F# and C# programs and expressions:

ECHO OFF
ECHO.
ECHO FSharpExpression
ECHO ----------------
ECHO.
cmd /c ECHO "Hello World" > HelloWorld && CALL "%ProgramFiles(x86)%\LINQPad5\5.35.0-AnyCPU\LPRun.exe" -lang=FSharpExpression HelloWorld && DEL HelloWorld && ECHO %ERRORLEVEL%
ECHO.
ECHO FSharpProgram
ECHO -------------
ECHO.
cmd /c ECHO "Hello World".Dump() > HelloWorld && CALL "%ProgramFiles(x86)%\LINQPad5\5.35.0-AnyCPU\LPRun.exe" -lang=FSharpProgram HelloWorld && DEL HelloWorld && ECHO %ERRORLEVEL%
ECHO.
ECHO Expression
ECHO ----------
ECHO.
cmd /c ECHO "Hello World" > HelloWorld && CALL "%ProgramFiles(x86)%\LINQPad5\5.35.0-AnyCPU\LPRun.exe" -lang=Expression HelloWorld && DEL HelloWorld && ECHO %ERRORLEVEL%
ECHO.
ECHO Program
ECHO -------
ECHO.
cmd /c ECHO void Main(){ "Hello World".Dump(); } > HelloWorld && CALL "%ProgramFiles(x86)%\LINQPad5\5.35.0-AnyCPU\LPRun.exe" -lang=Program HelloWorld && DEL HelloWorld && ECHO %ERRORLEVEL%
If the batch file is called directly from a command prompt , no F# compiler information will be output. If the batch file is called using Util.Cmd then the F# compiler information will be output.

Below are screenshots of calling the batch from LINQPad and from CMD:

From LINQPad:


image





From CMD:


image




* It's worth noting that the way I happened across this problem was a work around to calling parameterized F# queries with Util.Run . Arguments don't seem to bind to correctly to F# programs when given a signature like:

[<EntryPoint>]
let main args =
// do stuff with args
0
In most cases, arguments can be still be extracted from Environment.GetCommandLineArgs() , but I found that calling into LPRun gave me a way to circumvent the added ceremony of parsing out relevant arguments until this problem came up. It seems to me that, in an ideal world both LPRun output *and* argument binding would work consistently across supported languages. Pragmatically, it would be pretty helpful if this were true for at least one of these features.




UPDATE: I found that I was able to suppress the compiler info output behavior by setting the "Always use built-in F# compiler" setting to true. Obviously, this is a sub-optimal work-around because it means F# version will always be bound to the LINQPad release, but it is sufficient in many cases and will probably provide insight to tracking down why this happens. (e.g. Maybe the extraneous content emitted by the built-in F# compiler is filtered but the version it was using on my machine - apparently 10.1.0 for F# 4.1 - didn't match. ) Argument binding from Util.Run still fails in both situations.
Sign In or Register to comment.