private static SyntaxNode?FindFirstNonNestedClass( ISyntaxFactsService syntaxFacts, SyntaxList <SyntaxNode> members, CancellationToken cancellationToken ) { foreach (var member in members) { cancellationToken.ThrowIfCancellationRequested(); if (syntaxFacts.IsNamespaceDeclaration(member)) { var firstClass = FindFirstNonNestedClass( syntaxFacts, syntaxFacts.GetMembersOfNamespaceDeclaration(member), cancellationToken ); if (firstClass != null) { return(firstClass); } } else if (syntaxFacts.IsClassDeclaration(member)) { return(member); } } return(null); }