oleg-shilo / cs-script

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

cs_prescript does not work #282

Closed eugene-vv closed 2 years ago

eugene-vv commented 2 years ago

Hello Oleg, I unzipped manually cs-script.win.4.4.0.0 version. And for test purpose (pre/post scripts execution) created example main2.cs: //css_pre pre2($this); using System; public class Main2 { public static void Main(string[] args) { Console.WriteLine("Main2 script"); } } And pre2.cs: using System; public class Pre2 { public static void Main(string[] args) { Console.WriteLine("Pre2"); } } both in one folder. running cscs main2.cs returns OverflowException: Am I doing something wrong?

oleg-shilo commented 2 years ago

It is a bug. let me have a look at it

oleg-shilo commented 2 years ago

Until the problem is fixed you can use this workaround.

pcs.cs file

using System;
using System.Collections;
using System.Collections.Generic;

public class Sample_Precompiler // precompiler class name must end with 'Precompiler'
{
    public static bool Compile(ref string scriptCode, string scriptFile, bool isPrimaryScript, Hashtable context)
    {
        Console.WriteLine(scriptFile);
        return false;
    }
}

script.cs file

//css_pc pc.cs
using System;

public class script
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Main script");
    }
}
eugene-vv commented 2 years ago

Thanks for quick answer. I will implement workaround in my code.

oleg-shilo commented 2 years ago

Fixed in v4.4.2.0