This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
ConfigBuilder.AddJsonFile throws ArgumentOutOfRange if given an empty file #335
Closed

Description
Given the following code:
var config = new ConfigurationBuilder();
var tempFilePath = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"
var tempFile = File.Create(tempFilePath);
tempFile.Close();
config.AddJsonFile(tempFilePath);
You'll get the following exception:
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Add(IConfigurationProvider provider)
at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder, String path, Boolean optional)
at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder, String path)
Now I know that that's probably not the right way to use AddJsonFile but I would have expected a FormatException or something like that.
I'm using 1.0.0-rc2-15822, I attempted to add this as a unit test but I'm having issues with AddJsonFile being in a class that's not referenced by the unit test file I was editing.