Parse() public static method

Parses a "problem" node from an Android Studio log and consumes that node.
Thrown when the Android Studio file is incorrect.
public static Parse ( XmlReader reader, AndroidStudioStrings strings ) : AndroidStudioProblem
reader System.Xml.XmlReader The reader from which the problem shall be parsed.
strings AndroidStudioStrings NameTable strings used to parse Android Studio files.
return AndroidStudioProblem
        /// <summary>Processes an Android Studio log and writes issues therein to an instance of
        /// <see cref="IResultLogWriter"/>.</summary>
        /// <param name="xmlReader">The XML reader from which AndroidStudio format shall be read.</param>
        /// <returns>
        /// A list of the <see cref="Result"/> objects translated from the AndroidStudio format.
        /// </returns>
        private IList <Result> ProcessAndroidStudioLog(XmlReader xmlReader)
        {
            // The SARIF spec actually allows for non-unique results to be persisted to the
            // results array. We currently enforce uniqueness in the Android converter. We could
            // consider loosening this moving forward. The current behavior is primarily
            // intended to minimize test breaks while SARIF v2 is finalized.
            var results = new HashSet <Result>(Result.ValueComparer);

            int problemsDepth = xmlReader.Depth;

            xmlReader.ReadStartElement(_strings.Problems);

            while (xmlReader.Depth > problemsDepth)
            {
                var problem = AndroidStudioProblem.Parse(xmlReader, _strings);
                if (problem != null)
                {
                    results.Add(ConvertProblemToSarifResult(problem));
                }
            }

            xmlReader.ReadEndElement(); // </problems>

            return(new List <Result>(results));
        }
        /// <summary>Processes an Android Studio log and writes issues therein to an instance of
        /// <see cref="IResultLogWriter"/>.</summary>
        /// <param name="xmlReader">The XML reader from which AndroidStudio format shall be read.</param>
        /// <param name="output">The <see cref="IResultLogWriter"/> to write the output to.</param>
        private void ProcessAndroidStudioLog(XmlReader xmlReader, IResultLogWriter output)
        {
            int problemsDepth = xmlReader.Depth;

            xmlReader.ReadStartElement(_strings.Problems);

            while (xmlReader.Depth > problemsDepth)
            {
                var problem = AndroidStudioProblem.Parse(xmlReader, _strings);
                if (problem != null)
                {
                    output.WriteResult(AndroidStudioConverter.ConvertProblemToSarifIssue(problem));
                }
            }

            xmlReader.ReadEndElement(); // </problems>
        }
        /// <summary>Processes an Android Studio log and writes issues therein to an instance of
        /// <see cref="IResultLogWriter"/>.</summary>
        /// <param name="xmlReader">The XML reader from which AndroidStudio format shall be read.</param>
        /// <returns>
        /// A list of the <see cref="Result"/> objects translated from the AndroidStudio format.
        /// </returns>
        private ISet <Result> ProcessAndroidStudioLog(XmlReader xmlReader)
        {
            var results = new HashSet <Result>(Result.ValueComparer);

            int problemsDepth = xmlReader.Depth;

            xmlReader.ReadStartElement(_strings.Problems);

            while (xmlReader.Depth > problemsDepth)
            {
                var problem = AndroidStudioProblem.Parse(xmlReader, _strings);
                if (problem != null)
                {
                    results.Add(ConvertProblemToSarifResult(problem));
                }
            }

            xmlReader.ReadEndElement(); // </problems>

            return(results);
        }
Esempio n. 4
0
 private static AndroidStudioProblem Parse(XmlReader reader)
 {
     return(AndroidStudioProblem.Parse(reader, new AndroidStudioStrings(reader.NameTable)));
 }