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), 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 RenameSymbolInCurrentProcessAsync( solution, symbol, newName, optionSet, nonConflictSymbols, cancellationToken).ConfigureAwait(false)); }
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)); }