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)); }
private ImmutableArray <ReferenceUpdate> GetUnusedReferencesForProject(Project project, string projectAssetsFile, string targetFrameworkMoniker, CancellationToken cancellationToken) { ImmutableArray <ReferenceInfo> unusedReferences = ThreadHelper.JoinableTaskFactory.Run(async() => { var projectReferences = await _lazyReferenceCleanupService.Value.GetProjectReferencesAsync(project.FilePath !, cancellationToken).ConfigureAwait(true); var references = ProjectAssetsReader.ReadReferences(projectReferences, projectAssetsFile, targetFrameworkMoniker); return(await UnusedReferencesRemover.GetUnusedReferencesAsync(project, references, cancellationToken).ConfigureAwait(true)); }); var referenceUpdates = unusedReferences .Select(reference => new ReferenceUpdate(reference.TreatAsUsed ? UpdateAction.TreatAsUsed : UpdateAction.Remove, reference)) .ToImmutableArray(); return(referenceUpdates); }