public static ClassDeclarationSyntax AddOrUpdateMethod(this ClassDeclarationSyntax classDeclaration, Func <MethodDeclarationSyntax, bool> predicate, MethodDeclarationSyntax method) { classDeclaration = classDeclaration.AddOrUpdateNode( classDeclaration.Members.OfType <MethodDeclarationSyntax>().FirstOrDefault(predicate).ToOption(), method); return(classDeclaration); }