fix file not closed (#571)

This commit is contained in:
Boshi Lian
2021-02-24 21:35:24 -08:00
committed by GitHub
parent a5614df8bc
commit b282b9571b

View File

@@ -56,6 +56,8 @@ namespace k8s
/// <summary>
/// Load a collection of objects from a stream asynchronously
///
/// caller is responsible for closing the stream
/// </summary>
/// <param name="stream">
/// The stream to load the objects from.
@@ -80,9 +82,11 @@ namespace k8s
/// <returns>collection of objects</returns>
public static Task<List<object>> LoadAllFromFileAsync(string fileName, Dictionary<string, Type> typeMap)
{
var reader = File.OpenRead(fileName);
using (var reader = File.OpenRead(fileName))
{
return LoadAllFromStreamAsync(reader, typeMap);
}
}
/// <summary>
/// Load a collection of objects from a string