Skip to content

[release/5.0] Fix InvalidCastException when deserializing some dictionary types (#42835) - #45449

Merged
layomia merged 1 commit into
dotnet:release/5.0from
layomia:dictionary_5.0
Dec 8, 2020
Merged

[release/5.0] Fix InvalidCastException when deserializing some dictionary types (#42835)#45449
layomia merged 1 commit into
dotnet:release/5.0from
layomia:dictionary_5.0

Conversation

@layomia

Copy link
Copy Markdown
Contributor

Ports #42835 to 5.0
Fixes#44726 in 5.0

Description

Support for non-string dictionary keys was added in 5.0 (PR, design doc). This support is scoped to primitives such as DateTime, int etc. This change fixes a bug in that feature where InvalidCastException is thrown when deserializing the following dictionary types (exhaustive list) and the key type is not typeof(string):

  • typeof(IDictionary<,>)
  • typeof(ImmutableDictionary<,>)
  • typeof(IImmutableDictionary<,>)
  • typeof(IReadOnlyDictionary<,>)

Customer Impact

Successful deserialization of the above cases. Customers can avoid increased concept count of knowing which dictionary types work and which ones fail.

Regression

Not a regression since it was a new feature in 5.0.

Testing

Unit tests have been added to verify the expected behavior.

Risk

Little to none. This is a very scoped change to address this issue only.

@leecowleecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Dec 8, 2020
@layomia
layomia merged commit e9c9a2f into dotnet:release/5.0Dec 8, 2020
@layomia
layomia deleted the dictionary_5.0 branch December 8, 2020 18:36
@ghostghost locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.JsonServicing-approvedApproved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@layomia@eiriktsarpalis@steveharter@ericstj@leecow