Ejemplo n.º 1
0
        internal static async Task <ConflictResolution> RenameSymbolAsync(
            Solution solution,
            ISymbol symbol,
            string newName,
            RenameOptionSet optionSet,
            ImmutableHashSet <ISymbol>?nonConflictSymbols,
            CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution);
            Contract.ThrowIfNull(symbol);
            Contract.ThrowIfTrue(string.IsNullOrEmpty(newName));

            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_RenameSymbolAsync, cancellationToken))
            {
                if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol))
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var options = SerializableRenameOptionSet.Dehydrate(optionSet);
                        var nonConflictSymbolIds = nonConflictSymbols?.SelectAsArray(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)) ?? default;

                        var result = await client.TryInvokeAsync <IRemoteRenamerService, SerializableConflictResolution?>(
                            solution,
                            (service, solutionInfo, cancellationToken) => service.RenameSymbolAsync(
                                solutionInfo,
                                serializedSymbol,
                                newName,
                                options,
                                nonConflictSymbolIds,
                                cancellationToken),
                            cancellationToken).ConfigureAwait(false);

                        if (result.HasValue && result.Value != null)
                        {
                            return(await result.Value.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false));
                        }

                        // TODO: do not fall back to in-proc if client is available (https://github.com/dotnet/roslyn/issues/47557)
                    }
                }
            }

            return(await RenameSymbolInCurrentProcessAsync(
                       solution, symbol, newName, optionSet,
                       nonConflictSymbols, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        internal static async Task <ConflictResolution> RenameSymbolAsync(
            Solution solution,
            ISymbol symbol,
            string newName,
            RenameOptionSet optionSet,
            ImmutableHashSet <ISymbol> nonConflictSymbols,
            CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution);
            Contract.ThrowIfNull(symbol);
            Contract.ThrowIfTrue(string.IsNullOrEmpty(newName));

            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_RenameSymbolAsync, cancellationToken))
            {
                var project = solution.GetOriginatingProject(symbol);
                if (project != null)
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var result = await client.TryRunRemoteAsync <SerializableConflictResolution>(
                            WellKnownServiceHubServices.CodeAnalysisService,
                            nameof(IRemoteRenamer.RenameSymbolAsync),
                            solution,
                            new object[]
                        {
                            SerializableSymbolAndProjectId.Create(symbol, project, cancellationToken),
                            newName,
                            SerializableRenameOptionSet.Dehydrate(optionSet),
                            nonConflictSymbols?.Select(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)).ToArray(),
                        },
                            callbackTarget : null,
                            cancellationToken).ConfigureAwait(false);

                        if (result.HasValue)
                        {
                            return(await result.Value.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false));
                        }
                    }
                }
            }

            return(await RenameSymbolInCurrentProcessAsync(
                       solution, symbol, newName, optionSet,
                       nonConflictSymbols, cancellationToken).ConfigureAwait(false));
        }
        internal static async Task FindReferencesAsync(
            SymbolAndProjectId symbolAndProjectId,
            Solution solution,
            IStreamingFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.FindReference, cancellationToken))
            {
                // If ProjectId is null then this is a call through our old public API.  We don't have
                // the necessary data to effectively run the call out of proc.
                if (symbolAndProjectId.ProjectId != null)
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        // Create a callback that we can pass to the server process to hear about the
                        // results as it finds them.  When we hear about results we'll forward them to
                        // the 'progress' parameter which will then update the UI.
                        var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken);

                        var success = await client.TryRunRemoteAsync(
                            WellKnownServiceHubServices.CodeAnalysisService,
                            nameof(IRemoteSymbolFinder.FindReferencesAsync),
                            solution,
                            new object[]
                        {
                            SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId),
                            documents?.Select(d => d.Id).ToArray(),
                            SerializableFindReferencesSearchOptions.Dehydrate(options),
                        },
                            serverCallback,
                            cancellationToken).ConfigureAwait(false);

                        if (success)
                        {
                            return;
                        }
                    }
                }

                // Couldn't effectively search in OOP. Perform the search in-proc.
                await FindReferencesInCurrentProcessAsync(
                    symbolAndProjectId, solution, progress,
                    documents, options, cancellationToken).ConfigureAwait(false);
            }
        }
            public async Task OnReferenceFoundAsync(
                SerializableSymbolAndProjectId definition, SerializableReferenceLocation reference)
            {
                SymbolAndProjectId symbolAndProjectId;

                lock (_gate)
                {
                    symbolAndProjectId = _definitionMap[definition];
                }

                var referenceLocation = await reference.RehydrateAsync(
                    _solution, _cancellationToken).ConfigureAwait(false);

                await _progress.OnReferenceFoundAsync(symbolAndProjectId, referenceLocation).ConfigureAwait(false);
            }
