Skip to content

Commit 0ab30b3

Browse files
Verification and Validation of identical content compared to Original file
1 parent 3c2edd7 commit 0ab30b3

184 files changed

Lines changed: 65032 additions & 42991 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,80 @@ public static void RegisterPropertyHelper(this IHandlebars handlebars)
10471047
stringBuilder.AppendLine($"{childVariableName} => {childVariableName}.{oppositePropertyName});");
10481048
writer.WriteSafeString(stringBuilder + Environment.NewLine);
10491049
});
1050-
}
1050+
1051+
handlebars.RegisterHelper("Property.QueryHasDefaultValueWithDifferentValueThanDefault", (_, arguments) =>
1052+
{
1053+
if (arguments.Length != 1)
1054+
{
1055+
throw new ArgumentException("The #Property.QueryHasDefaultValueWithDifferentValueThanDefault supposed to have one argument");
1056+
}
1057+
1058+
if (arguments[0] is not IProperty property)
1059+
{
1060+
throw new ArgumentException("The #Property.QueryHasDefaultValueWithDifferentValueThanDefault argument supposed to be an IProperty");
1061+
}
1062+
1063+
return property.QueryIsEnum()
1064+
? property.QueryIsEnumPropertyWithDefaultValue()
1065+
: (property.QueryHasDefaultValue() && property.QueryIsDefaultValueDifferentThanDefault());
1066+
});
1067+
1068+
handlebars.RegisterHelper("Property.WriteDefaultValue", (writer, _, arguments) =>
1069+
{
1070+
if (arguments.Length != 1)
1071+
{
1072+
throw new ArgumentException("The #Property.WriteDefaultValue supposed to have one argument");
1073+
}
1074+
1075+
if (arguments[0] is not IProperty property)
1076+
{
1077+
throw new ArgumentException("The #Property.WriteDefaultValue argument supposed to be an IProperty");
1078+
}
1079+
1080+
if (property.QueryIsEnum())
1081+
{
1082+
writer.WriteSafeString($"{property.Type.Name}.{property.QueryDefaultValueAsString().CapitalizeFirstLetter()}");
1083+
}
1084+
else if (property.QueryIsString())
1085+
{
1086+
writer.WriteSafeString($"\"{property.QueryDefaultValueAsString()}\"");
1087+
}
1088+
else
1089+
{
1090+
writer.WriteSafeString($"{property.QueryDefaultValueAsString()}");
1091+
}
1092+
});
1093+
1094+
handlebars.RegisterHelper("Property.QueryIsEnumerableAndReferenceProperty", (_, arguments) =>
1095+
{
1096+
if (arguments.Length != 1)
1097+
{
1098+
throw new ArgumentException("The #Property.QueryIsEnumerableAndReferenceProperty supposed to have one argument");
1099+
}
1100+
1101+
if (arguments[0] is not IProperty property)
1102+
{
1103+
throw new ArgumentException("The #Property.QueryIsEnumerableAndReferenceProperty argument supposed to be an IProperty");
1104+
}
1105+
1106+
return property.QueryIsEnumerable() && property.QueryIsReferenceProperty();
1107+
});
1108+
1109+
handlebars.RegisterHelper("Property.IsTypeAbstract", (_, arguments) =>
1110+
{
1111+
if (arguments.Length != 1)
1112+
{
1113+
throw new ArgumentException("The #Property.IsTypeAbstract supposed to have one argument");
1114+
}
1115+
1116+
if (arguments[0] is not IProperty property)
1117+
{
1118+
throw new ArgumentException("The #Property.IsTypeAbstract argument supposed to be an IProperty");
1119+
}
1120+
1121+
return property.Type is IClassifier { IsAbstract: true };
1122+
});
1123+
}
10511124

