Browse Source

Add support for multiline XML documentation comments.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
18c96e089d
  1. 6
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs
  2. 12
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  3. 70
      ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs
  4. 112
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs
  5. 24
      ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs
  6. 78
      ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs
  7. 1
      ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj

6
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs

@ -43,7 +43,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,7 +43,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Inactive code (code in non-taken "#if")
/// </summary>
InactiveCode
InactiveCode,
/// <summary>
/// "/** */" comment
/// </summary>
MultiLineDocumentation
}
public class Comment : AstNode, IRelocatable

12
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -3474,14 +3474,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -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;

70
ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs

@ -19,6 +19,7 @@ @@ -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 @@ -1126,19 +1127,82 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
if (this.SkipXmlDocumentation)
return;
List<string> 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<string>();
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<string> lines = new List<string>();
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
}
}

112
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/CommentTests.cs

@ -0,0 +1,112 @@ @@ -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<NamespaceDeclaration>(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<NamespaceDeclaration>(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<NamespaceDeclaration>(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<NamespaceDeclaration>(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<NamespaceDeclaration>(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<NamespaceDeclaration>(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<NamespaceDeclaration>(program);
var c = ns.GetChildrenByRole(AstNode.Roles.Comment).Single();
Assert.AreEqual(CommentType.MultiLine, c.CommentType);
Assert.AreEqual("** Comment ", c.Content);
}
}
}

24
ICSharpCode.NRefactory.Tests/Documentation/CSharpDocumentationTests.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.Documentation
Init(@"using System;
/// <summary/>
class Test { }");
Assert.AreEqual("<summary/>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary/>", typeDefinition.Documentation.ToString());
}
[Test]
@ -56,7 +56,7 @@ class Test { }"); @@ -56,7 +56,7 @@ class Test { }");
/// Documentation
/// </summary>
class Test { }");
Assert.AreEqual("<summary>" + Environment.NewLine + "Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary>" + Environment.NewLine + "Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.ToString());
}
[Test]
@ -67,7 +67,7 @@ class Test { }"); @@ -67,7 +67,7 @@ class Test { }");
/// Documentation
/// </summary>
class Test { }");
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.ToString());
}
[Test]
@ -76,7 +76,7 @@ class Test { }"); @@ -76,7 +76,7 @@ class Test { }");
Init(@"using System;
/** <summary>Documentation</summary> */
class Test { }");
Assert.AreEqual("<summary>Documentation</summary>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary>Documentation</summary> ", typeDefinition.Documentation.ToString());
}
[Test]
@ -89,7 +89,7 @@ class Test { }"); @@ -89,7 +89,7 @@ class Test { }");
</summary>
*/
class Test { }");
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.ToString());
}
[Test]
@ -101,7 +101,19 @@ class Test { }"); @@ -101,7 +101,19 @@ class Test { }");
* Documentation
* </summary>*/
class Test { }");
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.Xml);
Assert.AreEqual("<summary>" + Environment.NewLine + " Documentation" + Environment.NewLine + "</summary>", typeDefinition.Documentation.ToString());
}
[Test]
public void MultilineDocumentationNoCommonPattern()
{
Init(@"using System;
/**
<summary>
* Documentation
*/
class Test { }");
Assert.AreEqual(" <summary>" + Environment.NewLine + " * Documentation", typeDefinition.Documentation.ToString());
}
}
}

78
ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs

@ -87,18 +87,18 @@ namespace Acme @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -229,8 +229,8 @@ namespace Acme
{
Init("class A<X> { class B<Y> { void M(A<Y>.B<X> 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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]

1
ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj

@ -88,6 +88,7 @@ @@ -88,6 +88,7 @@
<Compile Include="CSharp\Parser\Expression\AnonymousTypeCreateExpressionTests.cs" />
<Compile Include="CSharp\Parser\Expression\ObjectCreateExpressionTests.cs" />
<Compile Include="CSharp\Parser\Expression\UndocumentedExpressionTests.cs" />
<Compile Include="CSharp\Parser\GeneralScope\CommentTests.cs" />
<Compile Include="CSharp\Parser\GeneralScope\DelegateDeclarationTests.cs" />
<Compile Include="CSharp\Parser\GeneralScope\NamespaceDeclarationTests.cs" />
<Compile Include="CSharp\Parser\GeneralScope\PreprocessorDirectiveTests.cs" />

Loading…
Cancel
Save