Issue with Automatic Language Switching
I just started using LINQPad8 and encountered an issue, described as follows:
Currently, LINQPad's language is set to C# Expression(s). When I paste C# code that contains the Main function, the language automatically switches to C# Program, which is convenient.
However, at the same time, LINQPad adds an empty Main function at the top of the code, and I have to manually delete it each time, which is inconvenient.
I think that when pasting code into the editor, it should check whether a Main function already exists in the code. If it does, LINQPad should not add an empty Main function again.
To better illustrate the issue, I recorded a dynamic GIF demonstration.
https://i.ibb.co/B40nYbD/demo.gif
Empty Main function Code:
void Main() { }
Test Code:
using System; class Program { static void Main() { // Get the operating system version information var os = Environment.OSVersion; // Output the operating system platform and version number Console.WriteLine("Operating System Platform: " + os.Platform); Console.WriteLine("Operating System Version: " + os.Version); Console.WriteLine("Operating System Version String: " + os.VersionString); // Get the service pack information Console.WriteLine("Service Pack Version: " + os.ServicePack); } }
Comments
Thanks for reporting - this should now be fixed in the latest beta.
https://www.linqpad.net/linqpad8.aspx#beta
There are still issues; the language did not automatically switch to C# Program. Please see the demonstration below.
https://i.ibb.co/Fxkmzrg/A.gif
In previous versions of LinqPad, if the code you wanted to paste contained a Main function, the language would automatically switch to C# Program.
This occurs when you answer 'No' to moving the namespace imports. It should really work in either case. I've fixed this in 8.6.5.
@JoeAlbahari
Thank you! The issue has been resolved in the new version 8.6.5.
However, I have a feature request:
I don't want to click the No button every time the pop-up message "Move 'using' directives into Query Properties" appears!
Suggestion: **
add an option in Preferences --> Query like the following:
**□ Do not Move 'using' directives into Query Properties
When this option is manually checked, the above pop-up message will no longer appear.
I often use Linqpad to write some great example code, which I then share on my blog. The code requires using directives to remain complete, and clicking the No button each time is too cumbersome. Adding this feature would be simple to implement and very useful.
Thank you again!