Пример #1
0
        public static async Task <SyntaxTreeIndex?> LoadAsync(
            IChecksummedPersistentStorageService storageService, DocumentKey documentKey, Checksum?checksum, StringTable stringTable, CancellationToken cancellationToken)
        {
            try
            {
                var storage = await storageService.GetStorageAsync(documentKey.Project.Solution, cancellationToken).ConfigureAwait(false);

                await using var _ = storage.ConfigureAwait(false);

                // attempt to load from persisted state
                using var stream = await storage.ReadStreamAsync(documentKey, PersistenceName, checksum, cancellationToken).ConfigureAwait(false);

                using var reader = ObjectReader.TryGetReader(stream, cancellationToken: cancellationToken);
                if (reader != null)
                {
                    return(ReadFrom(stringTable, reader, checksum));
                }
            }
            catch (Exception e) when(IOUtilities.IsNormalIOException(e))
            {
                // Storage APIs can throw arbitrary exceptions.
            }

            return(null);
        }
Пример #2
0
 public static Task <TopLevelSyntaxTreeIndex?> LoadAsync(
     IChecksummedPersistentStorageService storageService, DocumentKey documentKey, Checksum?checksum, StringTable stringTable, CancellationToken cancellationToken)
 {
     return(LoadAsync(storageService, documentKey, checksum, stringTable, ReadIndex, cancellationToken));
 }