Skip to content

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

@sgryphon

Description

@sgryphon

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions