コード例 #1
0
		public override void VisitClassDeclaration(ClassDeclarationSyntax node)
		{
			if (node.ShouldBeHidden()) return;

			++ClassDepth;
			if (ClassDepth == 1)
			{
				base.VisitClassDeclaration(node);
			}				
			else if (node.ChildNodes().All(childNode => childNode is PropertyDeclarationSyntax || childNode is AttributeListSyntax))
			{
				// simple nested POCO	
				var line = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
				var walker = new CodeWithDocumentationWalker(ClassDepth - 2, line);
				walker.Visit(node);
				this.Blocks.AddRange(walker.Blocks);
			}
			else
			{
				var methods = node.ChildNodes().OfType<MethodDeclarationSyntax>();
				if (!methods.Any(m => m.AttributeLists.SelectMany(a => a.Attributes).Any()))
				{
					// nested class with methods that are not unit or integration tests e.g. example PropertyVisitor in Automap.doc.cs
					var line = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
					var walker = new CodeWithDocumentationWalker(ClassDepth - 2, line);
					walker.Visit(node);
					this.Blocks.AddRange(walker.Blocks);
				}
			}
			--ClassDepth;
		}
コード例 #2
0
        public override void VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            if (node.ShouldBeHidden())
            {
                return;
            }

            ++ClassDepth;
            if (ClassDepth == 1)
            {
                base.VisitClassDeclaration(node);
            }
            else if (node.ChildNodes().All(childNode => childNode is PropertyDeclarationSyntax || childNode is AttributeListSyntax))
            {
                // simple nested POCO
                var line   = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
                var walker = new CodeWithDocumentationWalker(ClassDepth - 2, line);
                walker.Visit(node);
                this.Blocks.AddRange(walker.Blocks);
            }
            else
            {
                var methods = node.ChildNodes().OfType <MethodDeclarationSyntax>();
                if (!methods.Any(m => m.AttributeLists.SelectMany(a => a.Attributes).Any()))
                {
                    // nested class with methods that are not unit or integration tests e.g. example PropertyVisitor in Automap.doc.cs
                    var line   = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
                    var walker = new CodeWithDocumentationWalker(ClassDepth - 2, line);
                    walker.Visit(node);
                    this.Blocks.AddRange(walker.Blocks);
                }
            }
            --ClassDepth;
        }
コード例 #3
0
        public override void VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
        {
            if (node.ShouldBeHidden())
            {
                return;
            }

            if (this.InsideAutoIncludeMethodBlock)
            {
                var allchildren      = node.DescendantNodesAndTokens(descendIntoTrivia: true);
                var linePositionSpan = node.SyntaxTree.GetLineSpan(node.Span);
                var line             = linePositionSpan.StartLinePosition.Line;
                if (allchildren.Any(a => a.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia))
                {
                    var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);
                    walker.Visit(node.WithAdditionalAnnotations());
                    this.Blocks.AddRange(walker.Blocks);
                    return;
                }
                var code = node.WithoutLeadingTrivia().ToFullString();
                code = code.RemoveNumberOfLeadingTabsAfterNewline(ClassDepth + 2);
                this.Blocks.Add(new CodeBlock(code, line, Language.CSharp, _propertyOrMethodName));

                if (allchildren.Any(a => a.Kind() == SyntaxKind.SimpleLambdaExpression))
                {
                    // nested lambda inside this local declaration
                    this.IncludeMethodBlockContainsLambda = true;
                    this.EndLine = linePositionSpan.EndLinePosition.Line;
                }
            }
            base.VisitLocalDeclarationStatement(node);
        }
コード例 #4
0
		public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node)
		{
			if (node.ShouldBeHidden()) return;

			if (node.ChildNodes().All(childNode => childNode is PropertyDeclarationSyntax || childNode is AttributeListSyntax))
			{
				// simple nested interface	
				var line = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
				var walker = new CodeWithDocumentationWalker(0, line);
				walker.Visit(node);
				this.Blocks.AddRange(walker.Blocks);
			}
		}
コード例 #5
0
        public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node)
        {
            if (node.ShouldBeHidden())
            {
                return;
            }

            if (node.ChildNodes().All(childNode => childNode is PropertyDeclarationSyntax || childNode is AttributeListSyntax))
            {
                // simple nested interface
                var line   = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
                var walker = new CodeWithDocumentationWalker(0, line);
                walker.Visit(node);
                this.Blocks.AddRange(walker.Blocks);
            }
        }
コード例 #6
0
        public override void VisitForEachStatement(ForEachStatementSyntax node)
        {
            if (node.ShouldBeHidden())
            {
                return;
            }

            if (this.InsideAutoIncludeMethodBlock)
            {
                var line   = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
                var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);
                walker.Visit(node);
                this.Blocks.AddRange(walker.Blocks);
            }
            else
            {
                base.VisitForEachStatement(node);
            }
        }
コード例 #7
0
        public override void VisitArrowExpressionClause(ArrowExpressionClauseSyntax node)
        {
            if (node.ShouldBeHidden())
            {
                return;
            }

            if (!this.InsideFluentOrInitializerExample && !PropertyOrMethodNamesOfInterest.Contains(_propertyOrMethodName))
            {
                return;
            }
            var syntaxNode = node?.ChildNodes()?.LastOrDefault()?.WithAdditionalAnnotations();

            if (syntaxNode == null)
            {
                return;
            }
            var line   = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
            var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);

            walker.Visit(syntaxNode);
            this.Blocks.AddRange(walker.Blocks);
        }
コード例 #8
0
		public override void VisitForEachStatement(ForEachStatementSyntax node)
		{
			if (node.ShouldBeHidden()) return;

			if (this.InsideAutoIncludeMethodBlock)
			{
				var line = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
				var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);
				walker.Visit(node);
				this.Blocks.AddRange(walker.Blocks);
			}
			else base.VisitForEachStatement(node);
		}
コード例 #9
0
		public override void VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
		{
			if (node.ShouldBeHidden()) return;

			if (this.InsideAutoIncludeMethodBlock)
			{
				var allchildren = node.DescendantNodesAndTokens(descendIntoTrivia: true);
				var linePositionSpan = node.SyntaxTree.GetLineSpan(node.Span);
				var line = linePositionSpan.StartLinePosition.Line;
				if (allchildren.Any(a => a.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia))
				{
					var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);
					walker.Visit(node.WithAdditionalAnnotations());
					this.Blocks.AddRange(walker.Blocks);
					return;
				}
				var code = node.WithoutLeadingTrivia().ToFullString();
				code = code.RemoveNumberOfLeadingTabsAfterNewline(ClassDepth + 2);
				this.Blocks.Add(new CodeBlock(code, line, Language.CSharp, _propertyOrMethodName));

				if (allchildren.Any(a => a.Kind() == SyntaxKind.SimpleLambdaExpression))
				{
					// nested lambda inside this local declaration
					this.IncludeMethodBlockContainsLambda = true;
					this.EndLine = linePositionSpan.EndLinePosition.Line;
				}
			}
			base.VisitLocalDeclarationStatement(node);
		}
コード例 #10
0
		public override void VisitArrowExpressionClause(ArrowExpressionClauseSyntax node)
		{
			if (node.ShouldBeHidden()) return;

			if (!this.InsideFluentOrInitializerExample && !PropertyOrMethodNamesOfInterest.Contains(_propertyOrMethodName)) return;
			var syntaxNode = node?.ChildNodes()?.LastOrDefault()?.WithAdditionalAnnotations();
			if (syntaxNode == null) return;
			var line = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
			var walker = new CodeWithDocumentationWalker(ClassDepth, line, _propertyOrMethodName);
			walker.Visit(syntaxNode);
			this.Blocks.AddRange(walker.Blocks);
		}