public void ShouldNotAddSummaryDocCommentsToConstructorDeclarationWithCommentsNoArguments() { var consDecl = @"public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> public Class1() { } }"; var expected = @"/// <summary> /// /// </summary> public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> public Class1() { } }"; var tree = CSharpSyntaxTree.ParseText(consDecl); var rewriter = new GenerateDocumentationComments.DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var result = rewriter.Visit(root); Assert.Equal(expected, result.ToFullString()); }
public void ShouldAddSummaryDocCommentsToClass2ConstructorDeclarationNoArguments() { var consDecl = @"public class Class2 { public Class2() { } }"; var expected = @"/// <summary> /// /// </summary> public class Class2 { /// <summary> /// Initializes a new instance of the <see cref=""Class2""/> class. /// </summary> public Class2() { } }"; var tree = CSharpSyntaxTree.ParseText(consDecl); var rewriter = new GenerateDocumentationComments.DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var result = rewriter.Visit(root); Assert.Equal(expected, result.ToFullString()); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var textView = GetTextViewOfActiveDocument(); if (textView != null) { var code = textView.TextSnapshot.GetText(); var syntaxTree = CSharpSyntaxTree.ParseText(code); var root = syntaxTree.GetRoot(); var rewriter = new DocumentCommentsRewriter(); var newCode = rewriter.Visit(root).ToFullString(); textView.TextBuffer.Replace(new Span(0, textView.TextSnapshot.Length), newCode); } }
public void ShouldAddSummaryDocCommentsToIndented4SpacesPublicClassDeclaration() { var classDecl = @" public class Class1 { }"; var expected = @" /// <summary> /// /// </summary> public class Class1 { }"; var tree = CSharpSyntaxTree.ParseText(classDecl); var rewriter = new GenerateDocumentationComments.DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var classDeclSyntax = (ClassDeclarationSyntax)root.Members[0]; var result = rewriter.VisitClassDeclaration(classDeclSyntax); Assert.Equal(expected, result.ToFullString()); }
public void ShouldAddParameterDocCommentsToConstructorDeclarationWithThreeParameters() { var consDecl = @" /// <summary> /// A summary comment. /// </summary> public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> public Class1(string text, string anotherString, string yetAnotherString) { } }"; var expected = @" /// <summary> /// A summary comment. /// </summary> public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> /// <param name=""text"">The text.</param> /// <param name=""anotherString"">The another string.</param> /// <param name=""yetAnotherString"">The yet another string.</param> public Class1(string text, string anotherString, string yetAnotherString) { } }"; var tree = CSharpSyntaxTree.ParseText(consDecl); var rewriter = new GenerateDocumentationComments.DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var result = rewriter.Visit(root); Assert.Equal(expected, result.ToFullString()); }
public void ShouldModifyParameterDocCommentsToConstructorDeclarationWithMismatchedParameterName() { var consDecl = @" /// <summary> /// A summary comment. /// </summary> public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> /// <param name=""text"">The text.</param> public Class1(string newText) { } }"; var expected = @" /// <summary> /// A summary comment. /// </summary> public class Class1 { /// <summary> /// Non-standard constructor comment. /// </summary> /// <param name=""newText"">The new text.</param> public Class1(string newText) { } }"; var tree = CSharpSyntaxTree.ParseText(consDecl); var rewriter = new GenerateDocumentationComments.DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var result = rewriter.Visit(root); Assert.Equal(expected, result.ToFullString()); }