oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.62k stars 235 forks source link

Do not overwrite return code set in Environment.ExitCode #265

Closed husk3r closed 2 years ago

husk3r commented 2 years ago

Hi Oleg,

it's me again. I just figured out that the return code was handled wrong when I execute scripts by cscs myScript.cs

//css_args -ac

using System;

class MyClass
{
    public static int Main(string[] args)
    {
        Console.WriteLine("My Test");
        return -2;
    }
}

Expectation is here that the error level is set to -2 after running this script, but it's 0. I debugged it at found that the Main function of cscs overwrites the return code set in Environment.ExitCode. This commit changes the signature to void and removes the return statements.

Florian

husk3r commented 2 years ago

Gentle ping, since I opened two merge requests and you missed this one :-)

oleg-shilo commented 2 years ago

Hi, @husk3r,

No, I did not miss this one 😄 Yes it is a bug but I have just addressed it in a slightly different way: 0f26381

Thank you for reporting/fixing.

husk3r commented 2 years ago

Also fine for me, thank you so much for your support. I will close this pull request