Skip to content

Commit

Permalink
Add non-abstract base classes as extension types
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Oct 5, 2022
1 parent 6591814 commit 8e7d40b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Bonsai.Core/WorkflowBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,19 @@ static IEnumerable<object> GetWorkflowElements(ExpressionBuilder builder)
}
}

static IEnumerable<Type> GetBaseTypes(Type type)
{
while (type != null && type != typeof(object) && !type.IsAbstract)
{
yield return type;
type = type.BaseType;
}
}

static IEnumerable<Type> GetExtensionTypes(ExpressionBuilderGraph workflow)
{
return workflow.SelectMany(node => GetWorkflowElements(node.Value))
.Select(element => element.GetType())
.SelectMany(element => GetBaseTypes(element.GetType()))
.Except(SerializerExtraTypes)
.Except(SerializerLegacyTypes);
}
Expand Down Expand Up @@ -837,7 +846,7 @@ static void WriteXmlAttributes(XmlReader reader, XmlWriter writer, bool lookupTy
}
}

types.Add(type);
types.UnionWith(GetBaseTypes(type));
if (!string.IsNullOrEmpty(typeArguments))
{
var typeRef = new CodeTypeReference(type);
Expand Down

0 comments on commit 8e7d40b

Please sign in to comment.