From a2be8c79af202b4d3b997c232337cae697fb7e33 Mon Sep 17 00:00:00 2001 From: Marko Ristin-Kaufmann Date: Sat, 3 Feb 2024 09:06:00 +0100 Subject: [PATCH] Use semantic patching to adapt aas-core-csharp At the moment, we manually change the source code of aas-core-csharp to adapt it and extend it for our needs. In this patch, we introduce a script which uses semantic patching (*i.e.*, analyzes the source code) and automatically adapts the aas-core-csharp. --- src/AasCore.Aas3_0/copying.cs | 20 +- src/AasCore.Aas3_0/types.cs | 876 ++++---- src/AasCore.Aas3_0/verification.cs | 164 +- src/AasCore.Aas3_0/visitation.cs | 7 +- src/AasCore.Aas3_0/xmlization.cs | 1955 ++++++++++++----- .../Folder.DotSettings | 6 + .../Program.cs | 616 ++++++ .../Script.SemanticallyPatchAasCore.csproj | 14 + 8 files changed, 2636 insertions(+), 1022 deletions(-) create mode 100644 src/Script.SemanticallyPatchAasCore/Folder.DotSettings create mode 100644 src/Script.SemanticallyPatchAasCore/Program.cs create mode 100644 src/Script.SemanticallyPatchAasCore/Script.SemanticallyPatchAasCore.csproj diff --git a/src/AasCore.Aas3_0/copying.cs b/src/AasCore.Aas3_0/copying.cs index 9cfb5dca6..5b06e3a47 100644 --- a/src/AasCore.Aas3_0/copying.cs +++ b/src/AasCore.Aas3_0/copying.cs @@ -3,8 +3,8 @@ * Do NOT edit or append. */ -using System.Collections.Generic; // can't alias using Aas = AasCore.Aas3_0; // renamed +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0 { @@ -1268,8 +1268,7 @@ Aas.IProperty that that.EmbeddedDataSpecifications.Count); foreach (var item in that.EmbeddedDataSpecifications) { - if (item.DataSpecification != null && item.DataSpecificationContent != null) - theEmbeddedDataSpecifications.Add(Deep(item)); + theEmbeddedDataSpecifications.Add(Deep(item)); } } @@ -2457,17 +2456,10 @@ public override Aas.IClass TransformEmbeddedDataSpecification( Aas.IEmbeddedDataSpecification that ) { - IReference? theDataSpecification = null; - if (that.DataSpecification != null) - { - theDataSpecification = Deep(that.DataSpecification); - } - IDataSpecificationContent? theDataSpecificationContent = null; - if (that.DataSpecificationContent != null) - { - theDataSpecificationContent = Deep(that.DataSpecificationContent); - } - return new Aas.EmbeddedDataSpecification(theDataSpecification, theDataSpecificationContent); + return new Aas.EmbeddedDataSpecification( + Deep(that.DataSpecification), + Deep(that.DataSpecificationContent) + ); } public override Aas.IClass TransformLevelType( diff --git a/src/AasCore.Aas3_0/types.cs b/src/AasCore.Aas3_0/types.cs index 3bf4f228b..82b824fff 100644 --- a/src/AasCore.Aas3_0/types.cs +++ b/src/AasCore.Aas3_0/types.cs @@ -2,12 +2,14 @@ * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. */ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; // can't alias + using Aas = AasCore.Aas3_0; // renamed using EnumMemberAttribute = System.Runtime.Serialization.EnumMemberAttribute; +using System.Collections.Generic; // can't alias + +using Newtonsoft.Json; // can't alias + namespace AasCore.Aas3_0 { /// @@ -383,11 +385,38 @@ public interface IHasExtensions : IClass /// An element that is referable by its . /// /// + /// /// This ID is not globally unique. /// This ID is unique within the name space of the element. + /// + /// + /// Constraints: + /// + /// /// public interface IReferable : IHasExtensions { + #region Parent + [JsonIgnore] + public IClass? Parent { get; set; } + #endregion + + #region TimeStamp + [JsonIgnore] + public System.DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public System.DateTime TimeStamp { get; set; } + [JsonIgnore] + public System.DateTime TimeStampTree { get; set; } + #endregion + + /// /// The category is a value that gives further meta information /// w.r.t. to the class of the element. @@ -439,21 +468,6 @@ public interface IReferable : IHasExtensions /// public List? Description { get; set; } - #region Parent - [JsonIgnore] - public IClass? Parent { get; set; } - #endregion - - #region TimeStamp - [JsonIgnore] - public DateTime TimeStampCreate { get; set; } - [JsonIgnore] - public DateTime TimeStamp { get; set; } - [JsonIgnore] - public DateTime TimeStampTree { get; set; } - - #endregion - /// /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. /// @@ -779,18 +793,20 @@ public AdministrativeInformation( /// /// /// - /// This constraint is checked at . - /// - /// /// Constraints: /// /// /// @@ -993,21 +1009,6 @@ public class Qualifier : IQualifier /// public IReference? ValueId { get; set; } - #region Parent - [JsonIgnore] - public IClass? Parent { get; set; } - #endregion - - #region TimeStamp - [JsonIgnore] - public DateTime TimeStampCreate { get; set; } - [JsonIgnore] - public DateTime TimeStamp { get; set; } - [JsonIgnore] - public DateTime TimeStampTree { get; set; } - - #endregion - /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -1196,6 +1197,21 @@ public interface IAssetAdministrationShell : /// public class AssetAdministrationShell : IAssetAdministrationShell { + #region Parent + [JsonIgnore] + public IClass? Parent { get; set; } + #endregion + + #region TimeStamp + [JsonIgnore] + public System.DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public System.DateTime TimeStamp { get; set; } + [JsonIgnore] + public System.DateTime TimeStampTree { get; set; } + #endregion + + /// /// An extension of the element. /// @@ -1297,21 +1313,6 @@ public class AssetAdministrationShell : IAssetAdministrationShell /// public List? Submodels { get; set; } - #region Parent - [JsonIgnore] - public IClass? Parent { get; set; } - #endregion - - #region TimeStamp - [JsonIgnore] - public DateTime TimeStampCreate { get; set; } - [JsonIgnore] - public DateTime TimeStamp { get; set; } - [JsonIgnore] - public DateTime TimeStampTree { get; set; } - - #endregion - /// /// Iterate over Extensions, if set, and otherwise return an empty enumerable. /// @@ -1605,31 +1606,33 @@ public AssetAdministrationShell( /// optional. /// /// - /// Constraint AASd-116 is important to enable a generic search across global - /// and specific asset IDs. - /// - /// - /// - /// In the book, Constraint AASd-116 imposes a - /// case-insensitive equality against globalAssetId. This is - /// culturally-dependent, and depends on the system settings. - /// For example, the case-folding for the letters "i" and "I" is - /// different in Turkish from English. - /// - /// - /// We implement the constraint as case-sensitive instead to allow - /// for interoperability across different culture settings. - /// - /// - /// /// Constraints: /// ///