public void ShouldNotAddSummaryDocCommentsClassDeclarationWithSummaryComments() { var classDecl = @" /// <summary> /// A summary description /// </summary> public class Class1 { }"; var tree = CSharpSyntaxTree.ParseText(classDecl); var rewriter = new DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var classDeclSyntax = (ClassDeclarationSyntax)root.Members[0]; var result = rewriter.VisitClassDeclaration(classDeclSyntax); Assert.Equal(classDecl, result.ToFullString()); }
public void ShouldNotAddSummaryDocCommentsToNoAccessClassDeclaration() { var classDecl = @" class Class1 { }"; var expected = @" class Class1 { }"; var tree = CSharpSyntaxTree.ParseText(classDecl); var rewriter = new DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var classDeclSyntax = (ClassDeclarationSyntax)root.Members[0]; var result = rewriter.VisitClassDeclaration(classDeclSyntax); Assert.Equal(expected, result.ToFullString()); }
public void ShouldRetainOneLineSummaryDocumentationComments() { var classDecl = @" /// <summary>A summary comment.</summary> internal class Class1 { }"; var expected = @" /// <summary>A summary comment.</summary> internal class Class1 { }"; var tree = CSharpSyntaxTree.ParseText(classDecl); var rewriter = new DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var classDeclSyntax = (ClassDeclarationSyntax)root.Members[0]; var result = rewriter.VisitClassDeclaration(classDeclSyntax); Assert.Equal(expected, result.ToFullString()); }
public void ShoulAddSummaryAndNotSeeAlsoCommentsForUndefinedChildClass() { var classDecl = @" internal class Class1 : Class0 { }"; var expected = @" /// <summary> /// /// </summary> internal class Class1 : Class0 { }"; var tree = CSharpSyntaxTree.ParseText(classDecl); var rewriter = new DocumentCommentsRewriter(); var root = (CompilationUnitSyntax)tree.GetRoot(); var classDeclSyntax = (ClassDeclarationSyntax)root.Members[0]; var result = rewriter.VisitClassDeclaration(classDeclSyntax); Assert.Equal(expected, result.ToFullString()); }