File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
src/Tools/src/ConfigurationSchemaGenerator Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -721,18 +721,13 @@ private static string[] CreateExclusionPaths(List<string>? exclusionPaths)
721721
722722 private static void ReplaceNodeWithKeyCasingChange ( JsonObject jsonObject , string key , JsonNode value )
723723 {
724- // In System.Text.Json v9, the casing of the new key is not adapted. See https://github.com/dotnet/runtime/issues/108790.
725- // So instead, remove the existing node and insert a new one with the updated key.
726- var index = jsonObject . IndexOf ( key ) ;
727- if ( index != - 1 )
724+ if ( ! jsonObject . TryAdd ( key , value , out var index ) )
728725 {
726+ // Starting from System.Text.Json v9, the casing of the new key is not adapted. See https://github.com/dotnet/runtime/issues/108790.
727+ // So instead, remove the existing node and insert a new one with the updated key.
729728 jsonObject . RemoveAt ( index ) ;
730729 jsonObject . Insert ( index , key , value ) ;
731730 }
732- else
733- {
734- jsonObject [ key ] = value ;
735- }
736731 }
737732
738733 private sealed class SchemaOrderJsonNodeConverter : JsonConverter < JsonNode >
You can’t perform that action at this time.
0 commit comments