Skip to content
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

Migrate number nodes with sequence to CBNs. #7582

Merged
merged 8 commits into from
Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
20 changes: 20 additions & 0 deletions src/Libraries/CoreNodeModels/Input/BaseTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using ProtoCore.DSASM;
using CoreNodeModels.Properties;
using Newtonsoft.Json;
using Dynamo.Migration;

namespace CoreNodeModels.Input
{
Expand Down Expand Up @@ -737,5 +738,24 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
writer.WriteValue(d);
}
}

[NodeMigration(from: "1.0.0.0")]
public static NodeMigrationData Migrate_Range(NodeMigrationData data)
{
var migrationData = new NodeMigrationData(data.Document);
var oldNode = data.MigratedNodes.ElementAt(0);
var valEls = oldNode.GetElementsByTagName("System.Double"); // The Value node
var val = valEls[0].Attributes["value"].Value;

if (!val.Contains(".."))
{
return data;
}

var newNode = MigrationManager.CreateCodeBlockNodeFrom(oldNode);
newNode.Attributes["CodeText"].Value = val + ";";
migrationData.AppendNode(newNode);
return migrationData;
}
}
}
6 changes: 3 additions & 3 deletions test/DynamoCoreTests/CallsiteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Dynamo.Graph.Nodes.ZeroTouch;
using Dynamo.Graph.Workspaces;
using NUnit.Framework;

using Dynamo.Graph.Nodes;

namespace Dynamo.Tests
{
Expand Down Expand Up @@ -96,10 +96,10 @@ private void OpenChangeAndCheckOrphans(string testFileName, string numNodeValue,

CurrentDynamoModel.TraceReconciliationProcessor = new TestTraceReconciliationProcessor(expectedOrphanCount);

var numNode = ws.FirstNodeFromWorkspace<DoubleInput>();
var numNode = ws.FirstNodeFromWorkspace<CodeBlockNodeModel>();

// Increase the number values.
numNode.Value = numNodeValue;
numNode.SetCodeContent(numNodeValue + ";", new ProtoCore.Namespace.ElementResolver());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just a temporary change for testing purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This test needs to be updated to work after this migration is added.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's going to replace the existing test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see now.


BeginRun();
}
Expand Down