10521125
/// <summary>
10531126
/// Gets the getter implementation for an <see cref="IProperty"/> that has been redefined, for DTO generation
Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,70 @@
11
{{#if (Property.QueryIsEnumerable property)}}
2-
{{#if (Property.QueryIsBool property)}}
3-
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
4-
{
2+
{{#unless (Property.QueryIsReferenceProperty property)}}
3+
{{#if (Property.QueryIsBool property)}}
4+
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
5+
{
56
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, string.Join(" ", poco.{{Property.WritePropertyName property}}));
6-
}
7-
{{else}}
8-
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
9-
{
7+
}
8+
{{else}}
9+
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
10+
{
1011
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, string.Join(" ", poco.{{Property.WritePropertyName property}}));
11-
}
12-
{{/if}}
12+
}
13+
{{/if}}
14+
{{/unless}}
1315
{{else}}
14-
{{#if (Property.QueryIsBool property)}}
15-
{{#if (Property.QueryIsImpliedIncluded property)}}
16-
if(includesImplied || poco.IsImpliedIncluded)
16+
{{#if (Property.QueryIsReferenceProperty property)}}
17+
if(writerOptions.WriteIdRefAsAttribute && poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri))
1718
{
18-
await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true");
19+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.Id.ToString());
1920
}
21+
{{else}}
22+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
23+
{{#unless (Property.QueryIsBool property)}}
24+
if(poco.{{Property.WritePropertyName property}} != {{Property.WriteDefaultValue property}})
25+
{
26+
{{/unless}}
27+
{{/if}}
28+
{{#if (Property.QueryIsBool property)}}
29+
{{#if (Property.QueryIsImpliedIncluded property)}}
30+
if(writerOptions.IncludeImplied || poco.IsImpliedIncluded)
31+
{
32+
await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true");
33+
}
34+
{{else}}
35+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
36+
if(!poco.{{Property.WritePropertyName property}})
37+
{
38+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, "false");
39+
}
40+
{{else}}
41+
if(poco.{{Property.WritePropertyName property}})
42+
{
43+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, "true");
44+
}
45+
{{/if}}
46+
{{/if}}
47+
{{else if (Property.QueryIsEnum property)}}
48+
{{#if (Property.QueryIsNullable property)}}
49+
if(poco.{{Property.WritePropertyName property}}.HasValue)
50+
{
51+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.Value.ToString().ToLower());
52+
}
53+
{{else}}
54+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString().ToLower());
55+
{{/if}}
56+
{{else if (Property.QueryIsNumeric property)}}
57+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture));
2058
{{else}}
21-
if(poco.{{Property.WritePropertyName property}})
22-
{
23-
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, "true");
24-
}
59+
if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}}))
60+
{
61+
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}});
62+
}
63+
{{/if}}
64+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
65+
{{#unless (Property.QueryIsBool property)}}
66+
}
67+
{{/unless}}
2568
{{/if}}
26-
{{else if (Property.QueryIsEnum property)}}
27-
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString());
28-
{{else if (Property.QueryIsNumeric property)}}
29-
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture));
30-
{{else}}
31-
if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}}))
32-
{
33-
await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}});
34-
}
3569
{{/if}}
3670
{{/if}}
Lines changed: 62 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,70 @@
11
{{#if (Property.QueryIsEnumerable property)}}
2-
{{#if (Property.QueryIsBool property)}}
3-
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
4-
{
5-
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}}));
6-
}
7-
{{else}}
8-
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
9-
{
10-
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}}));
11-
}
12-
{{/if}}
13-
{{else}}
14-
{{#if (Property.QueryIsBool property)}}
15-
{{#if (Property.QueryIsImpliedIncluded property)}}
16-
if(includesImplied || poco.IsImpliedIncluded)
17-
{
18-
xmlWriter.WriteAttributeString("isImpliedIncluded", "true");
19-
}
2+
{{#unless (Property.QueryIsReferenceProperty property)}}
3+
{{#if (Property.QueryIsBool property)}}
4+
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
5+
{
6+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}}));
7+
}
208
{{else}}
21-
if(poco.{{Property.WritePropertyName property}})
9+
if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0)
10+
{
11+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}}));
12+
}
13+
{{/if}}
14+
{{/unless}}
15+
{{else}}
16+
{{#if (Property.QueryIsReferenceProperty property)}}
17+
if(writerOptions.WriteIdRefAsAttribute && poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri))
2218
{
23-
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", "true");
19+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.Id.ToString());
2420
}
25-
{{/if}}
26-
{{else if (Property.QueryIsEnum property)}}
27-
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString());
28-
{{else if (Property.QueryIsNumeric property)}}
29-
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture));
3021
{{else}}
31-
if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}}))
32-
{
22+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
23+
{{#unless (Property.QueryIsBool property)}}
24+
if(poco.{{Property.WritePropertyName property}} != {{Property.WriteDefaultValue property}})
25+
{
26+
{{/unless}}
27+
{{/if}}
28+
{{#if (Property.QueryIsBool property)}}
29+
{{#if (Property.QueryIsImpliedIncluded property)}}
30+
if(writerOptions.IncludeImplied || poco.IsImpliedIncluded)
31+
{
32+
xmlWriter.WriteAttributeString("isImpliedIncluded", "true");
33+
}
34+
{{else}}
35+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
36+
if(!poco.{{Property.WritePropertyName property}})
37+
{
38+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", "false");
39+
}
40+
{{else}}
41+
if(poco.{{Property.WritePropertyName property}})
42+
{
43+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", "true");
44+
}
45+
{{/if}}
46+
{{/if}}
47+
{{else if (Property.QueryIsEnum property)}}
48+
{{#if (Property.QueryIsNullable property)}}
49+
if(poco.{{Property.WritePropertyName property}}.HasValue)
50+
{
51+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.Value.ToString().ToLower());
52+
}
53+
{{else}}
54+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString().ToLower());
55+
{{/if}}
56+
{{else if (Property.QueryIsNumeric property)}}
57+
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture));
58+
{{else}}
59+
if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}}))
60+
{
3361
xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}});
34-
}
62+
}
63+
{{/if}}
64+
{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}}
65+
{{#unless (Property.QueryIsBool property)}}
66+
}
67+
{{/unless}}
68+
{{/if}}
3569
{{/if}}
3670
{{/if}}

SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-async-template.hbs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
foreach(var item in poco.{{Property.WritePropertyName property}})
55
{
66
{{#if property.IsComposite}}
7-
await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", includeDerivedProperties, includesImplied, elementOriginMap, currentFileUri);
7+
await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
88
{{else}}
9-
await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri);
9+
await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
1010
{{/if}}
1111
}
1212
}
1313
{{else}}
1414
if(poco.{{Property.WritePropertyName property}} != null)
1515
{
1616
{{#if property.IsComposite}}
17-
await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", includeDerivedProperties, includesImplied, elementOriginMap, currentFileUri);
17+
await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
1818
{{else}}
19-
await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri);
19+
if(!writerOptions.WriteIdRefAsAttribute || !poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri))
20+
{
21+
await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
22+
}
2023
{{/if}}
2124
}
2225
{{/if}}

SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-template.hbs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
foreach(var item in poco.{{Property.WritePropertyName property}})
55
{
66
{{#if property.IsComposite}}
7-
this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", includeDerivedProperties, includesImplied, elementOriginMap, currentFileUri);
7+
this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
88
{{else}}
9-
this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri);
9+
this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
1010
{{/if}}
1111
}
1212
}
1313
{{else}}
1414
if(poco.{{Property.WritePropertyName property}} != null)
1515
{
1616
{{#if property.IsComposite}}
17-
this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", includeDerivedProperties, includesImplied, elementOriginMap, currentFileUri);
17+
this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
1818
{{else}}
19-
this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri);
19+
if(!writerOptions.WriteIdRefAsAttribute || !poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri))
20+
{
21+
this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}});
22+
}
2023
{{/if}}
2124
}
2225
{{/if}}

0 commit comments

Comments
 (0)