Skip to content

Commit bc747ed

Browse files
author
Andrew Nielsen
committed
FileCache.InitializeTypeAsync(Stream...) should not return null. It should return Task.FromResult<StorageFile>(null). Otherwise, CacheBase attempts to dereference the Task to call ConfigureAwait(false) which results in a NullReferenceException.
1 parent 7eb9c0b commit bc747ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Microsoft.Toolkit.Uwp.UI/Cache/FileCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class FileCache : CacheBase<StorageFile>
3434
protected override Task<StorageFile> InitializeTypeAsync(Stream stream, List<KeyValuePair<string, object>> initializerKeyValues = null)
3535
{
3636
// nothing to do in this instance;
37-
return null;
37+
return Task.FromResult<StorageFile>(null);
3838
}
3939

4040
/// <summary>
@@ -45,7 +45,7 @@ protected override Task<StorageFile> InitializeTypeAsync(Stream stream, List<Key
4545
/// <returns>awaitable task</returns>
4646
protected override Task<StorageFile> InitializeTypeAsync(StorageFile baseFile, List<KeyValuePair<string, object>> initializerKeyValues = null)
4747
{
48-
return Task.Run(() => baseFile);
48+
return Task.FromResult(baseFile);
4949
}
5050
}
5151
}

0 commit comments

Comments
 (0)