Skip to content

Commit 11fd9bc

Browse files
authored
Distinguish unknown operators from obsolete ones (#2622)
With the ObsoleteAttribute removed from the placeholder type for an unresolved operator, the editor no longer prefixes its description with "This operator is obsolete". The hatched node styling for unknown nodes is preserved through a dedicated NodeFlags.Unknown, set from the UnknownTypeBuilder base type instead of the removed attribute. Closes #2372
1 parent 5394943 commit 11fd9bc

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

Bonsai.Core/WorkflowBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,7 @@ public Type ResolveType(Assembly assembly, string typeName, bool ignoreCase)
576576
var errorMessage = string.Format(message, typeBuilder.FullName);
577577
var descriptionAttributeConstructor = typeof(DescriptionAttribute).GetConstructor(new[] { typeof(string) });
578578
var descriptionAttributeBuilder = new CustomAttributeBuilder(descriptionAttributeConstructor, new[] { errorMessage });
579-
var obsoleteAttributeConstructor = typeof(ObsoleteAttribute).GetConstructor(Type.EmptyTypes);
580-
var obsoleteAttributeBuilder = new CustomAttributeBuilder(obsoleteAttributeConstructor, new object[0]);
581579
typeBuilder.SetCustomAttribute(descriptionAttributeBuilder);
582-
typeBuilder.SetCustomAttribute(obsoleteAttributeBuilder);
583580
type = typeBuilder.CreateTypeInfo();
584581
dynamicTypes.Add(typeName, type);
585582
}

Bonsai.Editor/GraphModel/GraphNode.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public GraphNode(ExpressionBuilder value, int layer, IEnumerable<GraphEdge> succ
4444
}
4545

4646
if (obsolete) Flags |= NodeFlags.Obsolete;
47+
if (workflowElement is UnknownTypeBuilder) Flags |= NodeFlags.Unknown;
4748
if (expressionBuilder.IsBuildDependency()) Flags |= NodeFlags.BuildDependency;
4849
Category = elementCategoryAttribute.Category;
4950
Icon = new ElementIcon(workflowElement);
@@ -124,7 +125,7 @@ public Brush ModifierBrush
124125
{
125126
get
126127
{
127-
if ((Flags & NodeFlags.Obsolete) != 0) return ObsoleteBrush;
128+
if ((Flags & (NodeFlags.Obsolete | NodeFlags.Unknown)) != 0) return ObsoleteBrush;
128129
else if ((Flags & NodeFlags.Disabled) != 0) return DisabledBrush;
129130
else return null;
130131
}
@@ -191,7 +192,8 @@ enum NodeFlags
191192
NestedScope = 0x10,
192193
NestedGroup = 0x20,
193194
Annotation = 0x40,
194-
RangeUndefined = 0x80
195+
RangeUndefined = 0x80,
196+
Unknown = 0x100
195197
}
196198

197199
static class CategoryColors

0 commit comments

Comments
 (0)