Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review feedback
  • Loading branch information
layomia committed Sep 10, 2021
commit e6406f1700a9bd2676ab64d04a3110fcd7081afc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Json.SourceGeneration;

namespace System.Text.Json.Reflection
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Text.Json/gen/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<value>Type has multiple members annotated with JsonExtensionDataAttribute.</value>
</data>
<data name="DataExtensionPropertyInvalidFormat" xml:space="preserve">
<value>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</value>
<value>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</value>
</data>
<data name="DataExtensionPropertyInvalidTitle" xml:space="preserve">
<value>Data extension property type invalid.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</target>
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source>
<target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
Expand Down
4 changes: 4 additions & 0 deletions src/libraries/System.Text.Json/gen/TypeGenerationSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ internal class TypeGenerationSpec

public TypeGenerationSpec? NullableUnderlyingTypeMetadata { get; private set; }

/// <summary>
/// Supports deserialization of extension data dictionaries typed as I[ReadOnly]Dictionary<string, object/JsonElement>.
/// Specifies a concrete type to instanciate, which would be Dictionary<string, object/JsonElement>.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Specifies a concrete type to instanciate, which would be Dictionary<string, object/JsonElement>.
/// Specifies a concrete type to instantiate, which would be Dictionary<string, object/JsonElement>.

/// </summary>
public string? RuntimeTypeRef { get; private set; }

public TypeGenerationSpec? ExtensionDataPropertyTypeSpec { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Text.Json/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
<value>The JSON property name for '{0}.{1}' cannot be null.</value>
</data>
<data name="SerializationDataExtensionPropertyInvalid" xml:space="preserve">
<value>The data extension property '{0}.{1}' does not match the required signature of 'IDictionary&lt;string, JsonElement&gt;', 'IDictionary&lt;string, object&gt;' or 'JsonObject'.</value>
<value>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</value>
</data>
<data name="SerializationDuplicateTypeAttribute" xml:space="preserve">
<value>The type '{0}' cannot have more than one member that has the attribute '{1}'.</value>
Expand Down
17 changes: 4 additions & 13 deletions src/libraries/System.Text.Json/tests/Common/ExtensionDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ void Verify()
#endif
public async Task ExtensionFieldNotUsed()
{
Diagnostics.Debugger.Launch();
string json = @"{""MyNestedClass"":" + SimpleTestClass.s_json + "}";
ClassWithExtensionField obj = await JsonSerializerWrapperForString.DeserializeWrapper<ClassWithExtensionField>(json);
Assert.Null(obj.MyOverflow);
Expand Down Expand Up @@ -323,7 +322,7 @@ public class ClassWithTwoExtensionProperties

[Fact]
#if BUILDING_SOURCE_GENERATOR_TESTS
[ActiveIssue("Compile-time errors thrown for these scenarios.")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58945")]
#endif
public async Task InvalidExtensionPropertyFail()
{
Expand Down Expand Up @@ -797,7 +796,7 @@ public async Task DeserializeIntoJsonObjectProperty()

[Fact]
#if BUILDING_SOURCE_GENERATOR_TESTS
[ActiveIssue("Compile-time errors thrown for these scenarios.")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58945")]
#endif

public async Task DeserializeIntoSystemObjectProperty()
Expand Down Expand Up @@ -1087,7 +1086,7 @@ public class ClassWithInvalidExtensionPropertyStringJsonNode

[Fact]
#if BUILDING_SOURCE_GENERATOR_TESTS
[ActiveIssue("Compile-time errors thrown for these scenarios.")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58945")]
#endif
public async Task ExtensionProperty_InvalidDictionary()
{
Expand Down Expand Up @@ -1146,7 +1145,7 @@ public class ClassWithMultipleDictionaries

[Fact]
#if BUILDING_SOURCE_GENERATOR_TESTS
[ActiveIssue("Compile-time errors thrown for these scenarios.")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58945")]
#endif
public async Task DeserializeIntoImmutableDictionaryProperty()
{
Expand Down Expand Up @@ -1402,14 +1401,6 @@ public async Task EmptyPropertyNameAndExtensionData_ExtDataFirst()
Assert.Null(obj.MyOverflow);
}

//[Fact]
//public async Task QuickDictTest()
//{
// if (!Diagnostics.Debugger.IsAttached) { Diagnostics.Debugger.Launch(); }
// var dict = await JsonSerializerWrapperForString.DeserializeWrapper<IDictionary<string, JsonElement>>("{}");
// Console.WriteLine(dict.Count);
//}

[Fact]
public async Task ExtensionDataDictionarySerialize_DoesNotHonor()
{
Expand Down