Skip to content

Commit

Permalink
commit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guirava committed Apr 3, 2024
1 parent d6a27e4 commit 104df40
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,36 @@ public static List<string> FlattenFieldPatch(string typeName)

public static List<string> FlattenField(string typeName, FlattenFieldContext ctx)
{
List<string>? fields;
Type? type = GetStrippedType(typeName);
if (type == null)
{
throw new Exception($"FlattenField: {typeName} is null.");
}

// Reset cache
_FlattenFieldCache = new Dictionary<string, List<string>>();
List<string>? fields = _FlattenField(typeName, ctx, 0);

// If the type is an interface, we need to expand all types that implement it
if (type.IsInterface)
{
fields = new List<string>();
var infImpls = GetTypesImplementingInterface(type.Name);
infImpls.ForEach(impl =>
{
var f = _FlattenField(impl, ctx, 0);
if (f != null && f.Any())
{
fields.AddRange(f);
}
});
}
else // Otherwise, just expand the type
{
fields = _FlattenField(typeName, ctx, 0);
}

// Reset cache
_FlattenFieldCache = new Dictionary<string, List<string>>();

if (fields==null)
Expand Down

0 comments on commit 104df40

Please sign in to comment.