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

Fix for regression in multi-output node preview #11266

Merged
merged 5 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ObservableCollection<WatchViewModel> Children
}

/// <summary>
/// The string lable visibile in the watch.
/// The string label visible in the watch.
/// </summary>
public string NodeLabel
{
Expand Down
14 changes: 12 additions & 2 deletions src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Threading;
using Dynamo.Configuration;
using Dynamo.Controls;
using Dynamo.Graph.Nodes.ZeroTouch;
using Dynamo.Interfaces;
using Dynamo.Models;
using Dynamo.Scheduler;
Expand Down Expand Up @@ -368,8 +369,17 @@ private void RefreshExpandedDisplay(Action refreshDisplay)
RunOnSchedulerSync(
() =>
{
var preferredDictionaryOrdering =
nodeViewModel.NodeModel.OutPorts.Select(p => p.Name).Where(n => !String.IsNullOrEmpty(n));
IEnumerable<string> preferredDictionaryOrdering;
if (nodeViewModel.NodeModel is DSFunction dsFunction)
{
preferredDictionaryOrdering = dsFunction.Controller.ReturnKeys;
}
else
{
preferredDictionaryOrdering =
nodeViewModel.NodeModel.OutPorts.Select(p => p.Name).Where(n => !string.IsNullOrEmpty(n));
}

newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData(
nodeViewModel.NodeModel.CachedValue, preferredDictionaryOrdering,
null, nodeViewModel.NodeModel.AstIdentifierForPreview.Name, false);
Expand Down
6 changes: 3 additions & 3 deletions src/Libraries/CoreNodes/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public static IDictionary Deconstruct(IList list)
/// <returns name="sortedList">type: var[]..[]</returns>
/// <returns name="sortedKeys">type: var[]..[]</returns>
/// <search>sort;key</search>
[MultiReturn(new[] { "sorted list", "sorted keys" })]
[MultiReturn("sortedList", "sortedKeys")]
[IsVisibleInDynamoLibrary(true)]
public static IDictionary SortByKey(IList list, IList keys)
{
Expand Down Expand Up @@ -484,8 +484,8 @@ public static IDictionary SortByKey(IList list, IList keys)

return new Dictionary<object, object>
{
{ "sorted list", sortedList },
{ "sorted keys", sortedKeys }
{ "sortedList", sortedList },
{ "sortedKeys", sortedKeys }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These name changes are unrelated to the fix and are made only for consistency so that the same is reflected in the preview bubble.

};
}

Expand Down
25 changes: 25 additions & 0 deletions test/DynamoCoreWpfTests/PreviewBubbleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected override void GetLibrariesToPreload(List<string> libraries)
{
libraries.Add("DesignScriptBuiltin.dll");
libraries.Add("DSCoreNodes.dll");
libraries.Add("FFITarget.dll");
base.GetLibrariesToPreload(libraries);
}

Expand Down Expand Up @@ -354,6 +355,30 @@ public void PreviewBubble_ShowExpandedPreviewOnPinIconHover()
Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown");
}

[Test]
public void PreviewBubble_ShowExpandedPreview_MultiReturnNode()
{
Open(@"core\multireturnnode_preview.dyn");
var nodeView = NodeViewWithGuid("587d7494-e764-41fb-8b5d-a4229f7294ee");

var previewBubble = nodeView.PreviewControl;
previewBubble.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
previewBubble.bubbleTools.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

// open preview bubble
RaiseMouseEnterOnNode(nodeView);
Assert.IsTrue(previewBubble.IsCondensed, "Compact preview bubble should be shown");
Assert.AreEqual(Visibility.Collapsed, previewBubble.bubbleTools.Visibility, "Pin icon should not be shown");

// hover preview bubble to see pin icon
RaiseMouseEnterOnNode(previewBubble);
Assert.AreEqual(Visibility.Visible, previewBubble.bubbleTools.Visibility, "Pin icon should be shown");

// expand preview bubble
RaiseMouseEnterOnNode(previewBubble.bubbleTools);
Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown");
Copy link
Member

Choose a reason for hiding this comment

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

so this line failed previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

}

[Test]
public void PreviewBubble_ShownForColorRange()
{
Expand Down
1 change: 1 addition & 0 deletions test/Engine/FFITarget/FFITarget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>..\..\..\bin\AnyCPU\Debug\en-US\FFITarget.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
8 changes: 8 additions & 0 deletions test/Engine/FFITarget/ProtoFFITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ public int TestInternalClass(object y)
return x.GetValue();
}

/// <summary>
/// Return nested dictionary.
/// </summary>
/// <returns name="col">column</returns>
/// <returns name="dict">dictionary</returns>
/// <returns name="num">number</returns>
/// <returns name="wt">weight</returns>
/// <returns name="ok">okay</returns>
[MultiReturn("color", "dict", "nums", "weight", "ok")]
public Dictionary<string, object> ReturnNestedDictionary()
{
Expand Down
16 changes: 8 additions & 8 deletions test/Libraries/CoreNodesTests/ListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,8 @@ public static void SortByKey1()
var result = List.SortByKey(list, keys);
var expected = new Dictionary<string, object>
{
{ "sorted list", new object[] { "item2", "item1" } },
{ "sorted keys", new object[] { "key1", "key2" } }
{ "sortedList", new object[] { "item2", "item1" } },
{ "sortedKeys", new object[] { "key1", "key2" } }
};

Assert.AreEqual(expected, result);
Expand Down Expand Up @@ -1142,8 +1142,8 @@ public static void SortByKey4()
var result = List.SortByKey(list, keys);
var expected = new Dictionary<string, object>
{
{ "sorted list", new object[] { "Neal", "Matt", "Ian", "Zack", "Colin" } },
{ "sorted keys", new object[] { "Burnham", "Jezyk", "Keough", "Kron", "McCrone" } }
{ "sortedList", new object[] { "Neal", "Matt", "Ian", "Zack", "Colin" } },
{ "sortedKeys", new object[] { "Burnham", "Jezyk", "Keough", "Kron", "McCrone" } }
};

Assert.AreEqual(expected, result);
Expand All @@ -1165,8 +1165,8 @@ public static void SortByKey5()
var result = List.SortByKey(list, keys);
var expected = new Dictionary<string, object>
{
{ "sorted list", new object[] { "Zack", "Ian", "Anna", "Neal" } },
{ "sorted keys", new object[] { -3, 1.6, 5, "abc" } }
{ "sortedList", new object[] { "Zack", "Ian", "Anna", "Neal" } },
{ "sortedKeys", new object[] { -3, 1.6, 5, "abc" } }
};

Assert.AreEqual(expected, result);
Expand All @@ -1182,8 +1182,8 @@ public static void SortByKey6()
var result = List.SortByKey(list, keys);
var expected = new Dictionary<string, object>
{
{ "sorted list", new object[] { 2, 3, 1 }},
{ "sorted keys", new object[] { 1.20, 1.2001, 1.21 } }
{ "sortedList", new object[] { 2, 3, 1 }},
{ "sortedKeys", new object[] { 1.20, 1.2001, 1.21 } }
};

Assert.AreEqual(expected, result);
Expand Down
157 changes: 157 additions & 0 deletions test/core/multireturnnode_preview.dyn
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"Uuid": "cdab5b52-304f-4b23-8a5e-4a93ebdcafb9",
"IsCustomNode": false,
"Description": null,
"Name": "multireturnnode_preview",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore",
"NodeType": "FunctionNode",
"FunctionSignature": "FFITarget.TestData.ReturnNestedDictionary",
"Id": "587d7494e76441fb8b5da4229f7294ee",
"Inputs": [
{
"Id": "0e6050e8916a454eab7cf2d87861cb07",
"Name": "testData",
"Description": "FFITarget.TestData",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "fddbb030b56041bf88ee3b0f0b44c493",
"Name": "col",
"Description": "column",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "0f381b0e745e4604856705582cf0231c",
"Name": "dict",
"Description": "dictionary",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "421f2476bb444d8ba1330c9fd8d6e4fd",
"Name": "num",
"Description": "number",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "fc3fbe47234a4e0f8d4fa4385e301419",
"Name": "wt",
"Description": "weight",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "8d8682c503d84a0f8da77833247df6a8",
"Name": "ok",
"Description": "okay",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Auto",
"Description": "Return nested dictionary.\n\nTestData.ReturnNestedDictionary ( ): var[]..[]"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore",
"NodeType": "FunctionNode",
"FunctionSignature": "FFITarget.TestData.TestData",
"Id": "e64dd6ca741c4a09b722c7fb231cf474",
"Inputs": [],
"Outputs": [
{
"Id": "1404145039bf4ffbb2f648eecdce0928",
"Name": "TestData",
"Description": "TestData",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Auto",
"Description": "TestData.TestData ( ): TestData"
}
],
"Connectors": [
{
"Start": "1404145039bf4ffbb2f648eecdce0928",
"End": "0e6050e8916a454eab7cf2d87861cb07",
"Id": "e9da6bf89a1f4ff98b09a22a57585115"
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": true,
"IsVisibleInDynamoLibrary": true,
"Version": "2.10.0.3246",
"RunType": "Automatic",
"RunPeriod": "1000"
},
"Camera": {
"Name": "Background Preview",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
"LookX": 12.0,
"LookY": -13.0,
"LookZ": -58.0,
"UpX": 0.0,
"UpY": 1.0,
"UpZ": 0.0
},
"NodeViews": [
{
"ShowGeometry": true,
"Name": "TestData.ReturnNestedDictionary",
"Id": "587d7494e76441fb8b5da4229f7294ee",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 587.591972524768,
"Y": 366.80443744047426
},
{
"ShowGeometry": true,
"Name": "TestData.TestData",
"Id": "e64dd6ca741c4a09b722c7fb231cf474",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 396.92609744922186,
"Y": 383.40302487798539
}
],
"Annotations": [],
"X": -201.66090832590237,
"Y": -282.42730312803474,
"Zoom": 1.2374114765500794
}
}