Repository navigation
Conversation
…low on the Descriptor property in Resource while using EntrySerialize
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1602 +/- ##
==========================================
- Coverage 56.33% 56.29% -0.04%
==========================================
Files 951 951
Lines 35835 35835
Branches 3519 3519
==========================================
- Hits 20186 20173 -13
- Misses 14657 14673 +16
+ Partials 992 989 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…eated a derived class whose base has self referencing property . This is the pattern which causes the stack overflow. Now only the Moryx is referenced in the Moryx.Tests which is intentional.
dbeuchler
left a comment
There was a problem hiding this comment.
Thanks for adjusting the tests. This is good now. I focussed now on the change.
I will link the issue which should presumably be accomplished with that.: #1423
Your change identifies that when SelfReferencingDerived inherits from SelfReferencingBase, the Self property (type SelfReferencingBase) doesnt match SelfReferencingDerived - but it's still a self-reference.
IsAssignableFrom catches this inheritance case not the instance. If ClassA has a property of type ClassB, and ClassB has a property of type ClassA, this will still stack overflow. It is also over-filtering legitimate properties and will skip any property whose type is an ancestor of the instance. For example, if a class has a property of type object that would be skipped because typeof(object).IsAssignableFrom(anyType) is always true.
Another real sample which is broken now. Any config property typed as ConfigBase, UpdatableEntry, IConfig, IUpdatableConfig, or even object would be silently dropped.
public class MyModuleConfig : ConfigBase
{
public ConfigBase SomeSubConfig { get; set; }
} I also talked with @1nf0rmagician about that topic and I/we think there could only be one solution: There must be some kind of cycle detection at the value level e.g., maintaining a HashSet (by reference) of already-visited instances during recursive encoding, and skipping when re-encountering an already-visited object. As far as I know this match how most serializers (Newtonsoft, System.Text.Json) handle this
Problem: The following code in a resource results in a stack overflow, if I open such a resource in the resource UI.
[EntrySerialize]
internal MyOwnStateBase State { get; private set; }
Even though, that could be 'fixed' by
[EntrySerialize]
public string StateAsString => State.ToString();
this should be handled in some way, so that users don't have to spend time on figuring out the root cause of why the application suddenly crashes.
Solution:
added a condition to exclude a self reference to avoid the stackoverflow on the Descriptor property in Resource while using EntrySerialize