Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martinez <joelmartinez@gmail.com>2020-03-06 00:37:08 +0300
committerJoel Martinez <joelmartinez@gmail.com>2020-03-06 23:46:29 +0300
commit44da4c1282d00ad20701ae1445fe59916cb65874 (patch)
treef4652ac9c4892d17dd0831e9be464d33c17b1a1b /mdoc/Mono.Documentation/Updater/DocUtils.cs
parent49f4e9ba75c06b72a4bb2e421c57d8b334a2bb96 (diff)
[import] fixed issue with xpath
Diffstat (limited to 'mdoc/Mono.Documentation/Updater/DocUtils.cs')
-rw-r--r--mdoc/Mono.Documentation/Updater/DocUtils.cs26
1 files changed, 23 insertions, 3 deletions
diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs
index 8af7befd..16101987 100644
--- a/mdoc/Mono.Documentation/Updater/DocUtils.cs
+++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs
@@ -5,7 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
-
+using System.Xml.XPath;
using Mono.Cecil;
using Mono.Collections.Generic;
using Mono.Documentation.Util;
@@ -265,6 +265,8 @@ namespace Mono.Documentation.Updater
{
if (n is XmlText && n.InnerText == "To Be Added.")
return false;
+ else if (n is XmlComment)
+ return false;
else
{
bool removed = true;
@@ -272,14 +274,32 @@ namespace Mono.Documentation.Updater
{
if (nchild == null) continue;
+ if (nchild is XmlComment || nchild is XmlText || nchild is XmlCDataSection)
+ {
+ nchild.ParentNode.RemoveChild(nchild);
+ removed = true;
+ continue;
+ }
+
if (depth == 0)
{
// check the first level children to see if there's an incoming node that matches
var avalues = nchild.Attributes?.Cast<XmlAttribute>().Select(a => $"@{a.Name}='{a.Value}'").ToArray();
var nodexpath = $"./{nchild.Name}";
if (avalues?.Length > 0)
- nodexpath += $"[{ string.Join(" AND ", avalues) }]";
- var incomingEquivalent = incoming.SelectSingleNode(nodexpath);
+ nodexpath += $"[{ string.Join(" and ", avalues) }]";
+
+ XmlNode incomingEquivalent;
+
+ try
+ {
+ incomingEquivalent = incoming.SelectSingleNode(nodexpath);
+ }
+ catch (XPathException xex)
+ {
+ throw new MDocException($"xpath error: {nodexpath}. On incoming node {incoming.OuterXml}", xex);
+ }
+
if (incomingEquivalent != null)
{
nchild.ParentNode.RemoveChild(nchild);