Compiler.Main C# (CSharp) Method

Main() public static method

public static Main ( string args ) : int
args string
return int
  public static int Main(string[] args){
    AppDomainSetup setup = new AppDomainSetup();

    // fusion settings
    setup.PrivateBinPath = "";
    setup.PrivateBinPathProbe = "*";  // disable loading from app base

    try {
      AppDomain appDomain = null;
      Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
      appDomain = AppDomain.CreateDomain("Compiler", evidence, setup);
      JScriptCompiler jsc = (JScriptCompiler)(appDomain.CreateInstance(
        Assembly.GetAssembly(typeof(JScriptCompiler)).FullName, "JScriptCompiler").Unwrap());
      return jsc.Run(args);
    }
    catch (Exception e) {
      Console.WriteLine(JScriptCompiler.Localize("INTERNAL COMPILER ERROR", e.Message));
      return 10;
    }
    catch {
      Console.WriteLine(JScriptCompiler.Localize("INTERNAL COMPILER ERROR"));
      return 10;
    }
  }
}

Usage Example

Ejemplo n.º 1
0
        protected void Invoke([CallerMemberName] string caller = null)
        {
            // Arrange
            string testCasePath = GetPath(caller);

            string[] args = GetArgs(testCasePath);

            // Act
            int result = Compiler.Main(args);

            // Assert
            Assert.AreEqual(expectedResult, result);
            AssertCorrect(testCasePath);
        }
Compiler