Skip to content

Commit

Permalink
add scaledDecimal to v4 standard extension (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdouceur authored Oct 15, 2024
1 parent 772de8e commit e0e2364
Show file tree
Hide file tree
Showing 804 changed files with 19,416 additions and 18,204 deletions.
7 changes: 7 additions & 0 deletions dotnet/gen/MetamodelDigest/StandardElementDigest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public StandardElementDigest(JObject standardElementObj)
this.ElementName = ((JValue)standardElementObj["name"]).Value<string>();

this.Description = ((JObject)standardElementObj["description"]).Properties().ToDictionary(p => p.Name, p => ((JValue)p.Value).Value<string>());

this.SubElements = standardElementObj.TryGetValue("breakout", out JToken subElementsToken) ? ((JArray)subElementsToken).Select(s => new StandardSubElementDigest((JObject)s)).ToList() : new List<StandardSubElementDigest>();
}

/// <summary>
Expand All @@ -36,5 +38,10 @@ public StandardElementDigest(JObject standardElementObj)
/// Gets a language map describing element.
/// </summary>
public Dictionary<string, string> Description { get; }

/// <summary>
/// Gets a list of sub-element info, if any.
/// </summary>
public List<StandardSubElementDigest> SubElements { get; }
}
}
40 changes: 40 additions & 0 deletions dotnet/gen/MetamodelDigest/StandardSubElementDigest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace DTDLParser
{
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;

/// <summary>
/// Class that abstracts standard sub-element information extracted from the metamodel digest provided by the metaparser.
/// </summary>
public class StandardSubElementDigest
{
/// <summary>
/// Initializes a new instance of the <see cref="StandardSubElementDigest"/> class.
/// </summary>
/// <param name="subElementObj">A <c>JObject</c> from the metamodel digest containing information about a sub-element of a standard element.</param>
public StandardSubElementDigest(JObject subElementObj)
{
this.Name = ((JValue)subElementObj["name"]).Value<string>();

this.Schema = subElementObj.TryGetValue("schema", out JToken schemaToken) ? ((JValue)schemaToken).Value<string>() : null;

this.Description = subElementObj.TryGetValue("description", out JToken descriptioToken) ? ((JObject)descriptioToken).Properties().ToDictionary(p => p.Name, p => ((JValue)p.Value).Value<string>()) : new Dictionary<string, string>();
}

/// <summary>
/// Gets the name of the sub-element.
/// </summary>
public string Name { get; }

/// <summary>
/// Gets the schema of the element, if any.
/// </summary>
public string Schema { get; }

/// <summary>
/// Gets a language map describing element.
/// </summary>
public Dictionary<string, string> Description { get; }
}
}
1 change: 1 addition & 0 deletions dotnet/src/DTDLParser/generated/ContextCollection.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ private static ContextHistory GetDtdlContextHistory()
context4_0.AddTermDefinition("Relationship", new Dtmi("dtmi:dtdl:class:Relationship;4"), isMergeableType: false);
context4_0.AddTermDefinition("request", new Dtmi("dtmi:dtdl:property:request;4"), isMergeableType: false);
context4_0.AddTermDefinition("response", new Dtmi("dtmi:dtdl:property:response;4"), isMergeableType: false);
context4_0.AddTermDefinition("scaledDecimal", new Dtmi("dtmi:standard:schema:scaledDecimal;4"), isMergeableType: false);
context4_0.AddTermDefinition("schema", new Dtmi("dtmi:dtdl:property:schema;4"), isMergeableType: false);
context4_0.AddTermDefinition("Schema", new Dtmi("dtmi:dtdl:class:Schema;4"), isMergeableType: false);
context4_0.AddTermDefinition("SchemaField", new Dtmi("dtmi:dtdl:class:SchemaField;4"), isMergeableType: false);
Expand Down
24 changes: 24 additions & 0 deletions dotnet/src/DTDLParser/generated/ModelElements.g.json
Original file line number Diff line number Diff line change
Expand Up @@ -3464,6 +3464,30 @@
}
]
},
{
"@context": "dtmi:dtdl:context;4",
"@id": "dtmi:standard:schema:scaledDecimal;4",
"@type": "Object",
"description": {
"en-US": "A scaled decimal number equal to `value` * 10^`scale`"
},
"fields": [
{
"description": {
"en-US": "The significand of the scaled decimal value; not required to be integral or normalized"
},
"name": "value",
"schema": "decimal"
},
{
"description": {
"en-US": "Count of decimal places to shift `value` (positive left, negative right) to yield the scaled value"
},
"name": "scale",
"schema": "short"
}
]
},
{
"@context": [
"dtmi:dtdl:context;2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public class DocExampleUnitTest
[DataRow("UnspecifiedDocExample-en-US-15-V4")]
[DataRow("UnspecifiedDocExample-en-US-16-V4")]
[DataRow("UnspecifiedDocExample-en-US-17-V4")]
[DataRow("UnspecifiedDocExample-en-US-18-V4")]
[DataRow("UnspecifiedDocExample-en-US-2-V2")]
[DataRow("UnspecifiedDocExample-en-US-2-V3")]
[DataRow("UnspecifiedDocExample-en-US-2-V4")]
Expand Down
1 change: 1 addition & 0 deletions dotnet/tests/ParserUnitTest/generated/ParserUnitTest.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,7 @@ public void TestParser_R(string testName)
/// This method runs all test cases beginning with letter 'S'.
/// </remarks>
[TestMethod]
[DataRow("ScaledDecimalInstancesV4")]
[DataRow("SchemaV2")]
[DataRow("SchemaV3")]
[DataRow("SchemaV4")]
Expand Down
Loading

0 comments on commit e0e2364

Please sign in to comment.