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

Shall derived features be serialized? #114

Open
AnNeub opened this issue Dec 16, 2021 · 2 comments
Open

Shall derived features be serialized? #114

AnNeub opened this issue Dec 16, 2021 · 2 comments

Comments

@AnNeub
Copy link

AnNeub commented Dec 16, 2021

For my use case i want that a derived features shall be serialized. So far, independant of the transient flag, it is never serialized. For my point of view only transient shall determine if the feature is serialized or not.

Therefore I change the following lines in xmi.py

        for feat in obj._isset:
            if feat.derived or feat.transient:

to

        for feat in eclass.eAllStructuralFeatures():
            if feat.transient or not feat.derived and feat not in obj._isset:

What do you think about this topic?

@aranega
Copy link
Member

aranega commented Dec 18, 2021

Hi @AnNeub

Thanks for your message! Sorry for the dealy, I had to go again in EMF documentation and implementation to check all of that as you made me doubt.
You were right, by default, all non-transient features are serialized, derived or not. My mistake came from the fact that most of the time, derived attributes are also set as transient. I will change that in the XMI serializer with something probably like this:

for feat in obj._isset:
    if feat.transient:
        ...

I need to write tests to test this feature however :). I'm sorry, I have less time than usual lately to work on PyEcore, so it takes me time to include fixes.

@AnNeub
Copy link
Author

AnNeub commented Dec 18, 2021

No problem, I am happy if I can help to improve the library. The library really works great and I have learned a lot about python's internal functions by analysing your code.

Short remark on your solution: Removing the derivedwill be not sufficient, because it is not certain that the derived feature already exists in obj._isset. Therefore I do an iteration over all features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants