Пример #1
0
        static void Main(string[] args)
        {
            var src = @"
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Slowsharp;
 
namespace HelloWorld
{

    class Fooo : Bar {
        public static int aa = 1;

        public int FF { get { return ff; } }        
        
        public void Foo() {
            Console.WriteLine(1);
        }
        public void Foo(int b) {
            Console.WriteLine(11);
        }
    }

class Boor : Bar {


public void MoveForward() {  
    transform.position += new Vector3(11,1,1);
}
}
class MyList : List<int> { }
    class Program : Bar, IFoo
    {
static int bb = 1;
static int Foo() { return 5; }
static int Foo(int n) { return 15; }

public static int Booo(int n = 5) => 5;

static IEnumerator Bbb() {
yield return 1;
yield return 2;
yield return 3;
}

private static int acac = 123;

        static int Main(int n) {

var a = new int[] {1,2,3,4}
return a.Any((int x) => { return x > 2; });

return v;

return 0;
//return ""asdf"";
        }

static void Bo() {
var aa = 1234;
Console.WriteLin(aa);
}
    }
}
";

            var hotReloadSrc = @"
class Fooo : Bar {
    public void Foo() {
        Console.WriteLine(12341234);
    }
}
";

            src = System.IO.File.ReadAllText("a.cs");

            Console.WriteLine(nameof(Console));
            Console.WriteLine(CScript.RunSimple("\"hello from inception\""));

            Console.WriteLine(src);

            CSharpParseOptions options = new CSharpParseOptions(LanguageVersion.Default, kind: SourceCodeKind.Script);
            var tree = CSharpSyntaxTree.ParseText(src);
            var root = tree.GetCompilationUnitRoot();

            Dump(root);

            var config = ScriptConfig.Default;

            config.PrewarmTypes = new Type[] { typeof(Console) };

            var run = CScript.CreateRunner(src, config);

            SSDebugger.runner = run;
            var myList = run.RunMain();

            Console.WriteLine(myList.Is <List <int> >());

            var vd = new Validator();

            vd.Visit(root);

            var r = new Runner(config, new RunConfig()
            {
            });

            r.Run(root);

            Console.WriteLine(r.RunMain(5));
            Console.WriteLine(Goo());

            return;

            tree = CSharpSyntaxTree.ParseText(hotReloadSrc);
            root = tree.GetCompilationUnitRoot();
            r.UpdateMethodsOnly(root);

            r.RunMain(5);

            return;

            var bar = new Bar();
            //dynamic d = new DynamicHybInstance(r.Override("Boor", bar));
            //d.Boo();
            //d.SayHello();
            var boor = r.Override("Boor", bar);

            boor.Invoke("MoveForward");

            Console.WriteLine(bar.transform.position.x);

            //Console.WriteLine(r.Instantiate("Fooo").Invoke("Foo", 1));

            var a = new List <int>()
            {
            };

            a.Any();
            Any(a, (int x) => true);
        }
Пример #2
0
        static void Main(string[] args)
        {
            var src = @"
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Slowsharp;
 
namespace HelloWorld
{

    class Fooo : Bar {
        public static int aa = 1;

        public int FF { get { return ff; } }        
        
        public void Foo() {
            Console.WriteLine(1);
        }
        public void Foo(int b) {
            Console.WriteLine(11);
        }
    }

class Boor : Bar {


public void MoveForward() {  
    transform.position += new Vector3(11,1,1);
}
}
class MyList : List<int> { }
    class Program : Bar, IFoo
    {
static int bb = 1;
static int Foo() { return 5; }
static int Foo(int n) { return 15; }

public static int Booo(int n = 5) => 5;

static IEnumerator Bbb() {
yield return 1;
yield return 2;
yield return 3;
}

private static int acac = 123;

        [Aa]
        static int Main(int n) {

var c = new Action<int>((int a) => { Console.WriteLine(a); });
c.Invoke(1234879);

return 1;

var a = new int[] {1,2,3,4}
return a.Any((int x) => { return x > 2; });

return v;

return 0;
//return ""asdf"";
        }

static void Bo() {
var aa = 1234;
Console.WriteLin(aa);
}
    }
}
";

            var hotReloadSrc = @"
class Fooo : Bar {
    [Aa]
    public void Foo() {
        Console.WriteLine(12341234);
    }
}
";

            //src = System.IO.File.ReadAllText("a.cs");

            Console.WriteLine(nameof(Console));
            Console.WriteLine(CScript.RunSimple("\"hello from inception\""));

            Console.WriteLine(src);

            var config = ScriptConfig.Default;

            config.PrewarmTypes = new Type[] { typeof(Console) };

            var run = CScript.CreateRunner(src, config);

            run.Dump();
            SSDebugger.runner = run;

            run.Trap(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }),
                     typeof(Program).GetMethod("NewWriteLine"));

            var myList = run.RunMain();

            Console.WriteLine(myList.Is <List <int> >());

            return;
        }