Ejemplo n.º 5
0
        public static async Task FindReferencesAsync(
            IFindUsagesContext context,
            ISymbol symbol,
            Project project,
            FindReferencesSearchOptions options
            )
        {
            var cancellationToken = context.CancellationToken;
            var solution          = project.Solution;
            var client            = await RemoteHostClient
                                    .TryGetClientAsync(solution.Workspace, cancellationToken)
                                    .ConfigureAwait(false);

            if (client != null)
            {
                // Create a callback that we can pass to the server process to hear about the
                // results as it finds them.  When we hear about results we'll forward them to
                // the 'progress' parameter which will then update the UI.
                var serverCallback     = new FindUsagesServerCallback(solution, context);
                var symbolAndProjectId = SerializableSymbolAndProjectId.Create(
                    symbol,
                    project,
                    cancellationToken
                    );

                _ = await client
                    .TryInvokeAsync <IRemoteFindUsagesService>(
                    solution,
                    (service, solutionInfo, callbackId, cancellationToken) =>
                    service.FindReferencesAsync(
                        solutionInfo,
                        callbackId,
                        symbolAndProjectId,
                        options,
                        cancellationToken
                        ),
                    serverCallback,
                    cancellationToken
                    )
                    .ConfigureAwait(false);
            }
            else
            {
                // Couldn't effectively search in OOP. Perform the search in-process.
                await FindReferencesInCurrentProcessAsync(context, symbol, project, options)
                .ConfigureAwait(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Find the locations that need to be renamed.  Can cross process boundaries efficiently to do this.
        /// </summary>
        public static async Task <LightweightRenameLocations> FindRenameLocationsAsync(
            ISymbol symbol, Solution solution, SymbolRenameOptions options, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution);
            Contract.ThrowIfNull(symbol);

            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
            {
                if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol))
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var result = await client.TryInvokeAsync <IRemoteRenamerService, SerializableRenameLocations?>(
                            solution,
                            (service, solutionInfo, callbackId, cancellationToken) => service.FindRenameLocationsAsync(solutionInfo, callbackId, serializedSymbol, options, cancellationToken),
                            callbackTarget : new RemoteOptionsProvider <CodeCleanupOptions>(solution.Workspace.Services, fallbackOptions),
                            cancellationToken).ConfigureAwait(false);

                        if (result.HasValue && result.Value != null)
                        {
                            var rehydrated = await TryRehydrateAsync(
                                solution, symbol, fallbackOptions, result.Value, cancellationToken).ConfigureAwait(false);

                            if (rehydrated != null)
                            {
                                return(rehydrated);
                            }
                        }

                        // TODO: do not fall back to in-proc if client is available (https://github.com/dotnet/roslyn/issues/47557)
                    }
                }
            }

            // Couldn't effectively search in OOP. Perform the search in-proc.
            var renameLocations = await HeavyweightRenameLocations.FindLocationsInCurrentProcessAsync(
                symbol, solution, options, fallbackOptions, cancellationToken).ConfigureAwait(false);

            return(new LightweightRenameLocations(
                       symbol, solution, options, fallbackOptions, renameLocations.Locations,
                       renameLocations.ImplicitLocations.IsDefault ? null : renameLocations.ImplicitLocations.Select(loc => SerializableReferenceLocation.Dehydrate(loc, cancellationToken)).ToArray(),
                       renameLocations.ReferencedSymbols.IsDefault ? null : renameLocations.ReferencedSymbols.Select(sym => SerializableSymbolAndProjectId.Dehydrate(solution, sym, cancellationToken)).ToArray()));
        }
            public async Task OnDefinitionFoundAsync(SerializableSymbolAndProjectId definition)
            {
                var symbolAndProjectId = await definition.TryRehydrateAsync(
                    _solution, _cancellationToken).ConfigureAwait(false);

                if (!symbolAndProjectId.HasValue)
                {
                    return;
                }

                lock (_gate)
                {
                    _definitionMap[definition] = symbolAndProjectId.Value;
                }

                await _progress.OnDefinitionFoundAsync(symbolAndProjectId.Value).ConfigureAwait(false);
            }
        internal static async Task FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            IStreamingFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);

            using (Logger.LogBlock(FunctionId.FindReference, cancellationToken))
            {
                var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                if (client != null)
                {
                    // Create a callback that we can pass to the server process to hear about the
                    // results as it finds them.  When we hear about results we'll forward them to
                    // the 'progress' parameter which will then update the UI.
                    var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken);

                    var success = await client.TryRunRemoteAsync(
                        WellKnownServiceHubServices.CodeAnalysisService,
                        nameof(IRemoteSymbolFinder.FindReferencesAsync),
                        solution,
                        new object[]
                    {
                        SerializableSymbolAndProjectId.Dehydrate(solution, symbol, cancellationToken),
                        documents?.Select(d => d.Id).ToArray(),
                        SerializableFindReferencesSearchOptions.Dehydrate(options),
                    },
                        serverCallback,
                        cancellationToken).ConfigureAwait(false);

                    if (success)
                    {
                        return;
                    }
                }

                // Couldn't effectively search in OOP. Perform the search in-proc.
                await FindReferencesInCurrentProcessAsync(
                    symbol, solution, progress,
                    documents, options, cancellationToken).ConfigureAwait(false);
            }
        }
        public async Task FindReferencesAsync(
            SerializableSymbolAndProjectId symbolAndProjectIdArg, SerializableDocumentId[] documentArgs, 
            byte[] solutionChecksum)
        {
            var solution = await RoslynServices.SolutionService.GetSolutionAsync(
                new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);

            var symbolAndProjectId = await symbolAndProjectIdArg.RehydrateAsync(
                solution, CancellationToken).ConfigureAwait(false);
            var documents = documentArgs?.Select(a => a.Rehydrate())
                                         .Select(solution.GetDocument)
                                         .ToImmutableHashSet();

            var progressCallback = new ProgressCallback(this);
            await DefaultSymbolFinderEngineService.FindReferencesInCurrentProcessAsync(
                symbolAndProjectId, solution, progressCallback, documents, CancellationToken).ConfigureAwait(false);
        }
Ejemplo n.º 10
0
        public static async Task <RenameLocations> FindLocationsAsync(
            ISymbol symbol, Solution solution, RenameOptionSet optionSet, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution);
            Contract.ThrowIfNull(symbol);

            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
            {
                if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol))
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var result = await client.RunRemoteAsync <SerializableRenameLocations?>(
                            WellKnownServiceHubService.CodeAnalysis,
                            nameof(IRemoteRenamer.FindRenameLocationsAsync),
                            solution,
                            new object[]
                        {
                            serializedSymbol,
                            SerializableRenameOptionSet.Dehydrate(optionSet),
                        },
                            callbackTarget : null,
                            cancellationToken).ConfigureAwait(false);

                        if (result != null)
                        {
                            var rehydrated = await RenameLocations.TryRehydrateAsync(
                                solution, result, cancellationToken).ConfigureAwait(false);

                            if (rehydrated != null)
                            {
                                return(rehydrated);
                            }
                        }
                    }
                }
            }

            // Couldn't effectively search in OOP. Perform the search in-proc.
            return(await FindLocationsInCurrentProcessAsync(
                       symbol, solution, optionSet, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Find the locations that need to be renamed.
        /// </summary>
        public static async Task <RenameLocations> FindLocationsAsync(
            ISymbol symbol, Solution solution, RenameOptionSet optionSet, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution);
            Contract.ThrowIfNull(symbol);

            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
            {
                if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol))
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var options = SerializableRenameOptionSet.Dehydrate(optionSet);

                        var result = await client.TryInvokeAsync <IRemoteRenamerService, SerializableRenameLocations?>(
                            solution,
                            (service, solutionInfo, cancellationToken) => service.FindRenameLocationsAsync(solutionInfo, serializedSymbol, options, cancellationToken),
                            callbackTarget : null,
                            cancellationToken).ConfigureAwait(false);

                        if (result.HasValue && result.Value != null)
                        {
                            var rehydrated = await TryRehydrateAsync(
                                solution, result.Value, cancellationToken).ConfigureAwait(false);

                            if (rehydrated != null)
                            {
                                return(rehydrated);
                            }
                        }

                        // TODO: do not fall back to in-proc if client is available (https://github.com/dotnet/roslyn/issues/47557)
                    }
                }
            }

            // Couldn't effectively search in OOP. Perform the search in-proc.
            return(await FindLocationsInCurrentProcessAsync(
                       symbol, solution, optionSet, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 12
0
        public static async Task <ImmutableArray <INamedTypeSymbol>?> TryFindRemoteTypesAsync(
            INamedTypeSymbol type,
            Solution solution,
            IImmutableSet <Project> projects,
            bool transitive,
            FunctionId functionId,
            string remoteFunctionName,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(functionId, cancellationToken))
            {
                var project = solution.GetOriginatingProject(type);
                if (project != null)
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        var result = await client.TryRunRemoteAsync <ImmutableArray <SerializableSymbolAndProjectId> >(
                            WellKnownServiceHubService.CodeAnalysis,
                            remoteFunctionName,
                            solution,
                            new object?[]
                        {
                            SerializableSymbolAndProjectId.Create(type, project, cancellationToken),
                            projects?.Select(p => p.Id).ToArray(),
                            transitive,
                        },
                            null,
                            cancellationToken).ConfigureAwait(false);

                        if (result.HasValue)
                        {
                            return(await RehydrateAsync(solution, result.Value, cancellationToken).ConfigureAwait(false));
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 13
0
        public static async Task FindReferencesAsync(
            IFindUsagesContext context,
            ISymbol symbol,
            Project project,
            FindReferencesSearchOptions options)
        {
            var cancellationToken = context.CancellationToken;
            var solution          = project.Solution;
            var client            = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

            if (client != null)
            {
                // Create a callback that we can pass to the server process to hear about the
                // results as it finds them.  When we hear about results we'll forward them to
                // the 'progress' parameter which will then update the UI.
                var serverCallback = new FindUsagesServerCallback(solution, context);

                var success = await client.TryRunRemoteAsync(
                    WellKnownServiceHubService.CodeAnalysis,
                    nameof(IRemoteFindUsagesService.FindReferencesAsync),
                    solution,
                    new object[]
                {
                    SerializableSymbolAndProjectId.Create(symbol, project, cancellationToken),
                    SerializableFindReferencesSearchOptions.Dehydrate(options),
                },
                    serverCallback,
                    cancellationToken).ConfigureAwait(false);

                if (success)
                {
                    return;
                }
            }

            // Couldn't effectively search in OOP. Perform the search in-process.
            await FindReferencesInCurrentProcessAsync(
                context, symbol, project, options).ConfigureAwait(false);
        }
Ejemplo n.º 14
0
        internal static async Task <ConflictResolution> ResolveConflictsAsync(
            RenameLocations renameLocationSet,
            string replacementText,
            ImmutableHashSet <ISymbol> nonConflictSymbols,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
            {
                var solution = renameLocationSet.Solution;
                var client   = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                if (client != null)
                {
                    var result = await client.TryRunRemoteAsync <SerializableConflictResolution>(
                        WellKnownServiceHubServices.CodeAnalysisService,
                        nameof(IRemoteRenamer.ResolveConflictsAsync),
                        solution,
                        new object[]
                    {
                        renameLocationSet.Dehydrate(solution, cancellationToken),
                        replacementText,
                        nonConflictSymbols?.Select(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)).ToArray(),
                    },
                        callbackTarget : null,
                        cancellationToken).ConfigureAwait(false);

                    if (result.HasValue)
                    {
                        return(await result.Value.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false));
                    }
                }
            }

            return(await ResolveConflictsInCurrentProcessAsync(
                       renameLocationSet, replacementText, nonConflictSymbols, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 15
0
        internal static async Task FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            IStreamingFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.FindReference, cancellationToken))
            {
                if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol))
                {
                    var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                    if (client != null)
                    {
                        // Create a callback that we can pass to the server process to hear about the
                        // results as it finds them.  When we hear about results we'll forward them to
                        // the 'progress' parameter which will then update the UI.
                        var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken);
                        var documentIds    = documents?.SelectAsArray(d => d.Id) ?? default;

                        await client.TryInvokeAsync <IRemoteSymbolFinderService>(
                            solution,
                            (service, solutionInfo, callbackId, cancellationToken) => service.FindReferencesAsync(solutionInfo, callbackId, serializedSymbol, documentIds, options, cancellationToken),
                            serverCallback,
                            cancellationToken).ConfigureAwait(false);

                        return;
                    }
                }

                // Couldn't effectively search in OOP. Perform the search in-proc.
                await FindReferencesInCurrentProcessAsync(
                    symbol, solution, progress,
                    documents, options, cancellationToken).ConfigureAwait(false);
            }
        }
