-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds more features back that were lost due to the removal of Newtonsoft #16292
Conversation
…pers, that where lost by removing Newtonsoft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. If you are able to, it may not be a bad idea to add functional tests for this to ensure everything is working and will continue to work as expected.
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Outdated
Show resolved
Hide resolved
The unit test I mentioned in issue #16290 doesn't work with this PR , any plans to fix it in this PR? Can we modify the DynamicJsonValue fetching behaviour so that it can be generated from the JsonValueKind.String map to System. I'm working on that. |
Similar functionality exists in Jint and ClearScript, Jint uses ExpandoObject, but ClearScript uses DynamicObject. |
…micValue.cs Co-authored-by: Mike Alhayek <mike@crestapps.com>
…micValue.cs Co-authored-by: Mike Alhayek <mike@crestapps.com>
…micValue.cs Co-authored-by: Mike Alhayek <mike@crestapps.com>
Dude you are so cool, but even more if you create a unit test with these conversions ;) |
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicObject.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicValue.cs
Outdated
Show resolved
Hide resolved
public static bool operator !=(JsonDynamicValue left, JsonDynamicValue right) | ||
{ | ||
return !(left == right); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static bool operator !=(JsonDynamicValue left, JsonDynamicValue right) | |
{ | |
return !(left == right); | |
} | |
public static bool operator !=(JsonDynamicValue left, JsonDynamicValue right) => !(left == right); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you prefer expression bodies, but Sebastien removed all of them the last time this file was changed. So I rather keep the format consistent for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm. When I tried to open the classes and read what they were doing it was so condensed I couldn't understand what I was reading.
What I realized is that if the definition + body fits on a line on the screen then it's fine, if the implementation has to go on the second line then there is no point and it's more readable to just use a standard body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But please don't change anything because "that one char can be removed and it will fit in a single line", there is no readability advantage IMO by squashing everything in a line.
public static bool operator <(JsonDynamicValue left, JsonDynamicValue right) | ||
{ | ||
return ReferenceEquals(left, null) ? !ReferenceEquals(right, null) : left.CompareTo(right) < 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static bool operator <(JsonDynamicValue left, JsonDynamicValue right) | |
{ | |
return ReferenceEquals(left, null) ? !ReferenceEquals(right, null) : left.CompareTo(right) < 0; | |
} | |
public static bool operator <(JsonDynamicValue left, JsonDynamicValue right) | |
=> ReferenceEquals(left, null) ? !ReferenceEquals(right, null) : left.CompareTo(right) < 0; |
public static bool operator <=(JsonDynamicValue left, JsonDynamicValue right) | ||
{ | ||
return ReferenceEquals(left, null) || left.CompareTo(right) <= 0; | ||
} | ||
|
||
public static bool operator >(JsonDynamicValue left, JsonDynamicValue right) | ||
{ | ||
return !ReferenceEquals(left, null) && left.CompareTo(right) > 0; | ||
} | ||
|
||
public static bool operator >=(JsonDynamicValue left, JsonDynamicValue right) | ||
{ | ||
return ReferenceEquals(left, null) ? ReferenceEquals(right, null) : left.CompareTo(right) >= 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static bool operator <=(JsonDynamicValue left, JsonDynamicValue right) | |
{ | |
return ReferenceEquals(left, null) || left.CompareTo(right) <= 0; | |
} | |
public static bool operator >(JsonDynamicValue left, JsonDynamicValue right) | |
{ | |
return !ReferenceEquals(left, null) && left.CompareTo(right) > 0; | |
} | |
public static bool operator >=(JsonDynamicValue left, JsonDynamicValue right) | |
{ | |
return ReferenceEquals(left, null) ? ReferenceEquals(right, null) : left.CompareTo(right) >= 0; | |
} | |
public static bool operator <=(JsonDynamicValue left, JsonDynamicValue right) | |
=> ReferenceEquals(left, null) || left.CompareTo(right) <= 0; | |
public static bool operator >(JsonDynamicValue left, JsonDynamicValue right) | |
=> !ReferenceEquals(left, null) && left.CompareTo(right) > 0; | |
public static bool operator >=(JsonDynamicValue left, JsonDynamicValue right) | |
=> ReferenceEquals(left, null) ? ReferenceEquals(right, null) : left.CompareTo(right) >= 0; |
|
||
public static implicit operator JsonDynamicValue(short? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(int value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(int? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(long value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(long? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(sbyte value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(sbyte? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(float value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(float? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(string value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(ushort value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(ushort? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(uint value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(uint? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(ulong value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(ulong? value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(byte[] value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(Convert.ToBase64String(value), JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(TimeSpan value) | ||
{ | ||
return new JsonDynamicValue(JsonValue.Create(value.ToString(), JOptions.Node)); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(TimeSpan? value) | ||
{ | ||
return new JsonDynamicValue(value.HasValue ? JsonValue.Create(value.ToString(), JOptions.Node) : null); | ||
} | ||
|
||
public static implicit operator JsonDynamicValue(Uri? value) | ||
{ | ||
return new JsonDynamicValue(value != null ? JsonValue.Create(value.ToString(), JOptions.Node) : null); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static implicit operator JsonDynamicValue(bool value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(bool? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(byte value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(byte? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(char value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(char? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(DateTime value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(DateTime? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(DateTimeOffset value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(DateTimeOffset? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(decimal value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(decimal? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(double value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(double? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(Guid value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(Guid? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(short value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(short? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(int value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(int? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(long value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(long? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(sbyte value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(sbyte? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(float value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(float? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(string value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(ushort value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(ushort? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(uint value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(uint? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(ulong value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(ulong? value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(byte[] value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(Convert.ToBase64String(value), JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(TimeSpan value) | |
{ | |
return new JsonDynamicValue(JsonValue.Create(value.ToString(), JOptions.Node)); | |
} | |
public static implicit operator JsonDynamicValue(TimeSpan? value) | |
{ | |
return new JsonDynamicValue(value.HasValue ? JsonValue.Create(value.ToString(), JOptions.Node) : null); | |
} | |
public static implicit operator JsonDynamicValue(Uri? value) | |
{ | |
return new JsonDynamicValue(value != null ? JsonValue.Create(value.ToString(), JOptions.Node) : null); | |
} | |
public static implicit operator JsonDynamicValue(bool value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(bool? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(byte value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(byte? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(char value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(char? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(DateTime value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(DateTime? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(DateTimeOffset value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(DateTimeOffset? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(decimal value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(decimal? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(double value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(double? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(Guid value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(Guid? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(short value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(short? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(int value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(int? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(long value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(long? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(sbyte value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(sbyte? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(float value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(float? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(string value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(ushort value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(ushort? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(uint value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(uint? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(ulong value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(ulong? value) | |
=> new JsonDynamicValue(JsonValue.Create(value, JOptions.Node)); | |
public static implicit operator JsonDynamicValue(byte[] value) | |
=> new JsonDynamicValue(JsonValue.Create(Convert.ToBase64String(value), JOptions.Node)); | |
public static implicit operator JsonDynamicValue(TimeSpan value) | |
=> new JsonDynamicValue(JsonValue.Create(value.ToString(), JOptions.Node)); | |
public static implicit operator JsonDynamicValue(TimeSpan? value) | |
=> new JsonDynamicValue(value.HasValue ? JsonValue.Create(value.ToString(), JOptions.Node) : null); | |
public static implicit operator JsonDynamicValue(Uri? value) | |
=> new JsonDynamicValue(value != null ? JsonValue.Create(value.ToString(), JOptions.Node) : null); |
Added unit tests.
…dCore into gvkries/dyn-16233
I added some basic unit tests for the new implicit conversions and operators. Also, to make it even more complex, I added a fix for #16290 into this PR. Serializing the dynamic wrappers ( |
…micValue.cs Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
I've tested it and found that it's still a little different from the old version, but it's almost complete. Thanks! const content = contentItem('46t41hp7d9w6446r35405swzwt')
return {
data: {
// contentStr:JSON.stringify(content), //Error: Cyclic reference detected
testValue: content.Content.SEAQuotaionForm.SoldTo.Text,
testValue2: content.Content.SEAQuotaionForm.SoldTo.Text + "2123",
QuoteId: content.Content.SEAQuotaionForm.QuoteId.Value + 10000,
obj: JSON.parse(JSON.stringify(content.Content)),
objStr: JSON.stringify(content.Content),
objAll: content
}
} |
I should try the datetime value again later. |
I think in Jint you have the same problem. The dynamic wrappers are now also serialized, that's why you get a different result. The |
Yes, in my tests the serialisation converter you defined works in Jint |
I created a PR for solving serialisation problems in Jint #16298 |
I simplified this a little bit by adding a base class for the dynamic wrappers (as @hishamco suggested). Also, I removed the nested |
src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicObject.cs
Outdated
Show resolved
Hide resolved
@MikeAlhayek @hishamco waiting for you asking for more things, or we'll merge in 24h. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@sebastienros if there's any objection regarding expression bodies please let me, because it was a useful feature for single-line methods |
Personally, it's not a big deal, and I'm more than inclined to prioritise readability, too |
public void Merge(JsonNode? content, JsonMergeSettings? settings = null) | ||
{ | ||
_jsonObject.Merge(content, settings); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void Merge(JsonNode? content, JsonMergeSettings? settings = null) | |
{ | |
_jsonObject.Merge(content, settings); | |
} | |
public void Merge(JsonNode? content, JsonMergeSettings? settings = null) => _jsonObject.Merge(content, settings); |
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
throw new NotSupportedException($"Deserializing a {typeof(T).Name} is not supported."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | |
{ | |
throw new NotSupportedException($"Deserializing a {typeof(T).Name} is not supported."); | |
} | |
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | |
=> throw new NotSupportedException($"Deserializing a {typeof(T).Name} is not supported."); |
A week has passed. Nothing for now, is it mandatory that we use expression ? 🤨 |
Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
I don't see the remaining formatting suggestions as mandatory... 🙈 |
Hi @hishamco ,All right, all right, let's merge it quickly. |
merge, merge... |
@gvkries I enabled auto merge. Hopefully you are done making changes :) |
I have stated my "personal" preferences and motivations several times already. |
Added
ToObject<T>
implementations back toJsonDynamicObject
,JsonDynamicArray
andJsonDynamicValue
.This functionality allows to convert JSON to the strongly typed content items and parts when using dynamic typing. E.g. we have this functionality referenced in the documentation:
OrchardCore/src/docs/reference/modules/Media/README.md
Line 456 in 7196b5b
Also something like the following is now possible again:
To support value comparisons when using dynamic typing, I made the following changes:
E.g. this allows using conditions with dynamic values, without casting to the target type before:
Note that the comparison implementation (
<, >, <=, >=
) is very basic at the moment, e.g. it does not handle all typesa
JsonDynamicValue
can be converted too. The comparison was therefore supporting a wider rangeof target types with Newtonsoft JSON, in contrast to this rudimentary implementation.
Fixes #16233
Fixes #16221
Fixes #16290/cc @giannik @MikeAlhayek @sebastienros