private async Task<ProjectStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.ProjectState_ComputeChecksumsAsync, FilePath, cancellationToken)) { // get states by id order to have deterministic checksum var documentChecksumsTasks = DocumentIds.Select(id => DocumentStates[id].GetChecksumAsync(cancellationToken)); var additionalDocumentChecksumTasks = AdditionalDocumentIds.Select(id => AdditionalDocumentStates[id].GetChecksumAsync(cancellationToken)); var serializer = new Serializer(_solutionServices.Workspace.Services); var infoChecksum = serializer.CreateChecksum(ProjectInfo.Attributes, cancellationToken); var compilationOptionsChecksum = SupportsCompilation ? serializer.CreateChecksum(CompilationOptions, cancellationToken) : Checksum.Null; var parseOptionsChecksum = SupportsCompilation ? serializer.CreateChecksum(ParseOptions, cancellationToken) : Checksum.Null; var projectReferenceChecksums = new ProjectReferenceChecksumCollection(ProjectReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()); var metadataReferenceChecksums = new MetadataReferenceChecksumCollection(MetadataReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()); var analyzerReferenceChecksums = new AnalyzerReferenceChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()); var documentChecksums = await Task.WhenAll(documentChecksumsTasks).ConfigureAwait(false); var additionalChecksums = await Task.WhenAll(additionalDocumentChecksumTasks).ConfigureAwait(false); return new ProjectStateChecksums( infoChecksum, compilationOptionsChecksum, parseOptionsChecksum, new DocumentChecksumCollection(documentChecksums), projectReferenceChecksums, metadataReferenceChecksums, analyzerReferenceChecksums, new TextDocumentChecksumCollection(additionalChecksums)); } }
private async Task<DocumentStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.DocumentState_ComputeChecksumsAsync, FilePath, cancellationToken)) { var textTask = GetTextAsync(cancellationToken); var serializer = new Serializer(solutionServices.Workspace); var infoChecksum = serializer.CreateChecksum(Info.Attributes, cancellationToken); var textChecksum = serializer.CreateChecksum(await textTask.ConfigureAwait(false), cancellationToken); return new DocumentStateChecksums(infoChecksum, textChecksum); } }
private async Task<SolutionStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken)) { // get states by id order to have deterministic checksum var projectChecksumTasks = ProjectIds.Select(id => ProjectStates[id].GetChecksumAsync(cancellationToken)); var serializer = new Serializer(_solutionServices.Workspace); var infoChecksum = serializer.CreateChecksum(SolutionInfo.Attributes, cancellationToken); var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false); return new SolutionStateChecksums(infoChecksum, new ProjectChecksumCollection(projectChecksums)); } }