diff --git a/src/DynamoCore/Library/XmlDocumentationExtensions.cs b/src/DynamoCore/Library/XmlDocumentationExtensions.cs
index 426448b68ca..5c783a4343d 100644
--- a/src/DynamoCore/Library/XmlDocumentationExtensions.cs
+++ b/src/DynamoCore/Library/XmlDocumentationExtensions.cs
@@ -154,6 +154,8 @@ private static MemberDocumentNode GetMemberDocumentNode(
documentNode = documentNodes[fullyQualifiedName];
else
{
+ // Note that the following may take the incorrect overload.
+ // Unfortunately we can't map back to the exact .NET parameter types from the DS function descriptor.
var overloadedName = documentNodes.Keys.
Where(key => key.Contains(function.ClassName + "." + function.FunctionName)).FirstOrDefault();
@@ -199,6 +201,10 @@ private static string GetMemberElement(
}
}
+ ///
+ /// Attempts to translate a DS type into a .NET type. Note that,
+ /// given these do not map 1 to 1, this is just a heuristic.
+ ///
private static string PrimitiveMap(string s)
{
switch (s)
@@ -211,12 +217,20 @@ private static string PrimitiveMap(string s)
return "System.Object";
case "double":
return "System.Double";
+ case "double[]":
+ return "System.Double[]";
case "int":
return "System.Int32";
+ case "int[]":
+ return "System.Int32[]";
case "bool":
return "System.Boolean";
+ case "bool[]":
+ return "System.Boolean[]";
case "string":
return "System.String";
+ case "string[]":
+ return "System.String[]";
default:
return s;
}
diff --git a/src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs
index 857054f6883..d829a410619 100644
--- a/src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs
@@ -283,7 +283,7 @@ public ObservableCollection BrowserRootCategories
///
public NodeSearchElementViewModel FindViewModelForNode(string nodeName)
{
- var result = dynamoViewModel.Model.SearchModel.SearchEntries.Where(e => {
+ var result = Model.SearchEntries.Where(e => {
if (e.CreationName.Equals(nodeName))
{
return true;
diff --git a/test/DynamoCoreWpfTests/LibraryTests.cs b/test/DynamoCoreWpfTests/LibraryTests.cs
index 24371ae22d1..f05aefaf2fb 100644
--- a/test/DynamoCoreWpfTests/LibraryTests.cs
+++ b/test/DynamoCoreWpfTests/LibraryTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Dynamo;
@@ -32,7 +33,6 @@ public override void Setup()
libraryCore.ParsingMode = ParseMode.AllowNonAssignment;
var pathResolver = new TestPathResolver();
- pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");
var pathManager = new PathManager(new PathManagerParams
{
@@ -84,30 +84,9 @@ public static void OnLibraryLoadFailed(object sender, EventArgs e)
public void DumpLibraryToXmlZeroTouchTest()
{
var searchViewModel = new SearchViewModel(new NodeSearchModel());
-
- LibraryLoaded = false;
-
string libraryPath = "DSOffice.dll";
- // All we need to do here is to ensure that the target has been loaded
- // at some point, so if it's already here, don't try and reload it
- if (!libraryServices.IsLibraryLoaded(libraryPath))
- {
- libraryServices.ImportLibrary(libraryPath);
- Assert.IsTrue(LibraryLoaded);
- }
-
- var fgToCompare = libraryServices.GetFunctionGroups(libraryPath);
- foreach (var funcGroup in fgToCompare)
- {
- foreach (var functionDescriptor in funcGroup.Functions)
- {
- if (functionDescriptor.IsVisibleInLibrary && !functionDescriptor.DisplayName.Contains("GetType"))
- {
- searchViewModel.Model.Add(new ZeroTouchSearchElement(functionDescriptor));
- }
- }
- }
+ var fgToCompare = LoadLibraryIntoSearchViewModel(searchViewModel, libraryPath);
var document = searchViewModel.Model.ComposeXmlForLibrary(ExecutingDirectory);
@@ -157,30 +136,9 @@ public void DumpLibraryToXmlZeroTouchTest()
public void SearchHiddenInterfaceNodeTest()
{
var searchViewModel = new SearchViewModel(new NodeSearchModel());
-
- LibraryLoaded = false;
-
string libraryPath = "FFITarget.dll";
- // All we need to do here is to ensure that the target has been loaded
- // at some point, so if it's already here, don't try and reload it
- if (!libraryServices.IsLibraryLoaded(libraryPath))
- {
- libraryServices.ImportLibrary(libraryPath);
- Assert.IsTrue(LibraryLoaded);
- }
-
- var fgToCompare = libraryServices.GetFunctionGroups(libraryPath);
- foreach (var funcGroup in fgToCompare)
- {
- foreach (var functionDescriptor in funcGroup.Functions)
- {
- if (functionDescriptor.IsVisibleInLibrary && !functionDescriptor.DisplayName.Contains("GetType"))
- {
- searchViewModel.Model.Add(new ZeroTouchSearchElement(functionDescriptor));
- }
- }
- }
+ LoadLibraryIntoSearchViewModel(searchViewModel, libraryPath);
var searchString = "InterfaceA";
var nodes = searchViewModel.Search(searchString);
@@ -207,10 +165,47 @@ public void SearchHiddenInterfaceNodeTest()
public void SearchHiddenEnumTest()
{
var searchViewModel = new SearchViewModel(new NodeSearchModel());
+ string libraryPath = "FFITarget.dll";
- LibraryLoaded = false;
+ LoadLibraryIntoSearchViewModel(searchViewModel, libraryPath);
- string libraryPath = "FFITarget.dll";
+ var searchString = "Days";
+ var nodes = searchViewModel.Search(searchString);
+ var foundNodes = nodes.Where(n => n.Class.Equals(searchString));
+ Assert.IsFalse(foundNodes.Any());
+
+ searchString = "Sunday";
+ nodes = searchViewModel.Search(searchString);
+ foundNodes = nodes.Where(n => n.Class.Equals(searchString));
+ Assert.IsFalse(foundNodes.Any());
+
+ searchString = "Tuesday";
+ nodes = searchViewModel.Search(searchString);
+ foundNodes = nodes.Where(n => n.Class.Equals(searchString));
+ Assert.IsFalse(foundNodes.Any());
+ }
+
+ ///
+ /// Tests that the XmlDocumentationExtension is able to translate a DS mangled function name that contains
+ /// array parameters back into the correct .NET type based mangled name.
+ ///
+ [Test]
+ public void CanResolveCorrectOverloadByRecognizingDoubleArrayParameter()
+ {
+ var searchViewModel = new SearchViewModel(new NodeSearchModel());
+ var libraryPath = "ProtoGeometry.dll";
+
+ LoadLibraryIntoSearchViewModel(searchViewModel, libraryPath);
+
+ var node = searchViewModel.FindViewModelForNode("Autodesk.DesignScript.Geometry.Curve.SplitByParameter@double[]");
+ Assert.IsNotNull(node);
+ // This is the description of SplitByParameter(System.Double[]).
+ Assert.AreEqual("Split a Curve into multiple pieces at the given parameters", node.Description);
+ }
+
+ private IEnumerable LoadLibraryIntoSearchViewModel(SearchViewModel searchViewModel, string libraryPath)
+ {
+ LibraryLoaded = false;
// All we need to do here is to ensure that the target has been loaded
// at some point, so if it's already here, don't try and reload it
@@ -232,20 +227,7 @@ public void SearchHiddenEnumTest()
}
}
- var searchString = "Days";
- var nodes = searchViewModel.Search(searchString);
- var foundNodes = nodes.Where(n => n.Class.Equals(searchString));
- Assert.IsFalse(foundNodes.Any());
-
- searchString = "Sunday";
- nodes = searchViewModel.Search(searchString);
- foundNodes = nodes.Where(n => n.Class.Equals(searchString));
- Assert.IsFalse(foundNodes.Any());
-
- searchString = "Tuesday";
- nodes = searchViewModel.Search(searchString);
- foundNodes = nodes.Where(n => n.Class.Equals(searchString));
- Assert.IsFalse(foundNodes.Any());
+ return fgToCompare;
}
}
}