diff --git a/RubrikSecurityCloud/RubrikSecurityCloud.Common/ReflectionUtils.cs b/RubrikSecurityCloud/RubrikSecurityCloud.Common/ReflectionUtils.cs index 3e15425f4..384dde1fd 100644 --- a/RubrikSecurityCloud/RubrikSecurityCloud.Common/ReflectionUtils.cs +++ b/RubrikSecurityCloud/RubrikSecurityCloud.Common/ReflectionUtils.cs @@ -256,8 +256,36 @@ public static List FlattenFieldPatch(string typeName) public static List FlattenField(string typeName, FlattenFieldContext ctx) { + List? fields; + Type? type = GetStrippedType(typeName); + if (type == null) + { + throw new Exception($"FlattenField: {typeName} is null."); + } + + // Reset cache _FlattenFieldCache = new Dictionary>(); - List? 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(); + 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>(); if (fields==null)