Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
62 changes: 36 additions & 26 deletions src/DynamoCore/Library/FunctionDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,49 +318,59 @@ public IEnumerable<Tuple<string, string>> InputParameters
private set;
}

private string category;
/// <summary>
/// The category of this function.
/// </summary>
public string Category
{
get
{
if (category != null)
{
return category;
}
var categoryBuf = new StringBuilder();
categoryBuf.Append(GetRootCategory());

//if this is not BuiltIn function search NodeCategoryAttribute for it
if (ClassName != null)
{
//get function assembly
var asm = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x.GetName().Name == Path.GetFileNameWithoutExtension(Assembly))
.ToArray();

if (asm.Any() && asm.First().GetType(ClassName) != null)
try
Comment thread
mjkkirschner marked this conversation as resolved.
{
//get class type of function
var type = asm.First().GetType(ClassName);

//get NodeCategoryAttribute for this function if it was been defined
var nodeCat = type.GetMethods().Where(x => x.Name == FunctionName)
.Select(x => x.GetCustomAttribute(typeof(NodeCategoryAttribute)))
.Where(x => x != null)
.Cast<NodeCategoryAttribute>()
.Select(x => x.ElementCategory)
.FirstOrDefault();

//if attribute is found compose node category string with last part from attribute
if (!string.IsNullOrEmpty(nodeCat) && (
nodeCat == LibraryServices.Categories.Constructors
|| nodeCat == LibraryServices.Categories.Properties
|| nodeCat == LibraryServices.Categories.MemberFunctions))
var asm = AppDomain.CurrentDomain.Load(Path.GetFileNameWithoutExtension(Assembly));
Comment thread
pinzart90 marked this conversation as resolved.
Comment thread
pinzart90 marked this conversation as resolved.


if (asm != null && asm.GetType(ClassName) != null)
{
categoryBuf.Append("." + UnqualifedClassName + "." + nodeCat);
return categoryBuf.ToString();
//get class type of function
var type = asm.GetType(ClassName);

//get NodeCategoryAttribute for this function if it was been defined
Comment thread
mjkkirschner marked this conversation as resolved.
Outdated
var nodeCat = type.GetMethods().Where(x => x.Name == FunctionName)
.Select(x => x.GetCustomAttribute(typeof(NodeCategoryAttribute)))
.Where(x => x != null)
.Cast<NodeCategoryAttribute>()
.Select(x => x.ElementCategory)
.FirstOrDefault();

//if attribute is found compose node category string with last part from attribute
if (!string.IsNullOrEmpty(nodeCat) && (
nodeCat == LibraryServices.Categories.Constructors
|| nodeCat == LibraryServices.Categories.Properties
|| nodeCat == LibraryServices.Categories.MemberFunctions))
{
categoryBuf.Append("." + UnqualifedClassName + "." + nodeCat);
category = categoryBuf.ToString();
return category;
}
}
}
catch (Exception e)
{
Console.WriteLine($"Error while generating function descriptor category:{Assembly} {ClassName} {FunctionName} {e}");
}
}

switch (Type)
{
case FunctionType.Constructor:
Expand Down Expand Up @@ -583,7 +593,7 @@ private bool CheckIfFunctionIsMarkedExperimentalByPrefs(FunctionDescriptor fd)
}
return false;
}
internal bool IsExperimental { get;}
internal bool IsExperimental { get; }
}

}
1 change: 1 addition & 0 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3507,6 +3507,7 @@ internal void AddZeroTouchNodesToSearch(IEnumerable<FunctionGroup> functionGroup
{
var iDoc = LuceneUtility.InitializeIndexDocumentForNodes();
List<NodeSearchElement> nodes = new();

foreach (var funcGroup in functionGroups)
{
foreach (var functionDescriptor in funcGroup.Functions)
Expand Down
Loading