private bool DetermineNamespaceOrTypeToGenerateInWorker( TService service, SemanticModel semanticModel, CancellationToken cancellationToken) { // If we're on the right of a dot, see if we can figure out what's on the left. If // it doesn't bind to a type or a namespace, then we can't proceed. if (this.SimpleName != this.NameOrMemberAccessExpression) { return(DetermineNamespaceOrTypeToGenerateIn( service, semanticModel, service.GetLeftSideOfDot(this.SimpleName), cancellationToken)); } else { // The name is standing alone. We can either generate the type into our // containing type, or into our containing namespace. // // TODO(cyrusn): We need to make this logic work if the type is in the // base/interface list of a type. var format = SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted); this.TypeToGenerateInOpt = service.DetermineTypeToGenerateIn(semanticModel, this.SimpleName, cancellationToken); if (this.TypeToGenerateInOpt != null) { this.NamespaceToGenerateInOpt = this.TypeToGenerateInOpt.ContainingNamespace.ToDisplayString(format); } else { var namespaceSymbol = semanticModel.GetEnclosingNamespace(this.SimpleName.SpanStart, cancellationToken); if (namespaceSymbol != null) { this.NamespaceToGenerateInOpt = namespaceSymbol.ToDisplayString(format); } } } return(true); }