示例#1
0
    public void Parse(string input)
    {
      Regex rebuild = new Regex("------ [^:]+: [^:]+: (?<name>[^,]+)");
      Regex complete = new Regex("Compile complete --[^0-9]+(?<errors>[0-9]+)[^0-9]+(?<warnings>[0-9]+)");
      Regex summary = new Regex("========== [^0-9]+(?<succeeded>[0-9]+)[^0-9]+(?<failed>[0-9]+)[^0-9]+(?<skipped>[0-9]+)");

      _solution = new Solution();
      _solution.Name = "Unknown";

      //Match slnSummary = summary.Match(input);
      //if (slnSummary.Success)
      //{
      //  _solution.Succeeded = Int32.Parse(slnSummary.Groups["succeeded"].Value);
      //  _solution.Failed = Int32.Parse(slnSummary.Groups["failed"].Value);
      //  _solution.Skipped = Int32.Parse(slnSummary.Groups["skipped"].Value);
      //}

      MatchCollection projStart = rebuild.Matches(input);
      MatchCollection projComplete = complete.Matches(input);

      int c = 0;
      for (int i = 0; i < projStart.Count; i++)
      {
        Project proj = new Project();

        proj.name = projStart[i].Groups["name"].Value;

        int pos = projStart[i].Index;
        bool skipped = false;

        if (projComplete[c].Index < pos)
          skipped = true;

        if (i + 1 < projStart.Count && projComplete[c].Index > projStart[i + 1].Index)
          skipped = true;

        if (skipped)
        {
          proj.build = Solution.Compile.Skipped;
          proj.errors = 0;
          proj.warnings = 0;
        }
        else
        {
          proj.build = Solution.Compile.Success;
          proj.errors = Int32.Parse(projComplete[c].Groups["errors"].Value);
          proj.warnings = Int32.Parse(projComplete[c].Groups["warnings"].Value);
          if (proj.errors > 0)
            proj.build = Solution.Compile.Failed;
        }

        if (c + 1 < projComplete.Count)
          c++;

        _solution.AddProject(proj);
      }

      _solution.Projects.Sort();
    }
示例#2
0
    public void WriteSolution(Solution solution)
    {
      bool failed = false;
      if (solution.Failed > 0 || solution.TotalErrors > 0)
      {
        failed = true;
        report.WriteLine("<tr align=\"left\" class=\"error\">");
        report.WriteLine("  <td width=\"2%\">");
        report.WriteLine("    <img width=\"15\" height=\"15\" src=\"./images/icon_error_sml.gif\" alt=\"error\">");
      }
      else
      {
        report.WriteLine("<tr align=\"left\" class=\"success\">");
        report.WriteLine("  <td width=\"2%\">");
        report.WriteLine("    <img width=\"15\" height=\"15\" src=\"./images/icon_success_sml.gif\" alt=\"success\">");
      }
      report.WriteLine("   </td> ");
      report.WriteLine("  <td>&nbsp;{0}</td>", solution.Name);
      report.WriteLine("  <td>{0}</td>", solution.Succeeded.ToString());
      report.WriteLine("  <td>{0}</td>", solution.Failed.ToString());
      report.WriteLine("  <td>{0}</td>", solution.Skipped.ToString());
      report.WriteLine("  <td>{0}</td>", solution.TotalErrors.ToString());
      if (!failed && solution.TotalWarnings > 0)
        report.WriteLine("  <td class=\"warning\">");
      else
        report.WriteLine("  <td>");
      report.WriteLine("  {0}</td>", solution.TotalWarnings.ToString());
      report.WriteLine(" </tr>");
      report.WriteLine(" </table>");
      report.WriteLine("<hr>");
      report.WriteLine("<h2>");
      report.WriteLine("<a name=\"Projects\">Projects</a>");
      report.WriteLine("</h2>");
      report.WriteLine("<p>");
      report.WriteLine("[<a href=\"#Solution\">Solution</a>]");
      report.WriteLine("[<a href=\"#Projects\">Projects</a>]");
      report.WriteLine("[<a href=\"#Output\">Build Output</a>]");
      report.WriteLine("</p>");
      report.WriteLine("<table border=\"0\" rules=\"none\" width=\"100%\">");
      report.WriteLine("<tr align=\"left\" class=\"title\">");
      report.WriteLine("<th width=\"65%\" align=\"left\" colspan=\"2\">Name</th>");
      report.WriteLine("<th width=\"15%\" align=\"left\">Compile</th>");
      report.WriteLine("<th width=\"10%\" align=\"left\">Errors</th>");
      report.WriteLine("<th width=\"10%\" align=\"left\">Warnings</th>");
      report.WriteLine("</tr>");

      foreach (Project project in solution.Projects)
        WriteProject(project);
    }
    public void Parse(string input)
    {
      _solution = new Solution();

      Regex projectSearch = new Regex("\"(?<solution>[^\"]+)\" is building \"(?<project>[^\"]+)\"");
      Regex targetSearch = new Regex("Target (?<target>[^:]+):Rebuild:");

      List<string> lines = GetLines(input);

      FileInfo solutionFile = null;
      Project project = new Project();

      foreach (string line in lines)
      {
        switch (IndentDepth(line))
        {
          case 0: // header + footer
            if (line.IndexOf("Build") == 0 && (line.IndexOf("succeeded") > 0 || line.IndexOf("FAILED") > 0))
            {
              // save last project
              _solution.AddProject(project);
            }
            break;
          case 4: // project start
            if (line.IndexOf(":Rebuild:") > 0)
            {
              if (project.name != string.Empty)
              {
                // save last project
                _solution.AddProject(project);
                // create new project
                project = new Project();
              }

              Match lineMatch = targetSearch.Match(line);
              if (lineMatch.Success)
                project.name = lineMatch.Groups["target"].Value.Replace('_', '.');
            }
            break;
          case 8: // project info
            if (line.IndexOf(".sln") > 0)
            {
              Match lineMatch = projectSearch.Match(line);

              if (lineMatch.Success)
              {
                if (solutionFile == null)
                {
                  string solutionName = lineMatch.Groups["solution"].Value;
                  solutionFile = new FileInfo(solutionName);
                  _solution.Name = solutionFile.Name;
                }

                string projectName = lineMatch.Groups["project"].Value;

                FileInfo projectFile = new FileInfo(projectName);

                project.filename = Path.Combine(GetProjectDirectory(projectFile.Directory, solutionFile.Directory), projectFile.Name);
                project.build = Solution.Compile.Success;
              }
              break;
            }

            if (line.IndexOf("Done building project") > 0 && line.IndexOf("FAILED") > 0)
              project.build = Solution.Compile.Failed;

            break;
          case 12: // details
            if (line.IndexOf(": warning CS") > 0)
            {
              project.warnings++;
              break;
            }

            if (line.IndexOf(": error CS") > 0)
            {
              project.errors++;
              break;
            }
            break;
          default:
            break;
        }
      }
      _solution.Projects.Sort();
    }