From 18c96e089de48d03cce49146b8950283017bddc9 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 23 Feb 2012 18:26:09 +0100 Subject: [PATCH] Add support for multiline XML documentation comments. --- .../Ast/GeneralScope/Comment.cs | 6 +- .../Parser/CSharpParser.cs | 12 +- .../TypeSystem/TypeSystemConvertVisitor.cs | 70 ++++++++++- .../Parser/GeneralScope/CommentTests.cs | 112 ++++++++++++++++++ .../Documentation/CSharpDocumentationTests.cs | 24 +++- .../Documentation/IDStringTests.cs | 78 ++++++------ .../ICSharpCode.NRefactory.Tests.csproj | 1 + 7 files changed, 251 insertions(+), 52 deletions(-) create mode 100644 ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs index b0e8ab5f22..cd4010437f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs @@ -43,7 +43,11 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Inactive code (code in non-taken "#if") /// - InactiveCode + InactiveCode, + /// + /// "/** */" comment + /// + MultiLineDocumentation } public class Comment : AstNode, IRelocatable diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index bafabef19b..a662f8b2ac 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs @@ -3474,14 +3474,20 @@ namespace ICSharpCode.NRefactory.CSharp AstNode newLeaf = null; var comment = special as SpecialsBag.Comment; if (comment != null) { - if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation)) + // HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer + bool isMultilineDocumentationComment = ( + comment.CommentType == SpecialsBag.CommentType.Multi + && comment.Content.StartsWith("*", StringComparison.Ordinal) + && !comment.Content.StartsWith("**", StringComparison.Ordinal) + ); + if (conversionVisitor.convertTypeSystemMode && !(comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment)) continue; - var type = (CommentType)comment.CommentType; + var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType; var start = new TextLocation (comment.Line, comment.Col); var end = new TextLocation (comment.EndLine, comment.EndCol); newLeaf = new Comment (type, start, end) { StartsLine = comment.StartsLine, - Content = comment.Content + Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content }; } else { var directive = special as SpecialsBag.PreProcessorDirective; diff --git a/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs index de4296858d..5a87cbe14e 100644 --- a/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using ICSharpCode.NRefactory.CSharp.Analysis; @@ -1126,19 +1127,82 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem if (this.SkipXmlDocumentation) return; List documentation = null; + // traverse AST backwards until the next non-whitespace node for (AstNode node = entityDeclaration.PrevSibling; node != null && node.NodeType == NodeType.Whitespace; node = node.PrevSibling) { Comment c = node as Comment; - if (c != null && c.CommentType == CommentType.Documentation) { + if (c != null && (c.CommentType == CommentType.Documentation || c.CommentType == CommentType.MultiLineDocumentation)) { if (documentation == null) documentation = new List(); - documentation.Add(c.Content); + if (c.CommentType == CommentType.MultiLineDocumentation) { + documentation.Add(PrepareMultilineDocumentation(c.Content)); + } else { + if (c.Content.Length > 0 && c.Content[0] == ' ') + documentation.Add(c.Content.Substring(1)); + else + documentation.Add(c.Content); + } } } if (documentation != null) { - documentation.Reverse(); // bring docu in correct order + documentation.Reverse(); // bring documentation in correct order parsedFile.AddDocumentation(entity, string.Join(Environment.NewLine, documentation)); } } + + string PrepareMultilineDocumentation(string content) + { + StringBuilder b = new StringBuilder(); + using (var reader = new StringReader(content)) { + string firstLine = reader.ReadLine(); + // Add first line only if it's not empty: + if (!string.IsNullOrWhiteSpace(firstLine)) { + if (firstLine[0] == ' ') + b.Append(firstLine, 1, firstLine.Length - 1); + else + b.Append(firstLine); + } + // Read lines into list: + List lines = new List(); + string line; + while ((line = reader.ReadLine()) != null) + lines.Add(line); + // If the last line (the line with '*/' delimiter) is white space only, ignore it. + if (lines.Count > 0 && string.IsNullOrWhiteSpace(lines[lines.Count - 1])) + lines.RemoveAt(lines.Count - 1); + if (lines.Count > 0) { + // Extract pattern from lines[0]: whitespace, asterisk, whitespace + int patternLength = 0; + string secondLine = lines[0]; + while (patternLength < secondLine.Length && char.IsWhiteSpace(secondLine[patternLength])) + patternLength++; + if (patternLength < secondLine.Length && secondLine[patternLength] == '*') { + patternLength++; + while (patternLength < secondLine.Length && char.IsWhiteSpace(secondLine[patternLength])) + patternLength++; + } else { + // no asterisk + patternLength = 0; + } + // Now reduce pattern length to the common pattern: + for (int i = 1; i < lines.Count; i++) { + line = lines[i]; + if (line.Length < patternLength) + patternLength = line.Length; + for (int j = 0; j < patternLength; j++) { + if (secondLine[j] != line[j]) + patternLength = j; + } + } + // Append the lines to the string builder: + for (int i = 0; i < lines.Count; i++) { + if (b.Length > 0 || i > 0) + b.Append(Environment.NewLine); + b.Append(lines[i], patternLength, lines[i].Length - patternLength); + } + } + } + return b.ToString(); + } #endregion } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs new file mode 100644 index 0000000000..985b6483e4 --- /dev/null +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs @@ -0,0 +1,112 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Linq; +using NUnit.Framework; + +namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope +{ + [TestFixture] + public class CommentTests + { + [Test] + public void SimpleComment() + { + string program = @"namespace NS { + // Comment +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.SingleLine, c.CommentType); + Assert.AreEqual(" Comment", c.Content); + } + + [Test] + public void CStyleComment() + { + string program = @"namespace NS { + /* Comment */ +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.MultiLine, c.CommentType); + Assert.AreEqual(" Comment ", c.Content); + } + + [Test] + public void DocumentationComment() + { + string program = @"namespace NS { + /// Comment +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.Documentation, c.CommentType); + Assert.AreEqual(" Comment", c.Content); + } + + [Test, Ignore("Parser bug")] + public void SimpleCommentWith4Slashes() + { + string program = @"namespace NS { + //// Comment +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.SingleLine, c.CommentType); + Assert.AreEqual("// Comment", c.Content); + } + + [Test] + public void MultilineDocumentationComment() + { + string program = @"namespace NS { + /** Comment */ +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.MultiLineDocumentation, c.CommentType); + Assert.AreEqual(" Comment ", c.Content); + } + + [Test] + public void EmptyMultilineCommnet() + { + string program = @"namespace NS { + /**/ +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.MultiLine, c.CommentType); + Assert.AreEqual("", c.Content); + } + + [Test] + public void MultilineCommentWith3Stars() + { + string program = @"namespace NS { + /*** Comment */ +}"; + NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal(program); + var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single(); + Assert.AreEqual(CommentType.MultiLine, c.CommentType); + Assert.AreEqual("** Comment ", c.Content); + } + } +} diff --git a/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs b/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs index ac212e371a..30b6db241c 100644 --- a/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs +++ b/ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.Documentation Init(@"using System; /// class Test { }"); - Assert.AreEqual("", typeDefinition.Documentation.Xml); + Assert.AreEqual("", typeDefinition.Documentation.ToString()); } [Test] @@ -56,7 +56,7 @@ class Test { }"); /// Documentation /// class Test { }"); - Assert.AreEqual("" + Environment.NewLine + "Documentation" + Environment.NewLine + "", typeDefinition.Documentation.Xml); + Assert.AreEqual("" + Environment.NewLine + "Documentation" + Environment.NewLine + "", typeDefinition.Documentation.ToString()); } [Test] @@ -67,7 +67,7 @@ class Test { }"); /// Documentation /// class Test { }"); - Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.Xml); + Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.ToString()); } [Test] @@ -76,7 +76,7 @@ class Test { }"); Init(@"using System; /** Documentation */ class Test { }"); - Assert.AreEqual("Documentation", typeDefinition.Documentation.Xml); + Assert.AreEqual("Documentation ", typeDefinition.Documentation.ToString()); } [Test] @@ -89,7 +89,7 @@ class Test { }"); */ class Test { }"); - Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.Xml); + Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.ToString()); } [Test] @@ -101,7 +101,19 @@ class Test { }"); * Documentation * */ class Test { }"); - Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.Xml); + Assert.AreEqual("" + Environment.NewLine + " Documentation" + Environment.NewLine + "", typeDefinition.Documentation.ToString()); + } + + [Test] + public void MultilineDocumentationNoCommonPattern() + { + Init(@"using System; +/** + + * Documentation + */ +class Test { }"); + Assert.AreEqual(" " + Environment.NewLine + " * Documentation", typeDefinition.Documentation.ToString()); } } } diff --git a/ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs b/ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs index 9e277748d6..aeb471af52 100644 --- a/ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs +++ b/ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs @@ -87,18 +87,18 @@ namespace Acme } }"; Init(program); - Assert.AreEqual("T:Color", GetTypeDefinition(string.Empty, "Color").Documentation.Xml); - Assert.AreEqual("T:Acme.IProcess", GetTypeDefinition("Acme", "IProcess").Documentation.Xml); - Assert.AreEqual("T:Acme.ValueType", GetTypeDefinition("Acme", "ValueType").Documentation.Xml); + Assert.AreEqual("T:Color", GetTypeDefinition(string.Empty, "Color").Documentation.ToString()); + Assert.AreEqual("T:Acme.IProcess", GetTypeDefinition("Acme", "IProcess").Documentation.ToString()); + Assert.AreEqual("T:Acme.ValueType", GetTypeDefinition("Acme", "ValueType").Documentation.ToString()); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("T:Acme.Widget", widget.Documentation.Xml); - Assert.AreEqual("T:Acme.Widget.NestedClass", widget.NestedTypes.Single(t => t.Name == "NestedClass").Documentation.Xml); - Assert.AreEqual("T:Acme.Widget.IMenuItem", widget.NestedTypes.Single(t => t.Name == "IMenuItem").Documentation.Xml); - Assert.AreEqual("T:Acme.Widget.Del", widget.NestedTypes.Single(t => t.Name == "Del").Documentation.Xml); - Assert.AreEqual("T:Acme.Widget.Direction", widget.NestedTypes.Single(t => t.Name == "Direction").Documentation.Xml); - Assert.AreEqual("T:Acme.MyList`1", GetTypeDefinition("Acme", "MyList", 1).Documentation.Xml); - Assert.AreEqual("T:Acme.MyList`1.Helper`2", GetTypeDefinition("Acme", "MyList", 1).NestedTypes.Single().Documentation.Xml); + Assert.AreEqual("T:Acme.Widget", widget.Documentation.ToString()); + Assert.AreEqual("T:Acme.Widget.NestedClass", widget.NestedTypes.Single(t => t.Name == "NestedClass").Documentation.ToString()); + Assert.AreEqual("T:Acme.Widget.IMenuItem", widget.NestedTypes.Single(t => t.Name == "IMenuItem").Documentation.ToString()); + Assert.AreEqual("T:Acme.Widget.Del", widget.NestedTypes.Single(t => t.Name == "Del").Documentation.ToString()); + Assert.AreEqual("T:Acme.Widget.Direction", widget.NestedTypes.Single(t => t.Name == "Direction").Documentation.ToString()); + Assert.AreEqual("T:Acme.MyList`1", GetTypeDefinition("Acme", "MyList", 1).Documentation.ToString()); + Assert.AreEqual("T:Acme.MyList`1.Helper`2", GetTypeDefinition("Acme", "MyList", 1).NestedTypes.Single().Documentation.ToString()); } [Test] @@ -121,10 +121,10 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("F:Acme.Widget.NestedClass.value", widget.NestedTypes.Single().Fields.Single().Documentation.Xml); - Assert.AreEqual("F:Acme.Widget.message", widget.Fields.Single(f => f.Name == "message").Documentation.Xml); - Assert.AreEqual("F:Acme.Widget.PI", widget.Fields.Single(f => f.Name == "PI").Documentation.Xml); - Assert.AreEqual("F:Acme.Widget.ppValues", widget.Fields.Single(f => f.Name == "ppValues").Documentation.Xml); + Assert.AreEqual("F:Acme.Widget.NestedClass.value", widget.NestedTypes.Single().Fields.Single().Documentation.ToString()); + Assert.AreEqual("F:Acme.Widget.message", widget.Fields.Single(f => f.Name == "message").Documentation.ToString()); + Assert.AreEqual("F:Acme.Widget.PI", widget.Fields.Single(f => f.Name == "PI").Documentation.ToString()); + Assert.AreEqual("F:Acme.Widget.ppValues", widget.Fields.Single(f => f.Name == "ppValues").Documentation.ToString()); } [Test] @@ -142,9 +142,9 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.#cctor", widget.Methods.Single(m => m.IsStatic).Documentation.Xml); - Assert.AreEqual("M:Acme.Widget.#ctor", widget.Methods.Single(m => !m.IsStatic && m.Parameters.Count == 0).Documentation.Xml); - Assert.AreEqual("M:Acme.Widget.#ctor(System.String)", widget.Methods.Single(m => m.Parameters.Count == 1).Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.#cctor", widget.Methods.Single(m => m.IsStatic).Documentation.ToString()); + Assert.AreEqual("M:Acme.Widget.#ctor", widget.Methods.Single(m => !m.IsStatic && m.Parameters.Count == 0).Documentation.ToString()); + Assert.AreEqual("M:Acme.Widget.#ctor(System.String)", widget.Methods.Single(m => m.Parameters.Count == 1).Documentation.ToString()); } [Test] @@ -160,7 +160,7 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.Finalize", widget.Methods.Single(m => m.EntityType == EntityType.Destructor).Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.Finalize", widget.Methods.Single(m => m.EntityType == EntityType.Destructor).Documentation.ToString()); } [Test] @@ -200,28 +200,28 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.NestedClass.M(System.Int32)", widget.NestedTypes.Single().Methods.Single(m => m.EntityType == EntityType.Method).Documentation.Xml); - Assert.AreEqual("M:Acme.Widget.M0", widget.Methods.Single(m => m.Name == "M0").Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.NestedClass.M(System.Int32)", widget.NestedTypes.Single().Methods.Single(m => m.EntityType == EntityType.Method).Documentation.ToString()); + Assert.AreEqual("M:Acme.Widget.M0", widget.Methods.Single(m => m.Name == "M0").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M1(System.Char,System.Single@,Acme.ValueType@)", - widget.Methods.Single(m => m.Name == "M1").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M1").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])", - widget.Methods.Single(m => m.Name == "M2").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M2").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M3(System.Int64[][],Acme.Widget[0:,0:,0:][])", - widget.Methods.Single(m => m.Name == "M3").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M3").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M4(System.Char*,Color**)", - widget.Methods.Single(m => m.Name == "M4").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M4").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M5(System.Void*,System.Double*[0:,0:][])", - widget.Methods.Single(m => m.Name == "M5").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M5").Documentation.ToString()); Assert.AreEqual("M:Acme.Widget.M6(System.Nullable{System.Int32},System.Object[])", - widget.Methods.Single(m => m.Name == "M6").Documentation.Xml); + widget.Methods.Single(m => m.Name == "M6").Documentation.ToString()); Assert.AreEqual("M:Acme.MyList`1.Test(`0)", - GetTypeDefinition("Acme", "MyList", 1).Methods.Single(m => m.Name == "Test").Documentation.Xml); + GetTypeDefinition("Acme", "MyList", 1).Methods.Single(m => m.Name == "Test").Documentation.ToString()); Assert.AreEqual("M:Acme.UseList.Process(Acme.MyList{Color})", - GetTypeDefinition("Acme", "UseList").Methods.Single(m => m.Name == "Process").Documentation.Xml); + GetTypeDefinition("Acme", "UseList").Methods.Single(m => m.Name == "Process").Documentation.ToString()); Assert.AreEqual("M:Acme.UseList.GetValues``1(``0)", - GetTypeDefinition("Acme", "UseList").Methods.Single(m => m.Name == "GetValues").Documentation.Xml); + GetTypeDefinition("Acme", "UseList").Methods.Single(m => m.Name == "GetValues").Documentation.ToString()); } [Test] @@ -229,8 +229,8 @@ namespace Acme { Init("class A { class B { void M(A.B a) { } } }"); ITypeDefinition b = GetTypeDefinition("", "A", 1).NestedTypes.Single(); - Assert.AreEqual("T:A`1.B`1", b.Documentation.Xml); - Assert.AreEqual("M:A`1.B`1.M(A{`1}.B{`0})", b.Methods.Single(m => m.EntityType == EntityType.Method).Documentation.Xml); + Assert.AreEqual("T:A`1.B`1", b.Documentation.ToString()); + Assert.AreEqual("M:A`1.B`1.M(A{`1}.B{`0})", b.Methods.Single(m => m.EntityType == EntityType.Method).Documentation.ToString()); } [Test] @@ -248,11 +248,11 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("P:Acme.Widget.Width", widget.Properties.Single(p => p.Parameters.Count == 0).Documentation.Xml); + Assert.AreEqual("P:Acme.Widget.Width", widget.Properties.Single(p => p.Parameters.Count == 0).Documentation.ToString()); Assert.AreEqual("P:Acme.Widget.Item(System.Int32)", - widget.Properties.Single(p => p.Parameters.Count == 1).Documentation.Xml); + widget.Properties.Single(p => p.Parameters.Count == 1).Documentation.ToString()); Assert.AreEqual("P:Acme.Widget.Item(System.String,System.Int32)", - widget.Properties.Single(p => p.Parameters.Count == 2).Documentation.Xml); + widget.Properties.Single(p => p.Parameters.Count == 2).Documentation.ToString()); } @@ -269,7 +269,7 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("E:Acme.Widget.AnEvent", widget.Events.Single().Documentation.Xml); + Assert.AreEqual("E:Acme.Widget.AnEvent", widget.Events.Single().Documentation.ToString()); } @@ -286,7 +286,7 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.op_UnaryPlus(Acme.Widget)", widget.Methods.Single(m => m.EntityType == EntityType.Operator).Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.op_UnaryPlus(Acme.Widget)", widget.Methods.Single(m => m.EntityType == EntityType.Operator).Documentation.ToString()); } [Test] @@ -302,7 +302,7 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)", widget.Methods.Single(m => m.EntityType == EntityType.Operator).Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)", widget.Methods.Single(m => m.EntityType == EntityType.Operator).Documentation.ToString()); } [Test] @@ -319,8 +319,8 @@ namespace Acme }"; Init(program); ITypeDefinition widget = GetTypeDefinition("Acme", "Widget"); - Assert.AreEqual("M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32", widget.Methods.First(m => m.EntityType == EntityType.Operator).Documentation.Xml); - Assert.AreEqual("M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64", widget.Methods.Last(m => m.EntityType == EntityType.Operator).Documentation.Xml); + Assert.AreEqual("M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32", widget.Methods.First(m => m.EntityType == EntityType.Operator).Documentation.ToString()); + Assert.AreEqual("M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64", widget.Methods.Last(m => m.EntityType == EntityType.Operator).Documentation.ToString()); } [Test] diff --git a/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj b/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj index 6bc7802517..31749c9605 100644 --- a/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj +++ b/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj @@ -88,6 +88,7 @@ +