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

The name property in attributes is not recognised in the generated model #21

Open
sgryphon opened this issue Dec 18, 2021 · 0 comments
Open

Comments

@sgryphon
Copy link
Contributor

This affects properties/telemetry, components, and relationships, all of which have a name property.

e.g. Using the following code:

        [TwinRelationship(Name = "rel_runs_lines", DisplayName = "Runs Production Lines")]
        public IList<ProductionLine> RunsLines { get; } = new List<ProductionLine>();

The serialization outputs with the name runsLines instead of rel_runs_lines as expected:

    {
      "target": "dtmi:factoryexample:models:productionline;1",
      "name": "runsLines",
      "@type": "Relationship",
      "displayName": "Runs Production Lines"
    }

The output should have "name": "rel_runs_lines"

The fix is:

  1. to first add some unit tests,
  2. then to override if the attribute property is set, similar to how Schema is handled. Make it consistent across the different attributes

e.g.

propertyAttribute!.Name ?? info.Name.ToCamelCase()

Also need to fix the Schema override so it works for Telemetry (not just Property).

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

1 participant