Skip to content

ids serialization and deserialization: - #7930

Merged
mjkkirschner merged 9 commits into
DynamoDS:masterfrom
mjkkirschner:uuidToID
Jun 7, 2017
Merged

mjkkirschner merged 9 commits into
DynamoDS:masterfrom
mjkkirschner:uuidToID

Conversation

@mjkkirschner

@mjkkirschner mjkkirschner commented Jun 5, 2017 •

Copy link
Copy Markdown
Member

Purpose

This PR deals with both https://jira.autodesk.com/browse/QNTM-692 and https://jira.autodesk.com/browse/QNTM-700

Leaves workspaceModel's Guid property serializing to Uuid as it is today.
It changes AnnotationModel PortModel and ConnectorModel and NodeModel to serialize their Guid property as Id to be more explicit about that fact that these properties do not need to be globally unique but have different uniqueness requirements that are explained in their summaries.

When id properties are deserialized they are parsed as if they are guids, if they are not valid guids, we generate a deterministic guid based on the id string.

The element resolver still uses guids to remap the model as before. I've also added some checks to it that throw exceptions if a duplicate key is added to the resolve map or resolver models dict - all ids should at a minimum be unique within the graph so this should be a valid check to do.

  • I need to add tests which create some non guid ids and validate the graphs deserialize and run correctly.

Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@QilongTang

FYIs

@ramramps @ikeough @gregmarr

@mjkkirschner mjkkirschner changed the title ids and serialization and deserialization: ids serialization and deserialization: Jun 5, 2017
public PortModel End { get; private set; }

/// <summary>
/// ID of the Connector, which is unique on in the graph.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

within the graph?

@mjkkirschner

Copy link
Copy Markdown
Member Author

I've added a new set of tests based on the serialization tests that modify the generated json to have non guid ids - these are then deserialized, run and and compared.

I'll fix up the merge conflicts and this should be ready for review.

Guid nodeId;
if (!Guid.TryParse((obj["Id"].Value<string>()), out nodeId))
{
nodeId = GuidUtility.Create(GuidUtility.UrlNamespace, (obj["Id"].Value<string>()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This pattern occurs multiple times, seems like it should become a helper function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good catch- thanks, should be straight forward.

Michael Kirschner added 2 commits June 7, 2017 08:40
# Conflicts:
#	src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
@mjkkirschner mjkkirschner added PTAL Please Take A Look 👀 and removed WIP labels Jun 7, 2017
var guid = Guid.Parse(obj["Uuid"].Value<string>());

//if the id is not a guid, makes a guid based on the id of the node
Guid nodeId = GuidUtility.tryParseOrCreateGuid(obj["Id"].Value<string>());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's just assign this to guid directly

@mjkkirschner

Copy link
Copy Markdown
Member Author

@QilongTang addressed the comment.

ConvertCurrentWorkspaceToDesignScriptAndSave(filePathBase);

string json = ConvertCurrentWorkspaceToJsonAndSave(model, filePathBase);
string json = saveFunction(model, filePathBase);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Neat

@QilongTang

Copy link
Copy Markdown
Contributor

@mjkkirschner LGTM

@QilongTang QilongTang added LGTM and removed PTAL Please Take A Look 👀 labels Jun 7, 2017
@mjkkirschner
mjkkirschner merged commit 6ad016d into DynamoDS:master Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants