-
Notifications
You must be signed in to change notification settings - Fork 636
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
DYN-7278: fix dictionary preview by adding support for more types #15750
base: master
Are you sure you want to change the base?
Conversation
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.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-7278
UI Smoke TestsTest: success. 11 passed, 0 failed. |
@@ -122,6 +135,28 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC | |||
return new WatchViewModel(value, tag, RequestSelectGeometry); | |||
} | |||
|
|||
private static Dictionary<string, object> ConvertJObjectToDictionary(JObject jObject) |
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.
a couple thoughts.
- If I am understanding correctly, this is essentially arbitrary deserialization of json using the
ToObject()
calls. It's not clear to me exactly what types this allows deserialization of.
I think the default deserialization calls use a secure serializer (TypeNameHandling = None)
, but I am not sure, it might be good to make it explicit by using a serializer here with settings that encode that specifically - for example:
Dynamo/src/DynamoCore/Models/DynamoModel.cs
Line 2158 in 3d8a262
TypeNameHandling = TypeNameHandling.None, |
IMO this kind of thing becomes more important now that we have to support DaaS - though I guess maybe this code is never even present on the service? (wpf?)
-
Where is this type coming from? The Forma nodes? Personally I feel we should ditch newtonsoft everywhere and instead use the built in system.text.json - it's harder to screw up security using it (though not impossible)
-
I have not thought about it much - but wouldn't it be nice if packages could provide their own watch handlers?
-
why are both dictionary and this newtonsoft parsing done in the object handler instead of defining more specific overloads - was there a performance reason for this?
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.
- These are
NewtonSoft.Json JObject
types that are coming mainly from Forma elements represented as JSON. As of now, I'm not sure what other nodes exist that output such types that have preview issues but so far, I'm seeing this issue only with the Forma nodes. TheJObject
seems to have a structure similar to dictionaries or key-value pairs so it just seems natural to be able to convert them to a form such that they can be previewed such as dictionaries. - Yes, to types coming from Forma. I'll see if I can switch the deserialization to use System.Text.Json instead but I think it would mean changing the DynamoForma package to use STJ as well. If that's the case, that would be out of scope for this fix.
- Not sure given that I think this is the first time we've encountered a case such as this where nodes in a package are having preview issues and therefore such cases seem to be rare but still open to discuss.
I'm not sure I understand. What exactly are you referring to byobject handler
andoverloads
?
I think I see what you mean. No particular reason for doing it this way. I can add an overload forProcessThing
to handleJObject
and maybe another for Dictionary, if that's what you're alluding to.
@@ -272,7 +272,15 @@ private static string GetStringFromObject(object obj) | |||
case TypeCode.DateTime: | |||
return ((DateTime)obj).ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture); | |||
case TypeCode.Object: | |||
if (obj is byte[] byteArray) |
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.
can you add tests for the cases you are fixing?
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.
Yes, I was going to add tests, which is why I didn't call this out for review yet but thanks for the review all the same.
case TypeCode.UInt32: | ||
return nameof(TypeCode.UInt32); | ||
case TypeCode.UInt64: | ||
return nameof(TypeCode.UInt64); |
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 don't believe the type returned from GetDisplayType
is actually being used currently so it might just be better to remove this for function for the time being.
Purpose
(FILL ME IN) This section describes why this PR is here. Usually it would include a reference to the tracking task that it is part or all of the solution for.
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
(FILL ME IN) Brief description of the fix / enhancement. Use N/A to indicate that the changes in this pull request do not apply to Release Notes. Mandatory section
Reviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of