public async Task <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(Solution solution, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken) { using var logger = Logger.LogBlock(FunctionId.UnusedReferences_GetUnusedReferences, message: null, cancellationToken, LogLevel.Information); var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { var result = await client.TryInvokeAsync <IRemoteUnusedReferenceAnalysisService, ImmutableArray <ReferenceInfo> >( solution, (service, solutionInfo, cancellationToken) => service.GetUnusedReferencesAsync(solutionInfo, projectFilePath, projectAssetsFilePath, projectReferences, cancellationToken), cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(ImmutableArray <ReferenceInfo> .Empty); } return(result.Value); } // Read specified references with dependency information from the project assets file. var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false); // Determine unused references var unusedReferences = await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false); // Remove dependency information before returning. return(unusedReferences.SelectAsArray(reference => reference.WithDependencies(null))); }
public ValueTask <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(PinnedSolutionInfo solutionInfo, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken) { return(RunServiceAsync(async cancellationToken => { var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false); var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false); return await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false); }, cancellationToken)); }
public ValueTask <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(PinnedSolutionInfo solutionInfo, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken) { return(RunServiceAsync(solutionInfo, async solution => { // Read specified references with dependency information from the project assets file. var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false); // Determine unused references var unusedReferences = await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false); // Remove dependency information before returning. return unusedReferences.SelectAsArray(reference => reference.WithDependencies(null)); }, cancellationToken)); }
public async Task <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(Solution solution, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken) { using var logger = Logger.LogBlock(FunctionId.UnusedReferences_GetUnusedReferences, message: null, cancellationToken, LogLevel.Information); var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { var result = await client.TryInvokeAsync <IRemoteUnusedReferenceAnalysisService, ImmutableArray <ReferenceInfo> >( solution, (service, solutionInfo, cancellationToken) => service.GetUnusedReferencesAsync(solutionInfo, projectFilePath, projectAssetsFilePath, projectReferences, cancellationToken), cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(ImmutableArray <ReferenceInfo> .Empty); } return(result.Value); } var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false); return(await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false)); }