diff --git a/aas_core_codegen/csharp/jsonization/_generate.py b/aas_core_codegen/csharp/jsonization/_generate.py index bfd62ae53..1bf3ae20c 100644 --- a/aas_core_codegen/csharp/jsonization/_generate.py +++ b/aas_core_codegen/csharp/jsonization/_generate.py @@ -23,6 +23,7 @@ INDENT2 as II, INDENT3 as III, INDENT4 as IIII, + INDENT5 as IIIII, ) @@ -381,6 +382,9 @@ def _generate_from_method_for_class( blocks.append(Stripped(args_init_writer.getvalue())) + if cls.serialization.with_model_type: + blocks.append(Stripped("string? modelType = null;")) + # endregion # region Switch on property name @@ -419,11 +423,42 @@ def _generate_from_method_for_class( return None, errors if cls.serialization.with_model_type: + model_type = naming.json_model_type(cls.name) + cases.append( Stripped( - """\ + f"""\ case "modelType": - continue;""" +{I}{{ +{II}if (keyValue.Value == null) +{II}{{ +{III}error = new Reporting.Error( +{IIII}"Expected a model type, but got null"); +{III}return null; +{II}}} +{II}modelType = DeserializeImplementation.StringFrom( +{III}keyValue.Value, +{III}out error); +{II}if (error != null) +{II}{{ +{III}error.PrependSegment( +{IIII}new Reporting.NameSegment( +{IIIII}"modelType")); +{III}return null; +{II}}} + +{II}if (modelType != "{model_type}") +{II}{{ +{III}error = new Reporting.Error( +{IIII}"Expected the model type '{model_type}', " + +{IIII}$"but got {{modelType}}"); +{III}error.PrependSegment( +{IIII}new Reporting.NameSegment( +{IIIII}"modelType")); +{III}return null; +{II}}} +{II}break; +{I}}}""" ) ) @@ -482,6 +517,19 @@ def _generate_from_method_for_class( blocks.append(Stripped(required_check_writer.getvalue())) + if cls.serialization.with_model_type: + blocks.append( + Stripped( + f"""\ +if (modelType == null) +{{ +{I}error = new Reporting.Error( +{II}"Required property \\"modelType\\" is missing"); +{I}return null; +}}""" + ) + ) + # endregion # region Pass in arguments to the constructor diff --git a/aas_core_codegen/naming.py b/aas_core_codegen/naming.py index a5132c89a..d433ccf38 100644 --- a/aas_core_codegen/naming.py +++ b/aas_core_codegen/naming.py @@ -79,6 +79,11 @@ def json_property(identifier: Identifier) -> Identifier: @ensure( lambda result: "_" not in result ) # This post-condition avoids naming conflicts with prefixing in the JSON schema. +@ensure( + lambda result: '"' not in result and "'" not in result and '\\' not in result + # This post-condition simplifies a lot of generator code since we can simply in-line + # the model type in strings. +) # fmt: on def json_model_type(identifier: Identifier) -> Identifier: """ diff --git a/test_data/csharp/test_main/aas_core_meta.v3/expected_output/jsonization.cs b/test_data/csharp/test_main/aas_core_meta.v3/expected_output/jsonization.cs index 83cc986a6..2fa54697f 100644 --- a/test_data/csharp/test_main/aas_core_meta.v3/expected_output/jsonization.cs +++ b/test_data/csharp/test_main/aas_core_meta.v3/expected_output/jsonization.cs @@ -1658,6 +1658,8 @@ internal static class DeserializeImplementation IReference? theDerivedFrom = null; List? theSubmodels = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -2082,7 +2084,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "AssetAdministrationShell") + { + error = new Reporting.Error( + "Expected the model type 'AssetAdministrationShell', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -2104,6 +2135,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.AssetAdministrationShell( theId ?? throw new System.InvalidOperationException( @@ -2697,6 +2735,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; List? theSubmodelElements = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -3231,7 +3271,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Submodel") + { + error = new Reporting.Error( + "Expected the model type 'Submodel', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -3246,6 +3315,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Submodel( theId ?? throw new System.InvalidOperationException( @@ -3451,6 +3527,8 @@ internal static class DeserializeImplementation List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -3906,7 +3984,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "RelationshipElement") + { + error = new Reporting.Error( + "Expected the model type 'RelationshipElement', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -3928,6 +4035,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.RelationshipElement( theFirst ?? throw new System.InvalidOperationException( @@ -4010,6 +4124,8 @@ internal static class DeserializeImplementation DataTypeDefXsd? theValueTypeListElement = null; List? theValue = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -4568,7 +4684,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "SubmodelElementList") + { + error = new Reporting.Error( + "Expected the model type 'SubmodelElementList', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -4583,6 +4728,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.SubmodelElementList( theTypeValueListElement ?? throw new System.InvalidOperationException( @@ -4632,6 +4784,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; List? theValue = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -5094,7 +5248,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "SubmodelElementCollection") + { + error = new Reporting.Error( + "Expected the model type 'SubmodelElementCollection', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -5104,6 +5287,13 @@ internal static class DeserializeImplementation + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.SubmodelElementCollection( theExtensions, theCategory, @@ -5221,6 +5411,8 @@ internal static class DeserializeImplementation string? theValue = null; IReference? theValueId = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -5700,7 +5892,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Property") + { + error = new Reporting.Error( + "Expected the model type 'Property', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -5715,6 +5936,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Property( theValueType ?? throw new System.InvalidOperationException( @@ -5763,6 +5991,8 @@ internal static class DeserializeImplementation List? theValue = null; IReference? theValueId = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -6249,7 +6479,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "MultiLanguageProperty") + { + error = new Reporting.Error( + "Expected the model type 'MultiLanguageProperty', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -6259,6 +6518,13 @@ internal static class DeserializeImplementation + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.MultiLanguageProperty( theExtensions, theCategory, @@ -6305,6 +6571,8 @@ internal static class DeserializeImplementation string? theMin = null; string? theMax = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -6784,7 +7052,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Range") + { + error = new Reporting.Error( + "Expected the model type 'Range', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -6799,6 +7096,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Range( theValueType ?? throw new System.InvalidOperationException( @@ -6846,6 +7150,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; IReference? theValue = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -7277,7 +7583,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "ReferenceElement") + { + error = new Reporting.Error( + "Expected the model type 'ReferenceElement', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -7287,6 +7622,13 @@ internal static class DeserializeImplementation + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.ReferenceElement( theExtensions, theCategory, @@ -7331,6 +7673,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; byte[]? theValue = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -7786,7 +8130,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Blob") + { + error = new Reporting.Error( + "Expected the model type 'Blob', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -7801,6 +8174,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Blob( theContentType ?? throw new System.InvalidOperationException( @@ -7848,6 +8228,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; string? theValue = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -8303,7 +8685,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "File") + { + error = new Reporting.Error( + "Expected the model type 'File', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -8318,6 +8729,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.File( theContentType ?? throw new System.InvalidOperationException( @@ -8366,6 +8784,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; List? theAnnotations = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -8876,7 +9296,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "AnnotatedRelationshipElement") + { + error = new Reporting.Error( + "Expected the model type 'AnnotatedRelationshipElement', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -8898,6 +9347,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.AnnotatedRelationshipElement( theFirst ?? throw new System.InvalidOperationException( @@ -8950,6 +9406,8 @@ internal static class DeserializeImplementation string? theGlobalAssetId = null; List? theSpecificAssetIds = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -9515,7 +9973,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Entity") + { + error = new Reporting.Error( + "Expected the model type 'Entity', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -9530,6 +10017,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Entity( theEntityType ?? throw new System.InvalidOperationException( @@ -10001,6 +10495,8 @@ internal static class DeserializeImplementation string? theMinInterval = null; string? theMaxInterval = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -10600,7 +11096,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "BasicEventElement") + { + error = new Reporting.Error( + "Expected the model type 'BasicEventElement', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -10629,6 +11154,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.BasicEventElement( theObserved ?? throw new System.InvalidOperationException( @@ -10687,6 +11219,8 @@ internal static class DeserializeImplementation List? theOutputVariables = null; List? theInoutputVariables = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -11259,7 +11793,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Operation") + { + error = new Reporting.Error( + "Expected the model type 'Operation', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -11269,6 +11832,13 @@ internal static class DeserializeImplementation + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Operation( theExtensions, theCategory, @@ -11382,6 +11952,8 @@ internal static class DeserializeImplementation List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -11789,7 +12361,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "Capability") + { + error = new Reporting.Error( + "Expected the model type 'Capability', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -11799,6 +12400,13 @@ internal static class DeserializeImplementation + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.Capability( theExtensions, theCategory, @@ -11840,6 +12448,8 @@ internal static class DeserializeImplementation List? theEmbeddedDataSpecifications = null; List? theIsCaseOf = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -12216,7 +12826,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "ConceptDescription") + { + error = new Reporting.Error( + "Expected the model type 'ConceptDescription', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -12231,6 +12870,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.ConceptDescription( theId ?? throw new System.InvalidOperationException( @@ -13988,6 +14634,8 @@ internal static class DeserializeImplementation string? theValue = null; ILevelType? theLevelType = null; + string? modelType = null; + foreach (var keyValue in obj) { switch (keyValue.Key) @@ -14374,7 +15022,36 @@ internal static class DeserializeImplementation break; } case "modelType": - continue; + { + if (keyValue.Value == null) + { + error = new Reporting.Error( + "Expected a model type, but got null"); + return null; + } + modelType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + + if (modelType != "DataSpecificationIec61360") + { + error = new Reporting.Error( + "Expected the model type 'DataSpecificationIec61360', " + + $"but got {modelType}"); + error.PrependSegment( + new Reporting.NameSegment( + "modelType")); + return null; + } + break; + } default: error = new Reporting.Error( $"Unexpected property: {keyValue.Key}"); @@ -14389,6 +15066,13 @@ internal static class DeserializeImplementation return null; } + if (modelType == null) + { + error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return null; + } + return new Aas.DataSpecificationIec61360( thePreferredName ?? throw new System.InvalidOperationException(