From b55866d86d4d4e3fc1b3cd13d61479ecccdcf8e7 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Nov 2013 16:30:06 +0100 Subject: [PATCH] Fix #244: Add CDATA Support to DocumentationElement.cs --- .../Documentation/CSharpDocumentationTests.cs | 13 +++++++++++++ ICSharpCode.NRefactory.Xml/DocumentationElement.cs | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs b/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs index 031c55554..b1060879a 100644 --- a/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs +++ b/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs @@ -169,5 +169,18 @@ public void DocumentationAboveAttributeInRegion() class Test { }"); Assert.AreEqual("", typeDefinition.Documentation.ToString()); } + + [Test] + public void CDATAInDocumentation() + { + Init(@"using System; +/// before]]>after +class Test { } +"); + var element = XmlDocumentationElement.Get(typeDefinition); + Assert.AreEqual(1, element.Children.Count()); + Assert.AreEqual("summary", element.Children[0].Name); + Assert.AreEqual("beforeafter", element.Children[0].TextContent); + } } } diff --git a/ICSharpCode.NRefactory.Xml/DocumentationElement.cs b/ICSharpCode.NRefactory.Xml/DocumentationElement.cs index 17d17e1f7..43e816b31 100644 --- a/ICSharpCode.NRefactory.Xml/DocumentationElement.cs +++ b/ICSharpCode.NRefactory.Xml/DocumentationElement.cs @@ -198,9 +198,13 @@ static List CreateElements(IEnumerable chil List list = new List(); foreach (var child in childObjects) { var childText = child as AXmlText; + var childTag = child as AXmlTag; var childElement = child as AXmlElement; if (childText != null) { list.Add(new XmlDocumentationElement(childText.Value, declaringEntity)); + } else if (childTag != null && childTag.IsCData) { + foreach (var text in childTag.Children.OfType()) + list.Add(new XmlDocumentationElement(text.Value, declaringEntity)); } else if (childElement != null) { if (nestingLevel < 5 && childElement.Name == "inheritdoc") { string cref = childElement.GetAttributeValue("cref");