From 576c426f433ee6fee20fdbb86388a8fd1b92de64 Mon Sep 17 00:00:00 2001 From: Emmanuel ANDRE <2341261+manandre@users.noreply.github.com> Date: Sat, 30 Mar 2024 21:15:59 +0100 Subject: [PATCH] Remove duplicate assignments --- .../Converters/Collection/DictionaryDefaultConverter.cs | 2 -- .../Collection/DictionaryOfTKeyTValueConverter.cs | 6 ++---- .../Converters/Collection/IDictionaryConverter.cs | 2 -- .../Converters/Collection/IEnumerableConverter.cs | 2 -- .../Converters/Collection/IEnumerableDefaultConverter.cs | 2 -- .../Converters/Collection/StackOrQueueConverter.cs | 2 -- 6 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryDefaultConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryDefaultConverter.cs index 73b7124e97af1..05929fbe9fd20 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryDefaultConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryDefaultConverter.cs @@ -48,7 +48,6 @@ protected internal override bool OnWriteResume( { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } @@ -62,7 +61,6 @@ protected internal override bool OnWriteResume( TValue element = enumerator.Current.Value; if (!_valueConverter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryOfTKeyTValueConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryOfTKeyTValueConverter.cs index d3f804a4a0f16..d232f73ee3a9f 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryOfTKeyTValueConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/DictionaryOfTKeyTValueConverter.cs @@ -28,7 +28,7 @@ protected internal override bool OnWriteResume( JsonSerializerOptions options, ref WriteStack state) { - Dictionary.Enumerator enumerator; + IEnumerator> enumerator; if (state.Current.CollectionEnumerator == null) { enumerator = value.GetEnumerator(); @@ -41,7 +41,7 @@ protected internal override bool OnWriteResume( } else { - enumerator = (Dictionary.Enumerator)state.Current.CollectionEnumerator; + enumerator = (IEnumerator>)state.Current.CollectionEnumerator; } JsonTypeInfo typeInfo = state.Current.JsonTypeInfo; @@ -64,7 +64,6 @@ protected internal override bool OnWriteResume( { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } @@ -79,7 +78,6 @@ protected internal override bool OnWriteResume( TValue element = enumerator.Current.Value; if (!_valueConverter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IDictionaryConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IDictionaryConverter.cs index 74c150e0f9014..d109b254659f0 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IDictionaryConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IDictionaryConverter.cs @@ -63,7 +63,6 @@ protected internal override bool OnWriteResume(Utf8JsonWriter writer, TDictionar { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } @@ -88,7 +87,6 @@ protected internal override bool OnWriteResume(Utf8JsonWriter writer, TDictionar object? element = enumerator.Value; if (!_valueConverter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverter.cs index f7fd18f1c4b59..7fa9130e6557b 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverter.cs @@ -62,14 +62,12 @@ protected override bool OnWriteResume( { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } object? element = enumerator.Current; if (!converter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableDefaultConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableDefaultConverter.cs index 19002355cc25d..b8b7a4661e51e 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableDefaultConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableDefaultConverter.cs @@ -40,14 +40,12 @@ protected override bool OnWriteResume(Utf8JsonWriter writer, TCollection value, { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } TElement element = enumerator.Current; if (!converter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/StackOrQueueConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/StackOrQueueConverter.cs index 8540d7ea1aa5e..cfa54f31882e0 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/StackOrQueueConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/StackOrQueueConverter.cs @@ -62,14 +62,12 @@ protected sealed override bool OnWriteResume(Utf8JsonWriter writer, TCollection { if (ShouldFlush(writer, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; } object? element = enumerator.Current; if (!converter.TryWrite(writer, element, options, ref state)) { - state.Current.CollectionEnumerator = enumerator; return false; }