Ejemplo n.º 16
0
 bool IEqualityComparer <SerializableSymbolAndProjectId> .Equals(SerializableSymbolAndProjectId x, SerializableSymbolAndProjectId y)
 => y.SymbolKeyData.Equals(x.SymbolKeyData);
Ejemplo n.º 17
0
        internal static async Task <ConflictResolution> ResolveConflictsAsync(
            RenameLocations renameLocationSet,
            string replacementText,
            ImmutableHashSet <ISymbol>?nonConflictSymbols,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
            {
                var solution = renameLocationSet.Solution;
                var client   = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);

                if (client != null)
                {
                    var serializableLocationSet = renameLocationSet.Dehydrate(solution, cancellationToken);
                    var nonConflictSymbolIds    = nonConflictSymbols?.SelectAsArray(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)) ?? default;

                    var result = await client.TryInvokeAsync <IRemoteRenamerService, SerializableConflictResolution?>(
                        solution,
                        (service, solutionInfo, cancellationToken) => service.ResolveConflictsAsync(solutionInfo, serializableLocationSet, replacementText, nonConflictSymbolIds, cancellationToken),
                        callbackTarget : null,
                        cancellationToken).ConfigureAwait(false);

                    if (result.HasValue && result.Value != null)
                    {
                        return(await result.Value.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false));
                    }

                    // TODO: do not fall back to in-proc if client is available (https://github.com/dotnet/roslyn/issues/47557)
                }
            }

            return(await ResolveConflictsInCurrentProcessAsync(
                       renameLocationSet, replacementText, nonConflictSymbols, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 18
0
 public ValueTask OnDefinitionFoundAsync(RemoteServiceCallbackId callbackId, SerializableSymbolAndProjectId definition)
 => GetFindReferencesCallback(callbackId).OnDefinitionFoundAsync(definition);
Ejemplo n.º 19
0
        public static async Task <ImmutableArray <INamedTypeSymbol> > FindTypesAsync(
            INamedTypeSymbol type,
            Solution solution,
            IImmutableSet <Project>?projects,
            bool transitive,
            DependentTypesKind kind,
            CancellationToken cancellationToken
            )
        {
            if (
                SerializableSymbolAndProjectId.TryCreate(
                    type,
                    solution,
                    cancellationToken,
                    out var serializedType
                    )
                )
            {
                var client = await RemoteHostClient
                             .TryGetClientAsync(solution.Workspace, cancellationToken)
                             .ConfigureAwait(false);

                if (client != null)
                {
                    var projectIds = projects?.SelectAsArray(p => p.Id) ?? default;

                    var result = await client
                                 .TryInvokeAsync <
                        IRemoteDependentTypeFinderService,
                        ImmutableArray <SerializableSymbolAndProjectId>
                        >(
                        solution,
                        (service, solutionInfo, cancellationToken) =>
                        service.FindTypesAsync(
                            solutionInfo,
                            serializedType,
                            projectIds,
                            transitive,
                            kind,
                            cancellationToken
                            ),
                        cancellationToken
                        )
                                 .ConfigureAwait(false);

                    if (!result.HasValue)
                    {
                        return(ImmutableArray <INamedTypeSymbol> .Empty);
                    }

                    return(await RehydrateAsync(solution, result.Value, cancellationToken)
                           .ConfigureAwait(false));
                }
                // TODO: Do not fall back to in-proc https://github.com/dotnet/roslyn/issues/47557
            }

            return(await FindTypesInCurrentProcessAsync(
                       type,
                       solution,
                       projects,
                       transitive,
                       kind,
                       cancellationToken
                       )
                   .ConfigureAwait(false));
        }
Ejemplo n.º 20
0
 public static SerializableSearchResult Dehydrate(Solution solution, RenameLocations.SearchResult result, CancellationToken cancellationToken)
 => result == null ? null : new SerializableSearchResult
 {
     Locations         = result.Locations?.Select(loc => SerializableRenameLocation.Dehydrate(loc)).ToArray(),
     ImplicitLocations = result.ImplicitLocations.IsDefault ? null : result.ImplicitLocations.Select(loc => SerializableReferenceLocation.Dehydrate(loc, cancellationToken)).ToArray(),
     ReferencedSymbols = result.ReferencedSymbols.IsDefault ? null : result.ReferencedSymbols.Select(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)).ToArray(),
 };
Ejemplo n.º 21
0
 public ValueTask OnDefinitionFoundAsync(SerializableSymbolAndProjectId definition)
 => throw ExceptionUtilities.Unreachable;
Ejemplo n.º 22
0
 int IEqualityComparer <SerializableSymbolAndProjectId> .GetHashCode(SerializableSymbolAndProjectId obj)
 => obj.SymbolKeyData.GetHashCode();
Ejemplo n.º 23
0
 public ValueTask OnReferenceFoundAsync(SerializableSymbolAndProjectId definition, SerializableReferenceLocation reference)
 => throw ExceptionUtilities.Unreachable;
Ejemplo n.º 24
0
 public ValueTask OnReferenceFoundAsync(RemoteServiceCallbackId callbackId, SerializableSymbolGroup symbolGroup, SerializableSymbolAndProjectId definition, SerializableReferenceLocation reference)
 => GetFindReferencesCallback(callbackId).OnReferenceFoundAsync(symbolGroup, definition, reference);
Ejemplo n.º 25
0
 public SerializableRenameLocations Dehydrate(Solution solution, CancellationToken cancellationToken)
 => new SerializableRenameLocations(
     SerializableSymbolAndProjectId.Dehydrate(solution, Symbol, cancellationToken),
     SerializableRenameOptionSet.Dehydrate(Options),
     SerializableSearchResult.Dehydrate(solution, _result, cancellationToken));