@@ -8,19 +8,21 @@ namespace AggregateConfigBuildTask.FileHandlers
88{
99 public class ArmParametersFileHandler : IOutputWriter , IInputReader
1010 {
11- readonly IFileSystem fileSystem ;
11+ private readonly IFileSystem fileSystem ;
12+
13+ private readonly JsonSerializerOptions jsonOptions = new JsonSerializerOptions { WriteIndented = true } ;
1214
1315 internal ArmParametersFileHandler ( IFileSystem fileSystem )
1416 {
1517 this . fileSystem = fileSystem ;
1618 }
1719
1820 /// <inheritdoc/>
19- public ValueTask < JsonElement > ReadInput ( string inputPath )
21+ public async ValueTask < JsonElement > ReadInput ( string inputPath )
2022 {
2123 using ( var stream = fileSystem . OpenRead ( inputPath ) )
2224 {
23- using ( var jsonDoc = JsonDocument . Parse ( stream ) )
25+ using ( var jsonDoc = await JsonDocument . ParseAsync ( stream ) . ConfigureAwait ( false ) )
2426 {
2527 if ( jsonDoc . RootElement . TryGetProperty ( "parameters" , out JsonElement parameters ) )
2628 {
@@ -41,10 +43,10 @@ public ValueTask<JsonElement> ReadInput(string inputPath)
4143 }
4244
4345 var modifiedJson = modifiedParameters . ToJsonString ( ) ;
44- return new ValueTask < JsonElement > ( Task . FromResult ( JsonSerializer . Deserialize < JsonElement > ( modifiedJson ) ) ) ;
46+ return JsonSerializer . Deserialize < JsonElement > ( modifiedJson ) ;
4547 }
4648
47- return new ValueTask < JsonElement > ( Task . FromResult ( jsonDoc . RootElement . Clone ( ) ) ) ;
49+ return jsonDoc . RootElement . Clone ( ) ;
4850 }
4951 }
5052 }
@@ -74,8 +76,6 @@ public void WriteOutput(JsonElement? mergedData, string outputPath)
7476 [ "contentVersion" ] = "1.0.0.0" ,
7577 [ "parameters" ] = parameters
7678 } ;
77-
78- var jsonOptions = new JsonSerializerOptions { WriteIndented = true } ;
7979 var jsonContent = JsonSerializer . Serialize ( armTemplate , jsonOptions ) ;
8080 fileSystem . WriteAllText ( outputPath , jsonContent ) ;
8181 }
@@ -90,7 +90,7 @@ public void WriteOutput(JsonElement? mergedData, string outputPath)
9090 /// </summary>
9191 /// <param name="value">The JsonElement value to evaluate.</param>
9292 /// <returns>A string representing the ARM template parameter type.</returns>
93- private string GetParameterType ( JsonElement value )
93+ private static string GetParameterType ( JsonElement value )
9494 {
9595 switch ( value . ValueKind )
9696 {
@@ -115,7 +115,7 @@ private string GetParameterType(JsonElement value)
115115 }
116116 }
117117
118- private JsonNode ConvertElementToNode ( JsonElement element )
118+ private static JsonNode ConvertElementToNode ( JsonElement element )
119119 {
120120 // Use GetRawText to get the JSON string representation of the JsonElement
121121 var jsonString = element . GetRawText ( ) ;
0 commit comments