Esempio n. 1
0
        private void ExecuteOnce()
        {
            var csSource = Transpile(_cmd.SourceFilename);

            _reEval = new ResultEvaluation(csSource, _resultLog);
            CSCompiler.Compile(csSource,
                               onSuccess: Run,
                               onFailure: _reEval.HandleCompilerErrors
                               );
        }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int    error   = 0;
            string message = string.Empty;
            var    cpr     = CSCompiler.Compile(textBox1.Text, "aaa.dll", out error, out message);

            if (error != 0)
            {
                textBox2.Text = message;
            }

            object obj1 = CSCompiler.CreateObject(cpr, "WpfApplication1.NS", null, 0);
            //object obj2 = CSCompiler.CreateObject(cpr, "test.CTObservableCollection", null, 0);
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string message   = string.Empty;
            int    errorcode = CSCompiler.Compile(textBox1.Text, "test.dll", out message);

            if (errorcode != 0)
            {
                textBox2.Text = message;
            }

            //object obj1 = CSScript.CSScript.CreateObject("test.dll", "test.testdata", null);
            //object obj2 = CSScript.CSScript.CreateObject("test.dll", "test.CTObservableCollection", null);

            //string message = string.Empty;
            int    error = 0;
            object obj   = CSCompiler.Compile(textBox1.Text, "test.testdata", null, out error, out message);

            if (errorcode != 0)
            {
                textBox2.Text = message;
            }
        }
Esempio n. 4
0
        public void Compile_no_errors()
        {
            var csSource = new Sourcecode
            {
                Filename = "program_no_errors.cs",
                Text     = @"using System;
public class Program {
  public static void Main(string[] args) {
    #region main
var answer = 42;
Console.WriteLine(answer);
    #endregion
  }
}
".Split('\n')
            };

            Executable result = null;

            CSCompiler.Compile(csSource,
                               exe => result = exe,
                               errors => {
                foreach (var err in errors)
                {
                    Console.WriteLine($"{err.Filename} - {err.LineNumber},{err.ColumnNumber}: {err.Description}");
                }
                Assert.Fail("There should not be any errors!");
            });

            Assert.NotNull(result);


            var output = ConsoleOutput.Capture(() => result.Main());

            Assert.AreEqual("42", output.Trim());
        }