示例#1
0
        public void ShouldNotAddSummaryDocCommentsClassDeclarationWithMultilineSummaryComments()
        {
            var classDecl =
                @"        /** <summary>
         * A summary description
         * </summary> 
         **/
        public class Class1
        {
        }";
            var expected =
                @"        /// <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(expected, result.ToFullString());
        }
示例#2
0
        public void ShouldChangeSummaryDocCommentsToBeginAtClassDeclarationColumn()
        {
            var classDecl =
                @"    /// <summary>
    /// 
    /// </summary>
  internal class Class1
  {
  }";
            var expected =
                @"  /// <summary>
  /// 
  /// </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());
        }
示例#3
0
        public void ShouldAddSummaryAndSeeAlsoCommentsForClassWithDefinedTemplatedInterface()
        {
            var classDecl =
                @"using System.Collections.Generic;

    internal class Class1 : IEnumerable<Class0>
    {
    }

    internal interface IEnumerable<T>
    {
    }";
            var expected =
                @"using System.Collections.Generic;

    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref=""IEnumerable""/>
    internal class Class1 : IEnumerable<Class0>
    {
    }

    internal interface IEnumerable<T>
    {
    }";
            var tree     = CSharpSyntaxTree.ParseText(classDecl);
            var rewriter = new DocumentCommentsRewriter();
            var root     = (CompilationUnitSyntax)tree.GetRoot();

            var result = rewriter.Visit(root);

            Assert.Equal(expected, result.ToFullString());
        }
示例#4
0
        public void ShouldAddSummaryAnd3SeeAlsoCommentsForChildClassesAnd2Interfaces()
        {
            var classDecl =
                @"    internal class Class1 : Class0, IClass, IClass2
    {
    }
    internal class Class0
    {
    }
    internal interface IClass
    {
    }
    internal interface IClass2
    {
    }";
            var expected =
                @"    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref=""Class0""/>
    /// <seealso cref=""IClass""/>
    /// <seealso cref=""IClass2""/>
    internal class Class1 : Class0, IClass, IClass2
    {
    }
";
            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());
        }
示例#5
0
        public void ShouldRetainExistingCommentsWhenAddingSummaryComments()
        {
            var classDecl =
                @"    /// <remarks>A remarks comment.</remarks>
    /// <remarks>More remarks.</remarks>
    internal class Class1
    {
    }";
            var expected =
                @"    /// <summary>
    /// 
    /// </summary>
    /// <remarks>A remarks comment.</remarks>
    /// <remarks>More remarks.</remarks>
    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());
        }
示例#6
0
        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());
        }
示例#7
0
        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());
        }