Home

Problem running LPRun

First off, the documentation seems somewhat outdated. The executable is now named lprun7, not lprun. Aside from that, I have been trying to run a very simple query using the command line, and it generally works, except for referencing assemblies. Here is what I have in a test.cs file (copy pasted from the documentation):

ref nuget:Rx-Main;
using System.Reactive.Linq;

Observable.Range(1,10)

Then, when I try running it with the following command the compiler complains about the language:
Command:

lprun7 -lang=e test.cs

Result:

) or end of expression expected (change the Query Language to 'C# Statements' for statement-based queries)

Of course, this is not a statement, but if I modify it (add a ';' to the method call) and then run it as Statement, I'll get a host of errors, basically indicating that the program cannot parse the ref directive:
test.cs:

ref nuget:Rx-Main;
using System.Reactive.Linq;

Observable.Range(1,10);

Command:

lprun7 -lang=s test.cs

Result:

CS1001 Identifier expected line 0 column 9
CS1002 ; expected line 0 column 9
CS1513 } expected line 0 column 9
CS1001 Identifier expected line 1 column 26
CS0246 The type or namespace name 'nuget' could not be found (are you missing a using directive or an assembly reference?) line 0 column 4
CS8174 A declaration of a by-reference variable must have an initializer line 0 column 9
CS0103 The name 'Rx' does not exist in the current context line 0 column 10
CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement line 0 column 10
CS0234 The type or namespace name 'Reactive' does not exist in the namespace 'System' (are you missing an assembly reference?) line 1 column 13
CS0210 You must provide an initializer in a fixed or using statement declaration line 1 column 26
CS0103 The name 'Observable' does not exist in the current context line 3 column 0

What am I doing wrong?

Comments

  • edited December 2022

    Also worth noting, if I use txt file extension (instead of cs) for my script as suggested in the documentation example below, running it through lprun seems to do nothing.

    Command

    echo 12+12 > script.txt
    lprun7 -lang=e script.txt
    

    Expected Output:

    24
    

    Actual Output:


  • edited December 2022

    LINQPad expects .cs files to be like those you would find in a standard .csproj project, so it doesn't attempt to parse special driectives such as "ref nuget", and assumes its content is a program. You need to save the file with a .linq extension - then your example will work. Note that it's valid to omit the XML header normally present in .linq files, as long as you include the -lang switch when calling LPRun7.

    Also note that in your first example, you currently need to call .ToEnumerable() in order to see any output via LPRun7:

    Observable.Range (1, 10).ToEnumerable()

    This is due to a bug in the asynchronous coupling to the console output. I've registered this, so it should get fixed in the next LINQPad update.

    One further point is that the NuGet package for Reactive Extensions is now System.Reactive. Rx-Main is several years out of date.

    P.S. I've updated the documentation now - thanks for the head-up. I'll also investigate why .txt files don't behave like .linq files as the documentation previously stated.

Sign In or Register to comment.