Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINQPad program queries with args don't compile #25

Open
atifaziz opened this issue Mar 28, 2018 · 5 comments
Open

LINQPad program queries with args don't compile #25

atifaziz opened this issue Mar 28, 2018 · 5 comments
Labels

Comments

@atifaziz
Copy link
Owner

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
@atifaziz atifaziz added the bug label Mar 28, 2018
@fresh2dev
Copy link

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.

@atifaziz
Copy link
Owner Author

@dm3ll3n Thanks for dropping a note with a workaround that worked for you. I'm sure it'll help others encountering the same bug.

@madelson
Copy link

This feels like a pretty big limitation. Is there a plan to fix this? Would you accept a PR?

@atifaziz
Copy link
Owner Author

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.

@atifaziz
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants