예제 #1
0
        public async Task FindAsync(
            TextDocumentState state,
            HashSet <Checksum> searchingChecksumsLeft,
            Dictionary <Checksum, object> result,
            CancellationToken cancellationToken)
        {
            Debug.Assert(state.TryGetStateChecksums(out var stateChecksum) && this == stateChecksum);

            cancellationToken.ThrowIfCancellationRequested();

            if (searchingChecksumsLeft.Remove(Checksum))
            {
                result[Checksum] = this;
            }

            if (searchingChecksumsLeft.Remove(Info))
            {
                result[Info] = state.Attributes;
            }

            if (searchingChecksumsLeft.Remove(Text))
            {
                result[Text] = await SerializableSourceText.FromTextDocumentStateAsync(state, cancellationToken).ConfigureAwait(false);
            }
        }
예제 #2
0
        private async Task <DocumentStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.DocumentState_ComputeChecksumsAsync, FilePath, cancellationToken))
                {
                    var serializer = solutionServices.Workspace.Services.GetRequiredService <ISerializerService>();

                    var infoChecksum     = serializer.CreateChecksum(Attributes, cancellationToken);
                    var serializableText = await SerializableSourceText.FromTextDocumentStateAsync(this, cancellationToken).ConfigureAwait(false);

                    var textChecksum = serializer.CreateChecksum(serializableText, cancellationToken);

                    return(new DocumentStateChecksums(infoChecksum, textChecksum));
                }
            }
            catch (Exception e) when(FatalError.ReportWithoutCrashUnlessCanceledAndPropagate(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }