static DiagnosticMessage() { GetFromCode = new List <DiagnosticMessage>(); GetFromCode.Add(null); // to start message codes at index 1 using (StreamReader tableReader = new StreamReader(GetStreamForProjectFile("Compiler/Diagnostics/Resources/DiagnosticMessages.csv"))) { // Skip column headers tableReader.ReadLine(); // One message per line string line = null; while ((line = tableReader.ReadLine()) != null) { string[] columns = line.Split(';'); // Category Category category = (Category)Int32.Parse(columns[0]); // Code int code = Int32.Parse(columns[1]); // Severity Severity severity = (Severity)Int32.Parse(columns[2]); // MessageTemplate string messageTemplate = columns[3]; // Document int documentId = Int32.Parse(columns[4]); ReferenceDocument referenceDocument = ReferenceDocument.GetFromCode[documentId]; // PageNumber int pageNumber = Int32.Parse(columns[5]); // ReferenceText string referenceText = columns[6]; GetFromCode.Add(new DiagnosticMessage(category, code, severity, messageTemplate, referenceDocument, pageNumber, referenceText)); } } }
private DiagnosticMessage(Category category, int code, Severity severity, string messageTemplate, ReferenceDocument document, int pageNumber, string referenceText) { Category = category; Code = code; Severity = severity; MessageTemplate = messageTemplate; Document = document; PageNumber = pageNumber; ReferenceText = referenceText; }