private bool IsLastTokenSkippable() { int acceptTokenIndex = m_scannerInfo.GetTokenIndex(m_lastState); if (acceptTokenIndex < 0 && RecoverErrors) { //eat one char to continue m_lexemeValueBuilder.Append((char)m_source.ReadChar()); if (ErrorList != null) { ErrorList.AddError(LexicalErrorId, new SourceSpan(m_lastTokenStart, m_source.Location), m_lexemeValueBuilder.ToString()); } return(true); } return(acceptTokenIndex >= 0 && m_tokenAttributes[acceptTokenIndex] == c_skip); }
public static bool Validate(XmlOrder model) { IsValid = true; if (model.Options == null || model.Options.Count() == 0 || model.Options.Count() < 2) { ErrorList.AddError("Should be at least 2 options to order"); } else { if (model.Options.Any(x => x.Text == null || x.Text == "")) { ErrorList.AddError("Some Options are not initialized"); } } return(IsValid); }
private static bool FunctionTypeConformToPropertyType(IFunctionType derivedType, IPropertyType baseType, IErrorList errorList, ISource sourceLocation) { bool Result = true; Debug.Assert(derivedType.ResolvedBaseType.IsAssigned); Debug.Assert(baseType.ResolvedBaseType.IsAssigned); Result &= TypeConformToBase(derivedType.ResolvedBaseType.Item, baseType.ResolvedBaseType.Item, errorList, sourceLocation, isConversionAllowed: false); if (baseType.PropertyKind != BaseNode.UtilityType.ReadOnly) { errorList.AddError(new ErrorTypeKindConformance(sourceLocation, derivedType, baseType)); Result = false; } IErrorList AllOverloadErrorList = new ErrorList(); bool MatchingDerivedOverload = false; foreach (IQueryOverloadType DerivedOverload in derivedType.OverloadList) { IErrorList OverloadErrorList = new ErrorList(); if (!QueryOverloadHasPropertyConformingBase(DerivedOverload, baseType, OverloadErrorList, sourceLocation)) { Debug.Assert(!OverloadErrorList.IsEmpty); AllOverloadErrorList.AddError(OverloadErrorList.At(0)); } else { MatchingDerivedOverload = true; } } if (!MatchingDerivedOverload) { errorList.AddErrors(AllOverloadErrorList); errorList.AddError(new ErrorTypeKindConformance(sourceLocation, derivedType, baseType)); Result = false; } return(Result); }
private bool TryGetIdentifier(ProjectItem projectItem, string sourcePath, string identifier, object context, out object value) { value = null; if (identifier == null) { return(false); } var type = context.GetType(); try { var property = type.GetProperty(identifier); if (property != null) { value = property.GetValue(context); return(true); } var extension = extensions.Select(e => e.GetMethod(identifier, new[] { type })).FirstOrDefault(m => m != null); if (extension != null) { value = extension.Invoke(null, new[] { context }); return(true); } } catch (Exception e) { hasError = true; var message = $"Error rendering template. Cannot get identifier '{identifier}'. {e.Message} Source path: {sourcePath}"; Log.Error(message); ErrorList.AddError(projectItem, message); ErrorList.Show(); } return(false); }
private static bool ProcedureTypeConformToProcedureType(IProcedureType derivedType, IProcedureType baseType, IErrorList errorList, ISource sourceLocation) { bool Result = true; Debug.Assert(derivedType.ResolvedBaseType.IsAssigned); Debug.Assert(baseType.ResolvedBaseType.IsAssigned); Result &= TypeConformToBase(derivedType.ResolvedBaseType.Item, baseType.ResolvedBaseType.Item, errorList, sourceLocation, isConversionAllowed: false); IErrorList AllOverloadErrorList = new ErrorList(); foreach (ICommandOverloadType BaseOverload in baseType.OverloadList) { bool MatchingDerivedOverload = false; foreach (ICommandOverloadType DerivedOverload in derivedType.OverloadList) { IErrorList OverloadErrorList = new ErrorList(); if (!CommandOverloadConformToBase(DerivedOverload, BaseOverload, OverloadErrorList, DerivedOverload)) { Debug.Assert(!OverloadErrorList.IsEmpty); AllOverloadErrorList.AddError(OverloadErrorList.At(0)); } else { MatchingDerivedOverload = true; } } if (!MatchingDerivedOverload) { errorList.AddErrors(AllOverloadErrorList); errorList.AddError(new ErrorOverloadMismatchConformance(sourceLocation, derivedType, baseType)); Result = false; } } return(Result); }
public Symbol Analex() { if (ch == '\0') { EndOfFile = true; return(new Symbol("", Token.TokenEOF, linePointer + 1)); } Token lexToken = Token.TokenInvalid; Dictionary <string, string> result = new Dictionary <string, string>(); // Ignorar espaços em branco while (isWhiteSpace(ch)) { ch = getChar(); } // Verificar tokens de um caractere result = verifySingleCharacterToken(); Enum.TryParse(result[KEY_TOKEN], out lexToken); if (result[KEY_TOKEN] != Token.TokenInvalid.ToString()) { return(new Symbol(result[KEY_LEXEME], lexToken, linePointer + 1)); } // Verificar tokens de dois ou três caracteres result = verifyCharacterToken(); Enum.TryParse(result[KEY_TOKEN], out lexToken); if (result[KEY_TOKEN] != Token.TokenInvalid.ToString()) { return(new Symbol(result[KEY_LEXEME], lexToken, linePointer + 1)); } // Verificar token identificador ou keyword if (isLetter(ch) || ch == '$' || ch == '_') { string identifier = string.Empty; while (isLetter(ch) || ch == '$' || ch == '_' || isDigit(ch)) { identifier += ch; ch = getChar(); } result[KEY_LEXEME] = identifier; if (isKeyword(identifier)) { foreach (Token token in Enum.GetValues <Token>()) { if (!token.ToString().StartsWith("TokenKeyword")) { continue; } string stringToken = token.ToString().Substring(12).ToLower(); if (stringToken.Equals(identifier)) { lexToken = token; break; } } } else { lexToken = Token.TokenID; } } // Verificar token inteiro ou hexadecimal if (isDigit(ch)) { string value = string.Empty; bool isFloatingPoint = true; while (isDigit(ch) || (ch == '.' && isFloatingPoint)) { if (ch == '.') { isFloatingPoint = false; } value += ch; ch = getChar(); } // Se o último character do value não for um dígito, é um erro if (value.EndsWith('.')) { ErrorList.AddError( new InvalidFloatingPointException( linePointer, buffer[linePointer])); } result[KEY_LEXEME] = value; lexToken = value.Contains(".") ? Token.TokenFloatingPoint : Token.TokenInteger; } if (lexToken == Token.TokenInvalid) { ch = getChar(); } return(new Symbol(result[KEY_LEXEME], lexToken, linePointer + 1)); }
/// <summary> /// Verfica o caractere se é um token de dois ou três caracteres. Se for de um character, /// chamar outra função /// </summary> /// <returns>Retorna o <c>Token</c> para o caractere lido. Retorna <c>Token.Invalid</c> se não for /// caractere válido neste contexto /// </returns> private Dictionary <string, string> verifyCharacterToken() { Token lexToken = Token.TokenInvalid; string lexeme = string.Empty; switch (ch) { // Analisar <= , <, <<= ou << case '<': lexeme += ch.ToString(); ch = getChar(); if (ch == '<') { // Possível << ou <<= lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexToken = Token.TokenCA_LShift; lexeme += ch.ToString(); ch = getChar(); } else { lexToken = Token.TokenLeftShift; } } else if (ch == '=') { lexToken = Token.TokenLessEqual; lexeme += ch.ToString(); ch = getChar(); } // Exato < else { lexToken = Token.TokenLess; } break; // Analisar >=, >, >>= ou >> case '>': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexToken = Token.TokenGreaterEqual; lexeme += ch.ToString(); ch = getChar(); } else if (ch == '>') { lexeme += ch.ToString(); ch = getChar(); // Possível >>= ou >> if (ch == '=') { lexeme += ch.ToString(); lexToken = Token.TokenCA_RShift; ch = getChar(); } else { lexToken = Token.TokenRightShift; } } else { lexToken = Token.TokenGreater; } break; // Analisar = ou == case '=': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexeme += ch.ToString(); lexToken = Token.TokenEqual; ch = getChar(); } else { lexToken = Token.TokenAssignment; } break; // Analisar != ou == case '!': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexeme += ch.ToString(); lexToken = Token.TokenNotEqual; ch = getChar(); } else { lexToken = Token.TokenNot; } break; // Analisar ||, |= ou | case '|': lexeme += ch.ToString(); ch = getChar(); if (ch == '|') { lexeme += ch.ToString(); lexToken = Token.TokenOr; ch = getChar(); } else if (ch == '=') { lexeme += ch.ToString(); lexToken = Token.TokenCA_OR; ch = getChar(); } else { lexToken = Token.TokenBitwiseOR; } break; // Analisar &&, & ou &= case '&': lexeme += ch.ToString(); ch = getChar(); if (ch == '&') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenAnd; } else if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCA_AND; } else { lexToken = Token.TokenBitwiseAnd; } break; // Analisar +, ++, += case '+': lexeme += ch.ToString(); ch = getChar(); if (ch == '+') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenIncrement; } else if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCAAdition; } else { lexToken = Token.TokenAdition; } break; // Analisar -, --, -= case '-': lexeme += ch.ToString(); ch = getChar(); if (ch == '-') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenDecrement; } else if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCASubtraction; } else { lexToken = Token.TokenSubtraction; } break; // Analisar / , /= , // ou /* case '/': lexeme += ch.ToString(); ch = getChar(); // Start of the comment if (ch == '/') { bool inComment = true; // Usado para verificar se mudou de linha int commentLineStart = linePointer; ch = getChar(); while (inComment) { if (ch == '\0' || commentLineStart < linePointer) { inComment = false; lexToken = Token.TokenComment; } else { ch = getChar(); } } } else if (ch == '=') { ch = getChar(); lexToken = Token.TokenCADivision; } // Start of the comment else if (ch == '*') { bool inComment = true; int commentLineStart = linePointer; ch = getChar(); while (inComment) { if (ch == '\0') { inComment = false; ErrorList.AddError(new CommentaryEndOfFileException(commentLineStart)); } else if (ch == '*') { ch = getChar(); if (ch == '/') { ch = getChar(); inComment = false; lexToken = Token.TokenComment; } } else { ch = getChar(); } } } else { lexToken = Token.TokenDivision; } break; // Analisar * , *= case '*': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCAMultiplication; } else { lexToken = Token.TokenMultiplication; } break; // Analisar %, %= case '%': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCAModulus; } else { lexToken = Token.TokenModulus; } break; // Analisar ^, ^= case '^': lexeme += ch.ToString(); ch = getChar(); if (ch == '=') { lexeme += ch.ToString(); ch = getChar(); lexToken = Token.TokenCA_NOT; } else { lexToken = Token.TokenBitwiseNot; } break; // Analisar string com aspas case '"': int lineDiference = linePointer; string stringLiteral = ch.ToString(); ch = getChar(); while (ch != '"') { stringLiteral += ch; ch = getChar(); // Se mudou de linha, então a string não terminou if (linePointer > lineDiference) { ErrorList.AddError(new InvalidStringLiteralException(linePointer, buffer[linePointer - 1])); break; } lexToken = Token.TokenString; } stringLiteral += ch.ToString(); lexeme = stringLiteral; ch = getChar(); break; // Analisar string com virgulas altas case '\'': lineDiference = linePointer; stringLiteral = ch.ToString(); ch = getChar(); while (ch != '\'') { stringLiteral += ch; ch = getChar(); // Se mudou de linha, então a string não terminou if (linePointer > lineDiference) { ErrorList.AddError(new InvalidStringLiteralException(linePointer, buffer[linePointer - 1])); break; } lexToken = Token.TokenString; } stringLiteral += ch.ToString(); lexeme = stringLiteral; ch = getChar(); break; } return(new Dictionary <string, string>() { { KEY_LEXEME, lexeme }, { KEY_TOKEN, Enum.GetName(lexToken) } }); }
private void error(String message) { var error = new Exception(message + ": Linha " + currentSymbol.LineOfCode); ErrorList.AddError(error); }
private void ReadData(string input) { if (input.StartsWith("ID:")) { ID = GetValue(input, "ID:"); } if (input.StartsWith("Line:")) { Line = GetValue(input, "Line:"); } if (input.StartsWith("Notes:")) { Notes = GetValue(input, "Notes:"); } if (input.StartsWith("Source:")) { Source = GetValue(input, "Source:"); } if (input.StartsWith("Module:")) { Module = GetValue(input, "Module:"); } if (input.StartsWith("Statement:")) { Statement = GetValue(input, "Statement:"); } if (input.StartsWith("More Information:")) { MoreInformation = GetValue(input, "More Information:"); } if (input.StartsWith("---")) { //finished if (ID != "") { try { int iLine = 0; try { iLine = Int32.Parse(Line); } catch (Exception) { } if (Source != "") { list.AddError(currentProject, Source, Notes + " " + Statement + ", see:" + MoreInformation, TaskErrorCategory.Error, iLine, 0); } else { list.AddError(currentProject, Module, Notes + " " + Statement + ", see:" + MoreInformation, TaskErrorCategory.Error, iLine, 0); } } catch (Exception) { } } ID = ""; Line = "0"; Source = ""; Notes = ""; Statement = ""; Module = ""; } }
protected void error(string message) { var exception = new Exception($"{message} na {symbol.LineOfCode}"); ErrorList.AddError(exception); }
public ErrorList SetUpT(int idp) { if (SalarySheet == null) { throw new Exception("Bad init."); } var table_sar = MyData.DataSetKlons.SALARY_SHEETS; var table_sar_r = MyData.DataSetKlons.SALARY_SHEETS_R; var table_persons = MyData.DataSetKlons.PERSONS; var error_list = new ErrorList(); string error_source; int yr = SalarySheet.YR; int mt = SalarySheet.MT; var dt1 = SalarySheet.MDT1; var dt2 = SalarySheet.MDT2; var dr_person = table_persons.FindByID(idp); if (dr_person == null) { error_list.AddError("Algas lapa", "Nav darbinieka"); return(error_list); } error_source = string.Format("Darbinieks :{0} {1})", dr_person.FNAME, dr_person.LNAME); var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r, dt2, d => d.EDIT_DATE); if (DR_Person_r == null) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } PersonR.DateFirst = dt1; PersonR.DateLast = dt2; var drs_person_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); //var rete = PersonR.ReadDateListFilter(drs_person_r, d => d.EDIT_DATE); var rete = PersonR.ReadDateListAll(drs_person_r, d => d.EDIT_DATE); if (rete != PeriodInfo.ERetReadStartEndList.OK || PersonR.LinkedPeriods[0].DateFirst > dt2) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } if (Events == null) { if (!GetEventList(error_list, idp)) { return(error_list); } } if (Row != null) { TotalPositionPay = new SalaryInfo(); TotalPositionPay.SetFromRow(Row); } return(error_list); }
public ErrorList SetUp(int idp, int idam) { if (SalarySheet == null) { throw new Exception("Bad init."); } var table_sar = MyData.DataSetKlons.SALARY_SHEETS; var table_sar_r = MyData.DataSetKlons.SALARY_SHEETS_R; var table_darba_laiks = MyData.DataSetKlons.TIMESHEET; var table_sh = MyData.DataSetKlons.SALARY_SHEET_TEMPL; var table_sh_r = MyData.DataSetKlons.SALARY_SHEET_TEMPL_R; var table_persons = MyData.DataSetKlons.PERSONS; var table_amati = MyData.DataSetKlons.POSITIONS; var table_dl_sar_r = MyData.DataSetKlons.TIMESHEET_LISTS_R; var error_list = new ErrorList(); string error_source; int yr = SalarySheet.YR; int mt = SalarySheet.MT; var dt1 = SalarySheet.MDT1; var dt2 = SalarySheet.MDT2; //var dv_dl_sar_r = new DataView(table_dl_sar_r); //dv_dl_sar_r.RowFilter = string.Format("Parent(FK_TIMESHEET_LISTS_R_IDS).YR = {0} AND Parent(FK_TIMESHEET_LISTS_R_IDS).MT = {1}", yr, mt); var dr_person = table_persons.FindByID(idp); var dr_amats = table_amati.FindByID(idam); if (dr_person == null) { error_list.AddError("Algas lapa", "Nav darbinieka"); return(error_list); } if (dr_amats == null) { error_list.AddError("Algas lapa", "Nav amata"); return(error_list); } if (DR_salary_sheet_r_templ == null) { error_source = string.Format("Darbinieks :{0} {1} ({2})", dr_person.FNAME, dr_person.LNAME, dr_amats.TITLE); } else { error_source = string.Format("Lapa:{0} rinda:{1}", DR_salary_sheet_r_templ.SALARY_SHEET_TEMPLRow.SNR, DR_salary_sheet_r_templ.SNR); } var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r, dt2, d => d.EDIT_DATE); if (DR_Person_r == null) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } PersonR.DateFirst = dt1; PersonR.DateLast = dt2; var drs_person_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); //var rete = PersonR.ReadDateListFilter(drs_person_r, d => d.EDIT_DATE); var rete = PersonR.ReadDateListAll(drs_person_r, d => d.EDIT_DATE); if (rete != PeriodInfo.ERetReadStartEndList.OK || PersonR.LinkedPeriods[0].DateFirst > dt2) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } PositionsR.DateFirst = dt1; PositionsR.DateLast = dt2; var drs_amats_r = dr_amats.GetPOSITIONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); rete = PositionsR.ReadDateListFilter(drs_amats_r, d => d.EDIT_DATE); if (rete != PeriodInfo.ERetReadStartEndList.OK) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti amata dati."); return(error_list); } var drs_dl_sar_r = dr_person.GetTIMESHEET_LISTS_RRows() .WhereX( d => d.TIMESHEET_LISTSRow.YR == yr && d.TIMESHEET_LISTSRow.MT == mt && d.IDAM == dr_amats.ID) .ToArray(); if (drs_dl_sar_r.Length == 0) { error_list.AddError(error_source, "Norādītajam periodam nav darba laika uzskaites datu."); return(error_list); } if (drs_dl_sar_r.Length > 1) { error_list.AddError(error_source, "Darba laika uzskaites datu rindu skaits > 1."); return(error_list); } var dr_dl_sar_r = drs_dl_sar_r[0]; var dlrowset = dr_dl_sar_r.GetDLRowSet(); DLRows = dlrowset; SetDLRows(dlrowset); if (DLRows == null || DLRows.Plan == null || DLRows.Fact == null || (dr_dl_sar_r.NIGHT == 1 && (DLRows.PlanNight == null || DLRows.FactNight == null)) || (dr_dl_sar_r.OVERTIME == 1 && DLRows.FactOvertime == null)) { error_list.AddError(error_source, "Nekorekti darba laika uzskaites dati."); return(error_list); } if (Events == null) { if (!GetEventList(error_list, idp)) { return(error_list); } } if (IsRateTypeChangedDuringVacation(drs_amats_r)) { error_list.AddError(error_source, "Atvaļinājuma laikā nevar mainīt algas likmes veidu."); } var err1 = CheckVacationTimePlan(idam); if (err1 != "OK") { error_list.AddError(error_source, err1); return(error_list); } if (Row != null) { TotalPositionPay = new SalaryInfo(); TotalPositionPay.SetFromRow(Row); } return(error_list); }
private bool ParseDollar(ProjectItem projectItem, string sourcePath, Stream stream, object context, ref string output) { if (stream.Current == '$') { var identifier = stream.PeekWord(1); object value; if (TryGetIdentifier(projectItem, sourcePath, identifier, context, out value)) { stream.Advance(identifier.Length); var collection = value as IEnumerable <Item>; if (collection != null) { var filter = ParseBlock(stream, '(', ')'); var block = ParseBlock(stream, '[', ']'); var separator = ParseBlock(stream, '[', ']'); if (filter == null && block == null && separator == null) { var stringValue = value.ToString(); if (stringValue != value.GetType().FullName) { output += stringValue; } else { output += "$" + identifier; } } else { IEnumerable <Item> items; if (filter != null && filter.StartsWith("$")) { var predicate = filter.Remove(0, 1); if (extensions != null) { // Lambda filters are always defined in the first extension type var c = extensions.FirstOrDefault()?.GetMethod(predicate); if (c != null) { try { items = collection.Where(x => (bool)c.Invoke(null, new object[] { x })).ToList(); matchFound = matchFound || items.Any(); } catch (Exception e) { items = new Item[0]; hasError = true; var message = $"Error rendering template. Cannot apply filter to identifier '{identifier}'. {e.Message} Source path: {sourcePath}"; Log.Error(message); ErrorList.AddError(projectItem, message); ErrorList.Show(); } } else { items = new Item[0]; } } else { items = new Item[0]; } } else { items = ItemFilter.Apply(collection, filter, ref matchFound); } output += string.Join(ParseTemplate(projectItem, sourcePath, separator, context), items.Select(item => ParseTemplate(projectItem, sourcePath, block, item))); } } else if (value is bool) { var trueBlock = ParseBlock(stream, '[', ']'); var falseBlock = ParseBlock(stream, '[', ']'); output += ParseTemplate(projectItem, sourcePath, (bool)value ? trueBlock : falseBlock, context); } else { var block = ParseBlock(stream, '[', ']'); if (value != null) { if (block != null) { output += ParseTemplate(projectItem, sourcePath, block, value); } else { output += value.ToString(); } } } return(true); } } return(false); }
public static Type Compile(ProjectItem projectItem, ShadowClass shadowClass) { if (Directory.Exists(Constants.TempDirectory) == false) { Directory.CreateDirectory(Constants.TempDirectory); } foreach (Assembly assembly in shadowClass.ReferencedAssemblies) { if (assembly.GlobalAssemblyCache) { continue; } var asmSourcePath = assembly.Location; var asmDestPath = Path.Combine(Constants.TempDirectory, Path.GetFileName(asmSourcePath)); try { //File may be in use File.Copy(asmSourcePath, asmDestPath, true); } catch (Exception e) { Log.Warn(e.ToString()); } } var filname = Path.GetRandomFileName(); var path = Path.Combine(Constants.TempDirectory, filname); var result = shadowClass.Compile(path); ErrorList.Clear(); var errors = result.Diagnostics.Where(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error || diagnostic.Severity == DiagnosticSeverity.Warning); var hasErrors = false; foreach (var error in errors) { var message = error.GetMessage(); message = message.Replace("__Typewriter.", string.Empty); //message = message.Replace("__Code.", string.Empty); message = message.Replace("publicstatic", string.Empty); Log.Warn("Template error: {0} {1}", error.Id, message); if (error.Severity == DiagnosticSeverity.Error || error.IsWarningAsError) { ErrorList.AddError(projectItem, message); hasErrors = true; } else { ErrorList.AddWarning(projectItem, message); } } if (hasErrors) { ErrorList.Show(); } if (result.Success) { var assembly = Assembly.LoadFrom(path); var type = assembly.GetType("__Typewriter.Template"); return(type); } throw new Exception("Failed to compile template."); }