private static void WriteOutConsoleMode(IBSharpContext ctx) { var result = new XElement("result"); foreach (var cls in ctx.Get(BSharpContextDataType.Working)) { var clsElement = new XElement("cls"); clsElement.SetAttr("code", cls.FullName); clsElement.SetAttr("name", cls.Name); clsElement.SetAttr("ns", cls.Namespace); clsElement.SetAttr("prototype", cls.Prototype); clsElement.Add(cls.Compiled); result.Add(clsElement); } foreach (var error in ctx.GetErrors()) { var errorElement = new XElement("error", new XAttribute("type", error.Type)) { Value = error.ToLogString() }; if (null != error.LexInfo) { var lex = new XElement("lexinfo", new XAttribute("file", error.LexInfo.File), new XAttribute("line", error.LexInfo.Line)); errorElement.Add(lex); } result.Add(errorElement); } Console.WriteLine(result.ToString()); }
/// <summary> /// Формирует простой для чтений реестр ошибок /// </summary> /// <param name="context"></param> public override void Execute(IBSharpContext context){ var sb = new StringBuilder(); sb.AppendLine("<html>"); sb.AppendLine("\t<head>"); sb.AppendLine("\t\t<title>Ошибки по проекту " + Project.ProjectName + "</title>"); sb.AppendLine("\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); sb.AppendLine("\t<style type='text/css'>"); sb.AppendLine( "\t\ttable {border-collapse:collapse;} td, th { padding : 5px; border:solid 1px gray; } th {background-color:black;color:white;} "); sb.AppendLine("\t\t.level-error {background-color : #ffdddd;} "); sb.AppendLine("\t</style>"); sb.AppendLine("\t</head>"); sb.AppendLine("\t<body>"); sb.AppendLine("\t\t<h1>Ошибки по проекту " + Project.ProjectName + "</h1>"); sb.AppendLine("\t\t<table>"); sb.AppendLine("\t\t\t<tr>"); sb.AppendLine("\t\t\t\t<th>Номер</th><th>Уровень</th><th>Тип</th><th>Класс</th><th>Сообщение</th><th>Файл</th><th>Строка</th><th>Колонка</th><th>Фаза</th>"); sb.AppendLine("\t\t\t</tr>"); var id = 1; foreach (var d in context.GetErrors(ErrorLevel.Warning).Select(_ => _.GetDigest()).OrderByDescending(_ => _.ErrorLevel).ThenBy(_=>_.ClassName).ThenBy(_=>_.FileName)){ sb.AppendLine("\t\t\t<tr class='level-"+d.ErrorLevel+"'>"); sb.AppendFormat("\t\t\t\t<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td>\r\n", id++,d.ErrorLevel,d.Type,d.ClassName,d.Message.Replace("\r\n","<br/>"),d.FileName,d.Line,d.Column,d.Phase ); sb.AppendLine("\t\t\t</tr>"); } sb.AppendLine("\t\t</table>"); sb.AppendLine("\t</body>"); sb.AppendLine("</html>"); var filename = Path.Combine(Project.GetOutputDirectory(), Project.ProjectName + ".formatted.errors.html"); Directory.CreateDirectory(Path.GetDirectoryName(filename)); File.WriteAllText(filename,sb.ToString()); }
private void HandleErrorStream(IBSharpContext context) { var errors = context.GetErrors(); foreach (var c in context.Get(BSharpContextDataType.Working)) { var witherrors = errors.Any(_ => _.Class == c || _.AltClass == c || _.ClassName == c.FullName); if (witherrors) { Project.Log.Warn("class " + c.FullName + " compiled with some errors"); } else { Project.Log.Debug("class " + c.FullName + " compiled"); } } }
/// <summary> /// </summary> /// <param name="context"></param> public override void Execute(IBSharpContext context) { var errors = context.GetErrors().ToArray(); if (errors.Length == 0) { return; } PrepareWorkEnv(); var xmlstring = GetSerializedErrors(errors); var xml = XElement.Parse(xmlstring); RollWriting(GetWritePath(), xml.ToString()); RollWriting(GetWritePath()+".html",ConvertToErrorHtml(xml)); }
/// <summary> /// </summary> /// <param name="context"></param> public override void Execute(IBSharpContext context) { var errors = context.GetErrors().ToArray(); if (errors.Length == 0) { return; } PrepareWorkEnv(); var xmlstring = GetSerializedErrors(errors); var xml = XElement.Parse(xmlstring); RollWriting(GetWritePath(), xml.ToString()); RollWriting(GetWritePath() + ".html", ConvertToErrorHtml(xml)); }
/// <summary> /// Формирует простой для чтений реестр ошибок /// </summary> /// <param name="context"></param> public override void Execute(IBSharpContext context) { var errors = context.GetErrors(ErrorLevel.Warning).ToArray(); if (errors.Length == 0) { return; } var sb = new StringBuilder(); sb.AppendLine("<html>"); sb.AppendLine("\t<head>"); sb.AppendLine("\t\t<title>Ошибки по проекту " + Project.ProjectName + "</title>"); sb.AppendLine("\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); sb.AppendLine("\t<style type='text/css'>"); sb.AppendLine( "\t\ttable {border-collapse:collapse;} td, th { padding : 5px; border:solid 1px gray; } th {background-color:black;color:white;} "); sb.AppendLine("\t\t.level-error {background-color : #ffdddd;} "); sb.AppendLine("\t</style>"); sb.AppendLine("\t</head>"); sb.AppendLine("\t<body>"); sb.AppendLine("\t\t<h1>Ошибки по проекту " + Project.ProjectName + "</h1>"); sb.AppendLine("\t\t<table>"); sb.AppendLine("\t\t\t<tr>"); sb.AppendLine("\t\t\t\t<th>Номер</th><th>Уровень</th><th>Тип</th><th>Класс</th><th>Сообщение</th><th>Файл</th><th>Строка</th><th>Колонка</th><th>Фаза</th>"); sb.AppendLine("\t\t\t</tr>"); var id = 1; foreach (var d in errors.Select(_ => _.GetDigest()).OrderByDescending(_ => _.LogLevel).ThenBy(_ => _.ClassName).ThenBy(_ => _.FileName)) { sb.AppendLine("\t\t\t<tr class='level-" + d.LogLevel + "'>"); sb.AppendFormat("\t\t\t\t<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td>\r\n", id++, d.LogLevel, d.Type, d.ClassName, d.Message.Replace("\r\n", "<br/>"), d.FileName, d.Line, d.Column, d.Phase ); sb.AppendLine("\t\t\t</tr>"); } sb.AppendLine("\t\t</table>"); sb.AppendLine("\t</body>"); sb.AppendLine("</html>"); var filename = Path.Combine(Project.GetOutputDirectory(), Project.ProjectName + ".formatted.errors.html"); Directory.CreateDirectory(Path.GetDirectoryName(filename)); File.WriteAllText(filename, sb.ToString()); }
private static void WriteOutErrors(IBSharpContext resultContext, IUserLog log) { foreach (var e in resultContext.GetErrors()) { var el = LogLevel.Error; if (e.Level == ErrorLevel.Warning) { el = LogLevel.Warn; } else if (e.Level == ErrorLevel.Fatal) { el = LogLevel.Fatal; } else if (e.Level == ErrorLevel.Hint) { el = LogLevel.Info; } var m = e.ToLogString(); log.Write(el, m, e, e); } Thread.Sleep(200); }
private static void WriteOutErrors(IBSharpContext resultContext, IUserLog log) { foreach (var e in resultContext.GetErrors()) { var el = LogLevel.Error; if (e.Level == ErrorLevel.Warning) { el = LogLevel.Warning; } else if (e.Level == ErrorLevel.Fatal) { el = LogLevel.Fatal; } else if (e.Level == ErrorLevel.Hint) { el = LogLevel.Info; } var m = e.ToLogString(); log.Write(el, m, e, e); } Thread.Sleep(200); }