public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) { var result = node; var attributes = node .AttributeLists .SelectMany(q => q.Attributes) .ToArray(); // todo aggregate to avoid the enumeration twice if (attributes.Any(s => s.Name.ToString() == "TestCase") && attributes.All(s => s.Name.ToString() != "Theory")) { var theoryList = AttributeSyntaxFactory .List(AttributeSyntaxFactory.Theory()) .NormalizeWhitespace() .WithTriviaFrom(node.AttributeLists[0]); var attrList = node.AttributeLists .Insert(0, theoryList); result = MethodDeclaration( attrList, node.Modifiers, node.ReturnType, node.ExplicitInterfaceSpecifier, node.Identifier, node.TypeParameterList, node.ParameterList, node.ConstraintClauses, node.Body, node.ExpressionBody, node.SemicolonToken); } return(base.VisitMethodDeclaration(result)); }