예제 #1
0
        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);

                var infoChecksum = serializer.CreateChecksum(ProjectInfo.Attributes, cancellationToken);

                // these compiler objects doesn't have good place to cache checksum. but rarely ever get changed.
                var compilationOptionsChecksum = SupportsCompilation ? ChecksumCache.GetOrCreate(CompilationOptions, _ => serializer.CreateChecksum(CompilationOptions, cancellationToken)) : Checksum.Null;
                var parseOptionsChecksum       = SupportsCompilation ? ChecksumCache.GetOrCreate(ParseOptions, _ => serializer.CreateChecksum(ParseOptions, cancellationToken)) : Checksum.Null;

                var projectReferenceChecksums  = ChecksumCache.GetOrCreate <ProjectReferenceChecksumCollection>(ProjectReferences, _ => new ProjectReferenceChecksumCollection(ProjectReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));
                var metadataReferenceChecksums = ChecksumCache.GetOrCreate <MetadataReferenceChecksumCollection>(MetadataReferences, _ => new MetadataReferenceChecksumCollection(MetadataReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));
                var analyzerReferenceChecksums = ChecksumCache.GetOrCreate <AnalyzerReferenceChecksumCollection>(AnalyzerReferences, _ => 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)));
            }
        }
예제 #2
0
        public Task ExecuteAsync(DbConnection connection, DbTransaction transaction, ISqlDialect dialect, ILogger logger)
        {
            var command = "delete from " + dialect.QuoteForTableName(_tablePrefix + IndexType.Name) + " where " + dialect.QuoteForColumnName("DocumentId") + " = @Id";

            logger.LogTrace(command);
            return(connection.ExecuteAsync(command, DocumentIds.Select(x => new { Id = x }), transaction));
        }
예제 #3
0
        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(new SerializedProjectInfo(Id, Version, Name, AssemblyName, Language, FilePath, OutputFilePath, IsSubmission), 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)));
            }
        }
        public virtual Task <IList <IndexDocumentChange> > GetChangesAsync(DateTime?startDate, DateTime?endDate, long skip, long take)
        {
            IList <IndexDocumentChange> result;

            if (startDate == null && endDate == null)
            {
                result = DocumentIds.Select(id => new IndexDocumentChange
                {
                    DocumentId = id,
                    ChangeType = IndexDocumentChangeType.Modified,
                    ChangeDate = DateTime.UtcNow
                })
                         .Skip((int)skip)
                         .Take((int)take)
                         .ToArray();
            }
            else
            {
                var changes = GetChangesQuery(startDate, endDate);
                result = changes.Skip((int)skip).Take((int)take).ToArray();
            }
            return(Task.FromResult(result));
        }