Ejemplo n.º 1
0
        public bool Execute()
        {
            if (InputFiles == null)
            {
                // Target was included but no .psharp files are present in the project. Skip
                // execution.
                return(true);
            }

            for (int i = 0; i < InputFiles.Length; i++)
            {
                var    inp    = File.ReadAllText(InputFiles[i].ItemSpec);
                string errors = "";
                var    outp   = SyntaxRewriter.Translate(inp, out errors, this.csVersion);
                if (outp != null)
                {
                    // Tagging the generated .cs files with the "<auto-generated>" tag so as to avoid StyleCop build errors.
                    outp = "//  <auto-generated />\n" + outp;
                    File.WriteAllText(OutputFiles[i].ItemSpec, outp);
                }
                else
                {
                    // Replaces Program.psharp with the actual file name.
                    errors = errors.Replace("Program.psharp", System.IO.Path.GetFileName(InputFiles[i].ItemSpec));

                    // Prints a compiler error with log.
                    File.WriteAllText(OutputFiles[i].ItemSpec,
                                      string.Format("#error Psharp Compiler Error {0} /* {0} {1} {0} */ ", "\n", errors));
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Execute()
        {
            for (int i = 0; i < InputFiles.Length; i++)
            {
                var    inp = System.IO.File.ReadAllText(InputFiles[i].ItemSpec);
                string errors;
                var    outp = SyntaxRewriter.Translate(inp, out errors);
                if (outp != null)
                {
                    System.IO.File.WriteAllText(OutputFiles[i].ItemSpec, outp);
                }
                else
                {
                    // replace Program.psharp with the actual file name
                    errors = errors.Replace("Program.psharp", System.IO.Path.GetFileName(InputFiles[i].ItemSpec));
                    // print a compiler error with log
                    System.IO.File.WriteAllText(OutputFiles[i].ItemSpec,
                                                string.Format("#error Psharp Compiler Error {0} /* {0} {1} {0} */ ", "\n", errors));
                }
            }

            return(true);
        }