private static ErrorInfoAdapter GetErrorInfo(XmlNodeList messagesElements, int elIndex)
        {
            var messageNodes = messagesElements[elIndex].ChildNodes;
            var errorInfo    = new ErrorInfoAdapter();

            for (var j = 0; j < messageNodes.Count; j++)
            {
                SetErrorValue(messageNodes[j], errorInfo);
            }

            return(errorInfo);
        }
            private string GetOutput(ErrorInfoAdapter error)
            {
                var fileName = error.ErrorInfo.FileName;

                if (fileName.StartsWith(Utils.SourceTreeRootMarker))
                {
                    fileName = fileName.Replace(Utils.SourceTreeRootMarker, RenderInfo.SrcRoot);
                }

                return(error.ErrorInfo.Level >= 1 && error.ErrorInfo.Level <= 3
                    ? string.Format("{0} ({1}): error {2}: {3}{4}", fileName, error.ErrorInfo.LineNumber,
                                    error.ErrorInfo.ErrorCode, error.ErrorInfo.Message, Environment.NewLine)
                    : error.ErrorInfo.Message);
            }
Ejemplo n.º 3
0
        private static ErrorInfoAdapter GetErrorInfo(XmlNodeList messagesElements, int elIndex)
        {
            var messageNodes = messagesElements[elIndex].ChildNodes;
            var errorInfo    = new ErrorInfoAdapter();

            for (var j = 0; j < messageNodes.Count; j++)
            {
                var nodeName        = messageNodes[j].Name;
                var firstChildValue = messageNodes[j].HasChildNodes ? messageNodes[j].FirstChild.Value : string.Empty;
                SetErrorValue(nodeName, errorInfo, firstChildValue);
            }

            return(errorInfo);
        }
            private void WriteTableRow(TextWriter writer, ErrorInfoAdapter error)
            {
                var errorCode = HttpUtility.HtmlEncode(error.ErrorInfo.ErrorCode);
                var message   = HttpUtility.HtmlEncode(error.ErrorInfo.Message);

                writer.WriteLine("<tr>");
                writer.Write("<td style='width: 10%;'><a href='{0}'>{1}</a></td>",
                             String.Format(_revisionLink, SvnInfo.Instance.Revision), SvnInfo.Instance.Revision);
                writer.Write("<td style='width: 10%;'>{0}</td>", SvnInfo.Instance.Author);
                writer.Write("<td style='width: 25%;'>");
                var fileName = error.ErrorInfo.FileName;

                if (fileName.StartsWith(Utils.SourceTreeRootMarker))
                {
                    fileName = fileName.Replace(Utils.SourceTreeRootMarker, RenderInfo.SrcRoot);
                }

                string caseSensFileName = "";

                if (SvnInfo.Instance.CaseSensFileName.IndexOf("s:\\src\\") == 0)
                {
                    caseSensFileName = SvnInfo.Instance.CaseSensFileName.Substring("s:\\src\\".Length);
                    caseSensFileName = caseSensFileName.Replace('\\', '/');
                    caseSensFileName = String.Format(_repoLink, caseSensFileName, SvnInfo.Instance.Revision, error.ErrorInfo.LineNumber);
                }
                else if (SvnInfo.Instance.CaseSensFileName.IndexOf("f:\\ANT-Build\\ANT-Workspace\\libdsp\\") == 0)
                {
                    caseSensFileName = SvnInfo.Instance.CaseSensFileName.Substring("f:\\ANT-Build\\ANT-Workspace\\libdsp\\".Length);
                    caseSensFileName = caseSensFileName.Replace('\\', '/');
                    caseSensFileName = String.Format(_repoLink2, caseSensFileName, SvnInfo.Instance.Revision, error.ErrorInfo.LineNumber);
                }
                else if (SvnInfo.Instance.CaseSensFileName.IndexOf("f:\\ANT-Build\\ANT-Workspace\\AmberfinTrunkTests\\") == 0)
                {
                    caseSensFileName = SvnInfo.Instance.CaseSensFileName.Substring("f:\\ANT-Build\\ANT-Workspace\\AmberfinTrunkTests\\".Length);
                    caseSensFileName = caseSensFileName.Replace('\\', '/');
                    caseSensFileName = String.Format(_repoLink3, caseSensFileName, SvnInfo.Instance.Revision, error.ErrorInfo.LineNumber);
                }

                writer.WriteLine("<a href='{0}'>{1} ({2})</a>", caseSensFileName, Path.GetFileName(SvnInfo.Instance.CaseSensFileName),
                                 error.ErrorInfo.LineNumber.ToString(CultureInfo.InvariantCulture));

                writer.WriteLine("</td>");
                writer.WriteLine("<td style='width: 5%;'><a href='http://www.viva64.com/en/{0}'>{0}</a></td>", errorCode);
                writer.WriteLine("<td style='width: 60%;'>{0}</td>", message);
                writer.WriteLine("</tr>");
            }
        private static void SetErrorValue(XmlNode messageNode, ErrorInfoAdapter errorInfo)
        {
            XmlNodeList childNodes        = messageNode.ChildNodes;
            string      firstChildContent = childNodes.Count > 0 ? childNodes.Item(0).Value : string.Empty;

            switch (messageNode.Name)
            {
            case DataColumnNames.ErrorListAnalyzer:
                errorInfo.ErrorInfo.AnalyzerType = (AnalyzerType)Enum.Parse(typeof(AnalyzerType), firstChildContent);
                break;

            case DataColumnNames.ErrorListCodeCurrent:
                errorInfo.ErrorInfo.CodeCurrent = Convert.ToUInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListCodeNext:
                errorInfo.ErrorInfo.CodeNext = Convert.ToUInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListCodePrev:
                errorInfo.ErrorInfo.CodePrev = Convert.ToUInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListErrorCode:
                errorInfo.ErrorInfo.ErrorCode = firstChildContent;
                break;

            case DataColumnNames.ErrorListFalseAlarm:
                errorInfo.ErrorInfo.FalseAlarmMark = Convert.ToBoolean(firstChildContent);
                break;

            case DataColumnNames.ErrorListFile:
                errorInfo.ErrorInfo.FileName = firstChildContent;
                break;

            case DataColumnNames.ErrorListRetired:
                errorInfo.ErrorInfo.IsRetired = Convert.ToBoolean(firstChildContent);
                break;

            case DataColumnNames.ErrorListLevel:
                errorInfo.ErrorInfo.Level = Convert.ToUInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListLine:
                errorInfo.ErrorInfo.LineNumber = Convert.ToInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListPositions:
                // OuterXml is needed because the xml string for XmlTextReader must have only one root element
                var xmlReader = new XmlTextReader(new StringReader(messageNode.OuterXml));
                // Reading the root elemnet 'Positions'
                xmlReader.Read();
                ((IXmlSerializable)errorInfo.ErrorInfo.Positions).ReadXml(xmlReader);
                break;

            case DataColumnNames.ErrorListMessage:
                errorInfo.ErrorInfo.Message = firstChildContent;
                break;

            case DataColumnNames.ErrorListTrial:
                errorInfo.ErrorInfo.TrialMode = Convert.ToBoolean(firstChildContent);
                break;

            case DataColumnNames.ErrorListCwe:
                errorInfo.ErrorInfo.CweId = (firstChildContent.StartsWith(ErrorInfo.CWEPrefix) && firstChildContent.Length >= (ErrorInfo.CWEPrefix.Length + 1)) ?
                                            Convert.ToUInt32(firstChildContent.Substring(ErrorInfo.CWEPrefix.Length))
                                                : default(uint);
                break;

            case DataColumnNames.ErrorListMisra:
                errorInfo.ErrorInfo.MisraId = ErrorInfo.TryParseMisraId(firstChildContent);
                break;

            // Additional values
            case DataColumnNames.ErrorListFavIcon:
                errorInfo.FavIcon = Convert.ToBoolean(firstChildContent);
                break;

            case DataColumnNames.ErrorListOrder:
                errorInfo.DefaultOrder = Convert.ToInt32(firstChildContent);
                break;

            case DataColumnNames.ErrorListProject:
                errorInfo.Project = firstChildContent;
                errorInfo.ErrorInfo.ProjectNames = firstChildContent.Split(DataTableUtils.ProjectNameSeparator).ToList();
                break;

            case DataColumnNames.ErrorListShortFile:
                errorInfo.ShortFile = firstChildContent;
                break;

            case DataColumnNames.ErrorListAnalyzedSourceFiles:
                errorInfo.ErrorInfo.AnalyzedSourceFiles = firstChildContent.Split(DataTableUtils.AnalyzedSourceFileSeparator).ToList();
                break;
            }
        }
