コード例 #1
0
            private async Task <IList <SymbolReference> > GetNamespacesForQueryPatternsAsync(SearchScope searchScope)
            {
                if (!_owner.CanAddImportForQuery(_diagnostic, ref _node))
                {
                    return(null);
                }

                ITypeSymbol type = _owner.GetQueryClauseInfo(_semanticModel, _node, _cancellationToken);

                if (type == null)
                {
                    return(null);
                }

                // find extension methods named "Select"
                var symbols = await searchScope.FindDeclarationsAsync("Select", SymbolFilter.Member).ConfigureAwait(false);

                var extensionMethodSymbols = symbols
                                             .OfType <IMethodSymbol>()
                                             .Where(s => s.IsExtensionMethod && _owner.IsViableExtensionMethod(type, s))
                                             .ToList();

                return(GetProposedNamespaces(
                           searchScope, extensionMethodSymbols.Select(s => s.ContainingNamespace)));
            }
            private async Task <IList <SymbolReference> > GetNamespacesForQueryPatternsAsync(SearchScope searchScope)
            {
                searchScope.CancellationToken.ThrowIfCancellationRequested();

                if (!_owner.CanAddImportForQuery(_diagnostic, _node))
                {
                    return(null);
                }

                ITypeSymbol type = _owner.GetQueryClauseInfo(_semanticModel, _node, searchScope.CancellationToken);

                if (type == null)
                {
                    return(null);
                }

                // find extension methods named "Select"
                var symbols = await searchScope.FindDeclarationsAsync("Select", nameNode : null, filter : SymbolFilter.Member).ConfigureAwait(false);

                // Note: there is no "desiredName" when doing this.  We're not going to do any
                // renames of the user code.  We're just looking for an extension method called
                // "Select", but that name has no bearing on the code in question that we're
                // trying to fix up.
                var extensionMethodSymbols = OfType <IMethodSymbol>(symbols)
                                             .Where(s => s.Symbol.IsExtensionMethod && _owner.IsViableExtensionMethod(s.Symbol, type))
                                             .Select(s => s.WithDesiredName(null))
                                             .ToList();

                return(GetProposedNamespaces(
                           searchScope, extensionMethodSymbols.Select(s => s.WithSymbol(s.Symbol.ContainingNamespace))));
            }
コード例 #3
0
 private ImmutableArray <SymbolResult <IMethodSymbol> > GetViableExtensionMethods(
     ImmutableArray <SymbolResult <IMethodSymbol> > methodSymbols,
     SyntaxNode expression, CancellationToken cancellationToken)
 {
     return(GetViableExtensionMethodsWorker(methodSymbols, cancellationToken).WhereAsArray(
                s => _owner.IsViableExtensionMethod(s.Symbol, expression, _semanticModel, _syntaxFacts, cancellationToken)));
 }