NMFCode / NMF

This repository contains the entire code for the .NET Modeling Framework
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

enum values differ between model and serialization #41

Closed Herbie60D closed 6 years ago

Herbie60D commented 6 years ago

Hello. When I use enumerations in my model and serialize it, NMF capitalizes the names of the enums instead of using the original names defined in the model.

Example: Model:

  <Types xsi:type="nmeta:Class" Name="TestElement">
    <Attributes IsOrdered="True" IsUnique="True" LowerBound="1" Type="nmeta:Enumeration #//Enum" Name="enum" />
  </Types>
  <Types xsi:type="nmeta:Enumeration" Name="Enum">
    <Literals Value="0" Name="first" />
    <Literals Value="1" Name="second" />
    <Literals Value="2" Name="third" />
  </Types>

Code that uses the model:

TestElement testElement = new TestElement();
testElement.Enum = MetaModel.Model.Enum.Second;

Serialization by NMF: <model:TestElement xmi:version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" enum="Second" xmlns:xmi="http://www.omg.org/XMI" xmlns:model="http://example.com/model" />

The value of the attribute "enum" should be "second" as defined in the meta model, but instead it seems as if it gets the name of the generated C# enumeration element. Since the code generation creates a Class EnumConverter and two functions ConvertFrom and ConvertTo to map between the C# enumeration and the model values, I think this was not intended.

Because of this naming issue, when I try to read the serialization with EMF the enum value cannot be found, because of the wrong name.

Could you fix this issue?

georghinkel commented 6 years ago

Hi,

Sorry, I am on holiday right now, will look after this issue as soon as I am back. However, this will only be 8th June.

Best,

Georg

Von: Herbie60Dmailto:notifications@github.com Gesendet: Montag, 14. Mai 2018 03:04 An: NMFCode/NMFmailto:NMF@noreply.github.com Cc: Subscribedmailto:subscribed@noreply.github.com Betreff: [NMFCode/NMF] enum values differ between model and serialization (#41)

Hello. When I use enumerations in my model and serialize it, NMF capitalizes the names of the enums instead of using the original names defined in the model.

Example: Model:

Code that uses the model:

TestElement testElement = new TestElement(); testElement.Enum = MetaModel.Model.Enum.Second;

Serialization by NMF:

The value of the attribute "enum" should be "second" as defined in the meta model, but instead it seems as if it gets the name of the generated C# enumeration element. Since the code generation creates a Class EnumConverter and two functions ConvertFrom and ConvertTo to map between the C# enumeration and the model values, I think this was not intended.

Because of this naming issue, when I try to read the serialization with EMF the enum value cannot be found, because of the wrong name.

Could you fix this issue?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/NMFCode/NMF/issues/41, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACIV197Yk_7Dq9CFLYv82-jz0HsdiiIzks5tyVaOgaJpZM4T9gI1.

Herbie60D commented 6 years ago

Thank you very much for your quick reply. Take your time and enjoy your vacation. For now, I have a workaround that I will later remove. You do a great job with NMF. Thanks for the good support.

Herbie60D commented 6 years ago

Hello. I hope you had nice holidays. Do you had some time to look on this issue?

georghinkel commented 6 years ago

Sorry that this took so long, I had completely forgotten about it. It should be fixed now.

Herbie60D commented 6 years ago

Thank you, I run my tests with the new version and the issue seems to be fixed now.