public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var yieldClasses = new List<ClassDeclarationSyntax>();
            foreach (var method in node.Members.OfType<MemberDeclarationSyntax>().Where(j=>j is MethodDeclarationSyntax || j is PropertyDeclarationSyntax).Where(x => YieldChecker.HasYield(x)))
            {
                var yieldGenerator = new YieldClassGenerator(compilation, node, method);
                var enumerator = yieldGenerator.CreateEnumerator();
                yieldClasses.Add(enumerator);
            }

            if (yieldClasses.Any())
            {
                return node.AddMembers(yieldClasses.ToArray());
            }
            else
            {
                return base.VisitClassDeclaration(node);
            }
        }
示例#2
0
        public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var yieldClasses = new List <ClassDeclarationSyntax>();

            foreach (var method in node.Members.OfType <MemberDeclarationSyntax>().Where(j => j is MethodDeclarationSyntax || j is PropertyDeclarationSyntax).Where(x => YieldChecker.HasYield(x)))
            {
                var yieldGenerator = new YieldClassGenerator(compilation, node, method);
                var enumerator     = yieldGenerator.CreateEnumerator();
                yieldClasses.Add(enumerator);
            }

            if (yieldClasses.Any())
            {
                return(node.AddMembers(yieldClasses.ToArray()));
            }
            else
            {
                return(base.VisitClassDeclaration(node));
            }
        }