Пример #1
0
        public bool Compile(CodeDomProvider codeProvider, string source, TempFileRef dataContextAssembly, QueryLanguage queryKind, string compilerOptions)
        {
            if (this.IsMyExtensions)
            {
                string directoryName = Path.GetDirectoryName(MyExtensions.QueryFilePath);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }
                TempFileRef ref2 = new TempFileRef(Path.ChangeExtension(MyExtensions.QueryFilePath, ".dll"))
                {
                    AutoDelete = false
                };
                this.OutputFile = ref2;
                TempFileRef ref3 = new TempFileRef(Path.ChangeExtension(MyExtensions.QueryFilePath, ".pdb"))
                {
                    AutoDelete = false
                };
                this.PDBFile = ref3;
            }
            else
            {
                this.OutputFile = TempFileRef.GetRandom("query", ".dll");
                this.PDBFile    = new TempFileRef(Path.ChangeExtension(this.OutputFile.FullPath, ".pdb"));
            }
            List <string> references = new List <string>(this.References);

            if (!((dataContextAssembly == null) || string.IsNullOrEmpty(dataContextAssembly.FullPath)))
            {
                references.Add(dataContextAssembly.FullPath);
            }
            return(base.Compile(codeProvider, references, source.ToString(), this.OutputFile.FullPath, compilerOptions));
        }
Пример #2
0
        public override bool Compile(string queryText, QueryCore query, TempFileRef dataContextAssembly)
        {
            Process       process;
            string        str9;
            bool          flag2;
            StringBuilder builder = new StringBuilder(this.GetHeader(query));

            base.LineOffset = builder.ToString().Count <char>(c => c == '\n');
            if (queryText.Trim().Length == 0)
            {
                queryText = "\"\"";
            }
            string str = queryText.Replace("\t", "".PadRight(UserOptions.Instance.TabSizeActual));

            if (query.QueryKind == QueryLanguage.FSharpExpression)
            {
                str = "  " + str.Replace("\r\n", "\r\n  ");
            }
            builder.AppendLine(str);
            builder.Append(this.GetFooter(query));
            base.OutputFile = TempFileRef.GetRandom("query", (query.QueryKind == QueryLanguage.FSharpExpression) ? ".dll" : ".exe");
            base.PDBFile    = new TempFileRef(Path.ChangeExtension(base.OutputFile.FullPath, ".pdb"));
            List <string> list = new List <string>(base.References);

            if (dataContextAssembly != null)
            {
                list.Add(dataContextAssembly.FullPath);
            }
            string str2 = @"Microsoft F#\v4.0\fsc.exe";
            string path = Path.Combine(PathHelper.ProgramFiles, str2);
            string str4 = Path.Combine(PathHelper.ProgramFilesX86, str2);

            if (!(File.Exists(path) || File.Exists(str4)))
            {
                base.ReportError("Cannot locate " + str4 + " - is F# installed?");
                return(false);
            }
            string           str5      = File.Exists(str4) ? str4 : path;
            string           str6      = Path.ChangeExtension(base.OutputFile.FullPath, ".fs");
            string           str7      = (query.QueryKind == QueryLanguage.FSharpExpression) ? "library" : "exe";
            string           str8      = (("-o:\"" + base.OutputFile.FullPath + "\" -g --debug:full --target:" + str7 + " --utf8output " + this.GetCompilerOptions(query) + " ") + string.Join(" ", (from r in list select "-r:\"" + r + "\"").ToArray <string>())) + " \"" + str6 + "\"";
            ProcessStartInfo startInfo = new ProcessStartInfo {
                FileName              = str5,
                Arguments             = str8,
                RedirectStandardError = true,
                UseShellExecute       = false,
                CreateNoWindow        = true
            };

            File.WriteAllText(str6, builder.ToString());
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                process = Process.Start(startInfo);
                str9    = process.StandardError.ReadToEnd();
            }
            finally
            {
                try
                {
                    File.Delete(str6);
                }
                catch
                {
                }
            }
            stopwatch.Stop();
            if (!(flag2 = process.ExitCode == 0))
            {
                this.ParseError(str9);
            }
            return(flag2);
        }