Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Do not use DictionaryKeyPolicy on deserialization #39392

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

layomia
Copy link
Contributor

@layomia layomia commented Jul 11, 2019

@layomia layomia added this to the 3.0 milestone Jul 11, 2019
@layomia layomia requested a review from steveharter July 11, 2019 15:24
@layomia layomia self-assigned this Jul 11, 2019

Assert.Equal(2, obj[1].Count);
Assert.Equal(3, obj[1]["Key1"]);
Assert.Equal(4, obj[1]["Key2"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the serialize case to make sure Key1->key1 when the policy is applied.

Copy link
Contributor Author

@layomia layomia Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's here -

.

@ericstj
Copy link
Member

ericstj commented Jul 12, 2019

Can you update the docs to indicate that the policy is ignored on deserialization:

/// <summary>
/// Specifies the policy used to convert a <see cref="System.Collections.IDictionary"/> key's name to another format, such as camel-casing.
/// </summary>
/// <remarks>
/// This property can be set to <see cref="JsonNamingPolicy.CamelCase"/> to specify a camel-casing policy.
/// </remarks>

Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo a doc update.

@ericstj
Copy link
Member

ericstj commented Jul 12, 2019

@ericstj ericstj merged commit ba8641a into dotnet:master Jul 12, 2019
}

[Fact]
public static void KeyConflictDeserialize_LastValueWins()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this still a useful test case? What do we do for this case now since we are no longer using naming policy when deserializing? The behavior should be captured in a test.

ThrowHelper.ThrowInvalidOperationException_SerializerDictionaryKeyNull(options.DictionaryKeyPolicy.GetType());
}

keyName = options.DictionaryKeyPolicy.ConvertName(keyName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why did we initially try to get the keyName by calling ConvertName twice?

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Do not use DictionaryKeyPolicy on deserialization

* Update policy doc


Commit migrated from dotnet/corefx@ba8641a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not use DictionaryKeyPolicy on deserialization
5 participants