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

If you put a EntrySerialize over a Resource itself and also use it in one of the properties, there will be a StackOverflow Exception #341

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

MathoMathiasCamara
Copy link
Contributor

@MathoMathiasCamara MathoMathiasCamara commented Sep 14, 2023

  • Added a check to ignore self reference properties
  • Added a check to ignore EntrySerializeAttribute from overriding the attribute on the base class.

Added extra check to avoid abstract class getting initialized
@MathoMathiasCamara MathoMathiasCamara added the bug Something isn't working label Sep 14, 2023
@MathoMathiasCamara MathoMathiasCamara added this to the Framework 6.2.3 milestone Sep 14, 2023
@MathoMathiasCamara MathoMathiasCamara self-assigned this Sep 14, 2023
@MathoMathiasCamara MathoMathiasCamara force-pushed the fix/entrySerializeOnClassAndProperty branch from 9bee1a3 to ad6c853 Compare September 20, 2023 06:30
Copy link
Contributor

@MarisaGoergen MarisaGoergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI shouldn't show even the resource graph if you put entry serialize on the class.

src/Moryx/Serialization/EntryConvert/EntryConvert.cs Outdated Show resolved Hide resolved
@MarisaGoergen
Copy link
Contributor

Why don't we just declare that it's not allowed to use EntrySerialize over classes? @Toxantron @dbeuchler

@dbeuchler
Copy link
Member

Why don't we just declare that it's not allowed to use EntrySerialize over classes? @Toxantron @dbeuchler

I have not read the full merge request but: the EntrySerializeAttribute was developed to define it on classes, methods and properties. If you write it on a class, the rules will be applied for the whole class except the member is modified by the attribute itself. You can also declare "Never" on a the class and just add members explicitly.

See line 123: https://github.com/PHOENIXCONTACT/MORYX-Framework/blob/dev/src/Moryx/Serialization/EntrySerializeSerialization.cs

As I remember: The Resource-Type declares EntrySerialize(Never). This should not be overridden by the developer. https://github.com/PHOENIXCONTACT/MORYX-Framework/blob/dev/src/Moryx.AbstractionLayer/Resources/Resource.cs

@Toxantron
Copy link
Member

As I remember: The Resource-Type declares EntrySerialize(Never). This should not be overridden by the developer.

We should defenitly prohibit the override. For MORYX 8 we could even forbid it on the level of attribute declaration. There is an option "AllowMultiple = false".

Copy link
Member

@Toxantron Toxantron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep in mind, there is a dedicated EntrySerializeSerialization. We should not change the behavior of the DefaultSerialization.

Instead we should isolate this either as a double declaration check in EntrySerializeSerialization and just checking for EntrySerizalize in ResourceSerialization.

Copy link
Member

@Toxantron Toxantron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing the behavior, just improve the code that reads the class property. This should give preference to the base class declaration over the incorrect override.

For MORYX 8 I suggest we declare the attribute to prohibit duplicate declaration.

Edit: A definition on derived types can not be prohibited. That means we just change the code to give preference to the base class.

src/Moryx/Serialization/EntrySerializeSerialization.cs Outdated Show resolved Hide resolved
@MathoMathiasCamara MathoMathiasCamara force-pushed the fix/entrySerializeOnClassAndProperty branch from f692b02 to 784f97c Compare October 4, 2023 12:22
@MathoMathiasCamara MathoMathiasCamara force-pushed the fix/entrySerializeOnClassAndProperty branch from 784f97c to e2dcc8a Compare October 4, 2023 12:25
@Toxantron Toxantron force-pushed the fix/entrySerializeOnClassAndProperty branch from 1f696cb to 6948a5d Compare October 12, 2023 06:07
@Toxantron Toxantron force-pushed the fix/entrySerializeOnClassAndProperty branch from 6948a5d to 1aa6a40 Compare October 12, 2023 06:24
@Toxantron Toxantron dismissed MarisaGoergen’s stale review October 12, 2023 08:33

Changes already applied

@Toxantron Toxantron merged commit d356d90 into dev Oct 26, 2023
7 checks passed
@Toxantron Toxantron deleted the fix/entrySerializeOnClassAndProperty branch October 26, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants