You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Text.Json.Nodes.JsonNode no longer supports C# "dynamic" keyword in Preview 7 #25105
Binary compatibility (code must be recompiled to use the newer API version)
Source compatibility (successfully recompiling against the newer API version requires source changes)
Reason for change
As discussed in dotnet/runtime#53195, the "dynamic" feature in C# is considered somewhat stale and adding a dependency to a new API (JsonNode and derived classes) is not considered a good practice.
If a newer, more modern version of "dynamic" is introduced, this decision will be re-opened.
Recommended action
Use the string-based property name.
If "dynamic" is necessary, the previous workaround mentioned at dotnet/runtime#42097 is still valid. This will be verified and updated as necessary for .NET 6.0.
Feature area
System.Text.Json
Affected APIs
All System.Text.Json.Nodes.JsonNode.Parse() APIs are affected if the return value is assigned to a C# variable of type dynamic variable.
In addition, if JsonSerializerOptions.UnknownTypeHandling == UnknownTypeHandling.JsonNode then all System.Text.Json.JsonSerializer.Deserialize* APIs are affected if they use dynamic or object for the type parameter and the return value is assigned to a C# variable of type dynamic.
Issue metadata
Issue type: breaking-change
Reacted by Bruno B. de Souza, Greg Dennis and Yufei Huang
Reacted by Pratik Khasnabis, Alexey Shokov, Andrew Magee, Cattywampus and Shaun Tonstad
Dynamic is "stale" is an opinion and not a strong argument. As long as the feature exists in C# it should be supported. Some of use write C# to quickly prototype and achieve results and calling arbitrary APIs to test json response is a very common thing. Using dynamic is very valuable here. Code can always be written to better standards and performant but that doesn't mean everyone has to do it in all contexts.
Reacted by Alexey Shokov, Andrew Magee, Str3amR, Dave Black, Shaun Tonstad, jv.n and Ulugbek Umbarov
Activity
gewarren commentedon Jul 30, 2021
@steveharter Did you assign this to yourself because you're planning to document it? Otherwise I will document it.
softveda commentedon Aug 11, 2021
Dynamic is "stale" is an opinion and not a strong argument. As long as the feature exists in C# it should be supported. Some of use write C# to quickly prototype and achieve results and calling arbitrary APIs to test json response is a very common thing. Using dynamic is very valuable here. Code can always be written to better standards and performant but that doesn't mean everyone has to do it in all contexts.