LINQPad program queries with args don't compile
Suppose the following LINQPad program query:
<Query Kind="Program">
</Query>
void Main(string[] args)
{
}
// Define other methods and classes here
When run through lpless, the compiled program fails to build due to the following error:
error CS0111: Type 'UserQuery' already defines a member called 'Main' with the same parameter types
Thank you for this helpful program. Given some assumptions, I was able to workaround this issue for my needs. Starting from line 567 in Program.cs, I commented out the following lines:
"class UserQuery {",
//" static int Main(string[] args) {",
//" new UserQuery().Main()" + (IsMainAsync(source) ? ".Wait()" : null) + "; return 0;",
//" }",
source,
"}")
Now, the original Main() is not wrapped. This does not account for an async Main. When I declare Main() in the linq script, I make it return an int and give it the standard (string[] args) parameter set. Given the limitations introduced by commenting out the above lines, I can now use lpless to compile a linq script, and the target EXE will accept arguments.
@dm3ll3n Thanks for dropping a note with a workaround that worked for you. I'm sure it'll help others encountering the same bug.
This feels like a pretty big limitation. Is there a plan to fix this? Would you accept a PR?
Is there a plan to fix this?
It's been fixed in the branch that will become version 2.
Would you accept a PR?
If you need this fixed more immediately for v1 then I'd be happy to accept a PR and make a release.
Is there a plan to fix this?
It's been fixed in the branch that will become version 2.
You can see here that all signatures of Main, of which there are quite a few when you line them all up, are supported:
https://github.com/linqpadless/LinqPadless/blob/97f373fe96e769be1fda7359e531a52ce49aa815/src/Program.cs#L778-L799