Beispiel #1
0
 public static TripleSlashCommentModel CreateModel(string xml, ITripleSlashCommentParserContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (string.IsNullOrEmpty(xml))
     {
         return(null);
     }
     // Quick turnaround for badly formed XML comment
     if (xml.StartsWith("<!-- Badly formed XML comment ignored for member "))
     {
         Logger.LogWarning($"Invalid triple slash comment is ignored: {xml}");
         return(null);
     }
     try
     {
         var model = new TripleSlashCommentModel(xml, context);
         return(model);
     }
     catch (XmlException)
     {
         return(null);
     }
 }
        public static TripleSlashCommentModel CreateModel(string xml, ITripleSlashCommentParserContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }
            // Quick turnaround for badly formed XML comment
            if (xml.StartsWith("<!-- Badly formed XML comment ignored for member "))
            {
                return(null);
            }
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);
                var nav = doc.CreateNavigator();
                if (!context.PreserveRawInlineComments)
                {
                    ResolveSeeCref(nav, string.Empty, context.AddReferenceDelegate);
                    ResolveSeeAlsoCref(nav, string.Empty, context.AddReferenceDelegate);
                    ResolveParameterRef(nav);
                }

                var model = new TripleSlashCommentModel();
                model.Summary = GetSummary(nav, context);
                model.Remarks = GetRemarks(nav, context);
                model.Returns = GetReturns(nav, context);

                model.Exceptions     = GetExceptions(nav, context);
                model.Sees           = GetSees(nav, context);
                model.SeeAlsos       = GetSeeAlsos(nav, context);
                model.Examples       = GetExamples(nav, context);
                model.Parameters     = GetParameters(nav, context);
                model.TypeParameters = GetTypeParameters(nav, context);
                return(model);
            }
            catch (XmlException)
            {
                return(null);
            }
        }
Beispiel #3
0
 public static void FeedComments(MetadataItem item, ITripleSlashCommentParserContext context)
 {
     if (!string.IsNullOrEmpty(item.RawComment))
     {
         var commentModel = TripleSlashCommentModel.CreateModel(item.RawComment, context);
         if (commentModel == null)
         {
             return;
         }
         item.Summary      = commentModel.Summary;
         item.Remarks      = commentModel.Remarks;
         item.Exceptions   = commentModel.Exceptions;
         item.Sees         = commentModel.Sees;
         item.SeeAlsos     = commentModel.SeeAlsos;
         item.Examples     = commentModel.Examples;
         item.CommentModel = commentModel;
     }
 }
        public static TripleSlashCommentModel CreateModel(string xml, ITripleSlashCommentParserContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (string.IsNullOrEmpty(xml)) return null;
            // Quick turnaround for badly formed XML comment
            if (xml.StartsWith("<!-- Badly formed XML comment ignored for member ")) return null;
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);
                var nav = doc.CreateNavigator();
                if (!context.PreserveRawInlineComments)
                {
                    ResolveSeeCref(nav, string.Empty, context.AddReferenceDelegate);
                    ResolveSeeAlsoCref(nav, string.Empty, context.AddReferenceDelegate);
                    ResolveParameterRef(nav);
                }

                var model = new TripleSlashCommentModel();
                model.Summary = GetSummary(nav, context);
                model.Remarks = GetRemarks(nav, context);
                model.Returns = GetReturns(nav, context);

                model.Exceptions = GetExceptions(nav, context);
                model.Sees = GetSees(nav, context);
                model.SeeAlsos = GetSeeAlsos(nav, context);
                model.Examples = GetExamples(nav, context);
                model.Parameters = GetParameters(nav, context);
                model.TypeParameters = GetTypeParameters(nav, context);
                return model;
            }
            catch (XmlException)
            {
                return null;
            }
        }