Ejemplo n.º 6
0
        private static void SetErrorValue(string nodeName, ErrorInfoAdapter errorInfo, string firstChildValue)
        {
            switch (nodeName)
            {
            case DataColumnNames.ErrorListAnalyzer:
                errorInfo.ErrorInfo.AnalyzerType = (AnalyzerType)Enum.Parse(typeof(AnalyzerType), firstChildValue);
                break;

            case DataColumnNames.ErrorListCodeCurrent:
                errorInfo.ErrorInfo.CodeCurrent = Convert.ToUInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListCodeNext:
                errorInfo.ErrorInfo.CodeNext = Convert.ToUInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListCodePrev:
                errorInfo.ErrorInfo.CodePrev = Convert.ToUInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListErrorCode:
                errorInfo.ErrorInfo.ErrorCode = firstChildValue;
                break;

            case DataColumnNames.ErrorListFalseAlarm:
                errorInfo.ErrorInfo.FalseAlarmMark = Convert.ToBoolean(firstChildValue);
                break;

            case DataColumnNames.ErrorListFile:
                errorInfo.ErrorInfo.FileName = firstChildValue;
                break;

            case DataColumnNames.ErrorListRetired:
                errorInfo.ErrorInfo.IsRetired = Convert.ToBoolean(firstChildValue);
                break;

            case DataColumnNames.ErrorListLevel:
                errorInfo.ErrorInfo.Level = Convert.ToUInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListLine:
                errorInfo.ErrorInfo.LineNumber = Convert.ToInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListLineExtension:
                errorInfo.ErrorInfo.LineNumberExtension = string.Empty;     // It's not necessary - just surrogate value
                break;

            case DataColumnNames.ErrorListMessage:
                errorInfo.ErrorInfo.Message = firstChildValue;
                break;

            case DataColumnNames.ErrorListTrial:
                errorInfo.ErrorInfo.TrialMode = Convert.ToBoolean(firstChildValue);
                break;

            // Additional values
            case DataColumnNames.ErrorListFavIcon:
                errorInfo.FavIcon = Convert.ToBoolean(firstChildValue);
                break;

            case DataColumnNames.ErrorListOrder:
                errorInfo.DefaultOrder = Convert.ToInt32(firstChildValue);
                break;

            case DataColumnNames.ErrorListProject:
                errorInfo.Project = firstChildValue;
                break;

            case DataColumnNames.ErrorListShortFile:
                errorInfo.ShortFile = firstChildValue;
                break;
            }
        }