Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: missing column edges by correcting MergeSubResult handling for SharedObjects #1092

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all 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
14 changes: 7 additions & 7 deletions Elements/src/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void MergeSubResult(GatherSubElementsResult gatherResult, bool hasJsonIgn
{
if (isTypeRelatedToSharedObjects)
{
ElementsFromSharedObjectProperties.AddRange(gatherResult.ElementsFromSharedObjectProperties);
ElementsFromSharedObjectProperties.AddRange(gatherResult.Elements);
}
else
{
Expand Down Expand Up @@ -508,10 +508,10 @@ private GatherSubElementsResult RecursiveGatherSubElements(object obj)
// A dictionary created for the purpose of caching properties
// that we need to recurse, for types that we've seen before.
var props = new Dictionary<Type, List<PropertyInfo>>();
return RecursiveGatherSubElementsInternal(obj, props);
return RecursiveGatherSubElementsInternal(obj, props, false);
}

private GatherSubElementsResult RecursiveGatherSubElementsInternal(object obj, Dictionary<Type, List<PropertyInfo>> properties)
private GatherSubElementsResult RecursiveGatherSubElementsInternal(object obj, Dictionary<Type, List<PropertyInfo>> properties, bool parentHasJsonIgnore)
{
GatherSubElementsResult result = new GatherSubElementsResult();

Expand Down Expand Up @@ -585,13 +585,13 @@ private GatherSubElementsResult RecursiveGatherSubElementsInternal(object obj, D
}

// Do not save shared object to the model if it is marked with JsonIgnore (e.g. ElementRepresentation)
bool hasJsonIgnore = p.GetCustomAttributes(typeof(JsonIgnoreAttribute), true).Any();
bool hasJsonIgnore = parentHasJsonIgnore || p.GetCustomAttributes(typeof(JsonIgnoreAttribute), true).Any();

if (pValue is IList elems)
{
foreach (var item in elems)
{
var subElements = RecursiveGatherSubElementsInternal(item, properties);
var subElements = RecursiveGatherSubElementsInternal(item, properties, hasJsonIgnore);
result.MergeSubResult(subElements, hasJsonIgnore, isTypeRelatedToSharedObjects);
}
continue;
Expand All @@ -602,13 +602,13 @@ private GatherSubElementsResult RecursiveGatherSubElementsInternal(object obj, D
{
foreach (var value in dict.Values)
{
var subElements = RecursiveGatherSubElementsInternal(value, properties);
var subElements = RecursiveGatherSubElementsInternal(value, properties, hasJsonIgnore);
result.MergeSubResult(subElements, hasJsonIgnore, isTypeRelatedToSharedObjects);
}
continue;
}

var gatheredSubElements = RecursiveGatherSubElementsInternal(pValue, properties);
var gatheredSubElements = RecursiveGatherSubElementsInternal(pValue, properties, hasJsonIgnore);
result.MergeSubResult(gatheredSubElements, hasJsonIgnore, isTypeRelatedToSharedObjects);
}
catch (Exception ex)
Expand Down
Loading