Skip to content

Commit 992fb31

Browse files
committed
Allow trailing commas and comments.
1 parent ffa9a9b commit 992fb31

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities

src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ namespace Microsoft.Data.SqlClient.TestUtilities
1212
{
1313
public class Config
1414
{
15+
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
16+
{
17+
AllowTrailingCommas = true,
18+
ReadCommentHandling = JsonCommentHandling.Skip,
19+
};
20+
1521
public string? TCPConnectionString = null;
1622
public string? NPConnectionString = null;
1723
public string? TCPConnectionStringHGSVBS = null;
@@ -86,7 +92,7 @@ public static void UpdateConfig(Config updatedConfig, string configPath = @"conf
8692
try
8793
{
8894
using StreamReader sr = new StreamReader(configPath);
89-
return JsonSerializer.Deserialize<Config>(sr.ReadToEnd()) ??
95+
return JsonSerializer.Deserialize<Config>(sr.ReadToEnd(), JsonSerializerOptions) ??
9096
throw new InvalidOperationException($"Failed to deserialize config from '{configPath}'");
9197
}
9298
catch (FileNotFoundException)

0 commit comments

Comments
 (0)