Exemplo n.º 1
0
        public VerificationResult Verify(Silvernode silvernode)
        {
            if (!nailgunInitialized)
            {
                // Start Nailgun server.
                ReadyNailgun();
                nailgunInitialized = true;
            }

            string silvercode = silvernode.ToString();
            string filename   = Path.GetTempFileName();

            File.WriteAllText(filename, silvercode);
            try
            {
                // Run the nailgun client, catch the output.
                Process p = new Process
                {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true,
                        RedirectStandardError  = true
                    }
                };
                var enviromentPath = Environment.GetEnvironmentVariable("PATH");
                Debug.Assert(enviromentPath != null, "enviromentPath != null");
                var paths   = enviromentPath.Split(';');
                var exePath = paths
                              .Select(x => Path.Combine(x, "ng.exe"))
                              .FirstOrDefault(File.Exists) ?? "ng.exe";
                p.StartInfo.FileName = exePath;
                // Runner class is the class that operates the verifier (programmed in Scala).
                p.StartInfo.Arguments = _runnerClass + " \"" + filename + "\"";
                p.Start();
                string output = p.StandardOutput.ReadToEnd();
                p.WaitForExit();
                VerificationResult r = new VerificationResult
                {
                    OriginalOutput = output,
                    Errors         = BackendUtils.ConvertErrorMessages(output, silvernode)
                };
                return(r);
            }
            catch (Exception)
            {
                return(VerificationResult.Error(new Error(Diagnostics.SSIL201_BackendNotFound, null, "ng.exe")));
            }
        }
Exemplo n.º 2
0
        public VerificationResult Verify(Silvernode silvernode)
        {
            string silvercode = silvernode.ToString();
            string filename   = Path.GetTempFileName();

            File.WriteAllText(filename, silvercode);
            try
            {
                // Find and run "silicon.bat" in PATH and catch the output
                Process p = new Process
                {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true
                    }
                };
                p.StartInfo.RedirectStandardOutput = true;
                var enviromentPath = Environment.GetEnvironmentVariable("PATH");
                Debug.Assert(enviromentPath != null, "enviromentPath != null");
                var paths   = enviromentPath.Split(';');
                var exePath = paths
                              .Select(x => Path.Combine(x, "silicon.bat"))
                              .FirstOrDefault(File.Exists) ?? "silicon.bat";
                p.StartInfo.FileName  = exePath;
                p.StartInfo.Arguments = "\"" + filename + "\"";
                p.Start();

                string             output = p.StandardOutput.ReadToEnd();
                VerificationResult r      = new VerificationResult
                {
                    OriginalOutput = output,
                    Errors         = BackendUtils.ConvertErrorMessages(output, silvernode)
                };
                return(r);
            }
            catch (Exception)
            {
                return(VerificationResult.Error(new Error(Diagnostics.SSIL201_BackendNotFound, null, "silicon.bat")));
            }
        }