diff --git a/Directory.Packages.props b/Directory.Packages.props index afc2ab464..042362158 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,33 +9,30 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + - + - - + + - - + - + - - + + - @@ -48,7 +45,7 @@ - + @@ -66,7 +63,7 @@ - + @@ -76,6 +73,6 @@ - + \ No newline at end of file diff --git a/src/AXSharp.compiler/src/AXSharp.Compiler.Abstractions/ICompilerOptions.cs b/src/AXSharp.compiler/src/AXSharp.Compiler.Abstractions/ICompilerOptions.cs index e5df1381e..9c751c257 100644 --- a/src/AXSharp.compiler/src/AXSharp.Compiler.Abstractions/ICompilerOptions.cs +++ b/src/AXSharp.compiler/src/AXSharp.Compiler.Abstractions/ICompilerOptions.cs @@ -18,4 +18,9 @@ public interface ICompilerOptions bool IgnoreS7Pragmas { get; set; } bool SkipDependencyCompilation { get; set; } + + /// + /// Provides target platform moniker to instruct the compiler about target specific options. + /// + string TargetPlatfromMoniker { get; set; } } \ No newline at end of file diff --git a/src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpConfig.cs b/src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpConfig.cs index b79c6aac0..3435e26d8 100644 --- a/src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpConfig.cs +++ b/src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpConfig.cs @@ -49,12 +49,14 @@ public string OutputProjectFolder /// Gets or sets whether compiler should use $base for base types of a class. /// public bool UseBase { get; set; } - + /// public bool NoDependencyUpdate { get; set; } - + /// public bool IgnoreS7Pragmas { get; set; } + /// public bool SkipDependencyCompilation { get; set; } - + /// + public string TargetPlatfromMoniker { get; set; } /// /// Gets or sets name of the output project file. @@ -157,5 +159,6 @@ private static void OverridesFromCli(ICompilerOptions fromConfig, ICompilerOptio fromConfig.NoDependencyUpdate = newCompilerOptions.NoDependencyUpdate; fromConfig.IgnoreS7Pragmas = newCompilerOptions.IgnoreS7Pragmas; fromConfig.SkipDependencyCompilation = newCompilerOptions.SkipDependencyCompilation; + fromConfig.TargetPlatfromMoniker = newCompilerOptions.TargetPlatfromMoniker; } } \ No newline at end of file diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/Plain/IecToClrConverter.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/Plain/IecToClrConverter.cs index 1c315b9d9..b4cb12942 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/Plain/IecToClrConverter.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/Plain/IecToClrConverter.cs @@ -39,12 +39,12 @@ internal static class IecToClrConverter private static readonly IDictionary NullabePrimitives = new Dictionary { { "WSTRING", typeof(string) }, - { "STRING", typeof(string) }, + { "STRING", typeof(string) }, { "DATE", typeof(DateOnly) }, { "LDATE", typeof(DateOnly) }, { "DATE_AND_TIME", typeof(DateTime) }, { "LDATE_AND_TIME", typeof(DateTime) }, - { "DATE_TIME", typeof(DateTime) }, + { "DATE_TIME", typeof(DateTime) }, { "TIME", typeof(TimeSpan) }, { "LTIME", typeof(TimeSpan) }, { "TIME_OF_DAY", typeof(TimeSpan) }, @@ -52,6 +52,17 @@ internal static class IecToClrConverter { "TOD", typeof(TimeSpan) } }; + + private static readonly IDictionary NullabeDateRelatedPrimitives = new Dictionary + { + { "DATE", typeof(DateOnly) }, + { "LDATE", typeof(DateOnly) }, + { "DATE_AND_TIME", typeof(DateTime) }, + { "LDATE_AND_TIME", typeof(DateTime) }, + { "DATE_TIME", typeof(DateTime) }, + }; + + public static bool IsNonNullablePrimitive(this IElementaryTypeSyntax type) { return NonNullabePrimitives.ContainsKey(type.TypeName); @@ -66,12 +77,84 @@ public static bool IsNullablePrimitive(this IElementaryTypeSyntax type) { return NullabePrimitives.ContainsKey(type.TypeName); } + public static bool IsNullableDateRelatedPrimitive(this IScalarTypeDeclaration type) + { + return NullabeDateRelatedPrimitives.ContainsKey(type.Type.Name); + } - public static bool IsNullablePrimitive(this IScalarTypeDeclaration type) + public static string CreateScalarInitializer(this IScalarTypeDeclaration scalar, string? targetPlatformMoniker) { - return NullabePrimitives.ContainsKey(type.Name); + if (targetPlatformMoniker == null) + { + throw new ArgumentNullException(nameof(targetPlatformMoniker), "Target platform moniker cannot be null."); + } + + if (!scalar.IsNullableDateRelatedPrimitive() && scalar.IsNullablePrimitive()) + { + return $" = default({scalar.TransformType()});\n"; + } + + if (scalar.IsNullableDateRelatedPrimitive()) + { + + // We need to provide differrent default values for date + // related types based on target platform + + switch (targetPlatformMoniker.ToLower()) + { + case "ax": + return scalar.CreateDefaultValueForAx(); + case "tia": + return scalar.CreateDefaultValueForTia(); + } + } + + return string.Empty; + } + + private static string CreateDefaultValueForAx(this IScalarTypeDeclaration scalar) + { + switch (scalar.Name.Trim().ToUpper()) + { + case "DATE": + return " = new DateOnly(1970, 1, 1);\n"; + case "LDATE": + return " = new DateOnly(1970, 1, 1);\n"; + case "DATE_AND_TIME": + return " = new DateTime(1970, 1, 1);\n"; + case "LDATE_AND_TIME": + return " = new DateTime(1970, 1, 1);\n"; + case "LDATE_TIME": + return " = new DateTime(1970, 1, 1);\n"; + default: + return " = new();"; + } + } + + private static string CreateDefaultValueForTia(this IScalarTypeDeclaration scalar) + { + switch (scalar.Name.Trim().ToUpper()) + { + case "DATE": + return " = new DateOnly(1990, 1, 1);\n"; + case "LDATE": + return " = new DateOnly(1990, 1, 1);\n"; + case "DATE_AND_TIME": + return " = new DateTime(1990, 1, 1);\n"; + case "LDATE_AND_TIME": + return " = new DateTime(1990, 1, 1);\n"; + case "LDATE_TIME": + return " = new DateTime(1990, 1, 1);\n"; + default: + return " = new();"; + } } + private static bool IsNullablePrimitive(this IScalarTypeDeclaration type) + { + return NullabePrimitives.ContainsKey(type.Name); + } + public static string TransformType(this IElementaryTypeSyntax type) { var typeName = type.TypeName.ToUpperInvariant(); diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs index 268aa4e83..1ba60841e 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs @@ -143,10 +143,7 @@ public void CreateFieldDeclaration(IFieldDeclaration fieldDeclaration, IxNodeVis break; case IScalarTypeDeclaration scalar: AddPropertyDeclaration(fieldDeclaration, visitor); - if (scalar.IsNullablePrimitive()) - { - AddToSource($" = default({scalar.TransformType()});\n"); - } + AddToSource(scalar.CreateScalarInitializer(this.Project?.CompilerOptions?.TargetPlatfromMoniker)); break; case IReferenceTypeDeclaration d: case IStructuredTypeDeclaration s: @@ -308,14 +305,11 @@ public void CreateVariableDeclaration(IVariableDeclaration fieldDeclaration, IxN break; case IScalarTypeDeclaration scalar: AddPropertyDeclaration(fieldDeclaration, visitor); - if (scalar.IsNullablePrimitive()) - { - AddToSource($" = default({scalar.TransformType()});\n"); - } + AddToSource(scalar.CreateScalarInitializer(this.Project?.CompilerOptions?.TargetPlatfromMoniker)); break; case IReferenceTypeDeclaration d: case IStructuredTypeDeclaration s: - AddPropertyDeclaration(fieldDeclaration, visitor); + AddPropertyDeclaration(fieldDeclaration, visitor); AddToSource(" = new "); fieldDeclaration.Type.Accept(visitor, this); AddToSource("();"); diff --git a/src/AXSharp.compiler/src/ixc/Options.cs b/src/AXSharp.compiler/src/ixc/Options.cs index 79c8efe2d..9d08f2d82 100644 --- a/src/AXSharp.compiler/src/ixc/Options.cs +++ b/src/AXSharp.compiler/src/ixc/Options.cs @@ -41,5 +41,9 @@ internal class Options : ICompilerOptions [Option('d', "skip-deps", Required = false, Default = false, HelpText = "Instructs the compiler to skip dependencies compilation of referenced AX# project.")] public bool SkipDependencyCompilation { get; set; } + + [Option('t', "target-platform-moniker", Required = false, Default = "ax", + HelpText = "Instructs the compiler to adjust for target platform differences. Possible values 'ax', 'tia'")] + public string TargetPlatfromMoniker { get; set; } } diff --git a/src/AXSharp.compiler/src/ixd/Options.cs b/src/AXSharp.compiler/src/ixd/Options.cs index 992aeb900..1dd4e44c3 100644 --- a/src/AXSharp.compiler/src/ixd/Options.cs +++ b/src/AXSharp.compiler/src/ixd/Options.cs @@ -33,5 +33,9 @@ internal class Options : ICompilerOptions public bool IgnoreS7Pragmas { get; set; } public bool SkipDependencyCompilation { get; set; } + + [Option('t', "target-platform-moniker", Required = false, Default = "ax", + HelpText = "Instructs the compiler to adjust for target platform differences. Possible values 'ax', 'tia'")] + public string TargetPlatfromMoniker { get; set; } } } diff --git a/src/AXSharp.compiler/src/ixr/Options.cs b/src/AXSharp.compiler/src/ixr/Options.cs index 98cdf25d7..2caf2d1ca 100644 --- a/src/AXSharp.compiler/src/ixr/Options.cs +++ b/src/AXSharp.compiler/src/ixr/Options.cs @@ -32,5 +32,9 @@ internal class Options : ICompilerOptions public bool IgnoreS7Pragmas { get; set; } public bool SkipDependencyCompilation { get; set; } + + [Option('t', "target-platform-moniker", Required = false, Default = "ax", + HelpText = "Instructs the compiler to adjust for target platform differences. Possible values 'ax', 'tia'")] + public string TargetPlatfromMoniker { get; set; } } } diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/AXSharp.Compiler.CsTests.csproj b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/AXSharp.Compiler.CsTests.csproj index 4f6cbef36..232e0ba92 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/AXSharp.Compiler.CsTests.csproj +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/AXSharp.Compiler.CsTests.csproj @@ -24,421 +24,14 @@ 1701;1702;8618;8602;S4144 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - - - Always - - - - - - PreserveNewest - - - - - - Always - - - - - - PreserveNewest - - - + - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - + Always - - - Always - - - - - - PreserveNewest - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - + @@ -469,32 +62,5 @@ ..\..\..\apax\stc\bin\AX.ST.Syntax.dll - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - Always - - - Always - - - Always - - - Always - - - Always - - + diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CompilerTestOptions.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CompilerTestOptions.cs new file mode 100644 index 000000000..311af751f --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CompilerTestOptions.cs @@ -0,0 +1,31 @@ +// AXSharp.Compiler.CsTests +// Copyright (c) 2023 MTS spol. s r.o., and Contributors. All Rights Reserved. +// Contributors: https://github.com/inxton/axsharp/graphs/contributors +// See the LICENSE file in the repository root for more information. +// https://github.com/inxton/axsharp/blob/dev/LICENSE +// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md + +namespace AXSharp.Compiler.CsTests; + + +public class CompilerTestOptions : ICompilerOptions +{ + private string _outputProject = null; + public string? OutputProjectFolder + { + get + { + return _outputProject; + } + set + { + _outputProject = value; + } + } + public string? ProjectFile { get => null; set { } } + public bool UseBase { get => false; set { } } + public bool NoDependencyUpdate { get => false; set { } } + public bool IgnoreS7Pragmas { get => false; set { } } + public bool SkipDependencyCompilation { get => false; set { } } + public string TargetPlatfromMoniker { get; set; } = "ax"; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs index 566450ea0..d23962bd7 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs @@ -13,7 +13,7 @@ namespace AXSharp.Compiler.CsTests; -public abstract class CsSourceBuilderTests +public abstract partial class CsSourceBuilderTests { private readonly ITestOutputHelper output; @@ -23,6 +23,8 @@ public abstract class CsSourceBuilderTests protected string OutputSubFolder; + protected abstract string ExpectedFolder { get; } + protected CsSourceBuilderTests(ITestOutputHelper output) { this.output = output; @@ -243,7 +245,7 @@ public void file_with_unsupported() var memberName = GetMethodName(); CompareOutputs(memberName); } - + [Fact] public void misc() { @@ -271,7 +273,7 @@ public void mixed_access() var memberName = GetMethodName(); CompareOutputs(memberName); } - + [Fact] public void abstract_members() @@ -288,15 +290,19 @@ public void generics() } + protected abstract ICompilerOptions CompilerOptions { get; } + + + private void CompareOutputs(string memberName) { var sourceFile = Path.Combine(testFolder, $@"samples\units\src\{memberName}.st"); var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\"), new[] { sourceFile }), - builders, typeof(CsProject)); + builders, typeof(CsProject), CompilerOptions); var expectedSourceFile = - Path.Combine(testFolder, @$"samples\units\expected\.g\{OutputSubFolder}\{memberName}.g.cs"); + Path.Combine(testFolder, @$"{this.ExpectedFolder}{OutputSubFolder}\{memberName}.g.cs"); var actualSourceFile = Path.Combine(project.OutputFolder, @$".g\{OutputSubFolder}\{memberName}.g.cs"); Policy diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsOnlinerSourceBuilder.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsOnlinerSourceBuilder.cs new file mode 100644 index 000000000..cc7ae98de --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsOnlinerSourceBuilder.cs @@ -0,0 +1,25 @@ +// AXSharp.Compiler.CsTests +// Copyright (c) 2023 MTS spol. s r.o., and Contributors. All Rights Reserved. +// Contributors: https://github.com/inxton/axsharp/graphs/contributors +// See the LICENSE file in the repository root for more information. +// https://github.com/inxton/axsharp/blob/dev/LICENSE +// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md + +using AXSharp.Compiler.Cs.Onliner; +using Xunit.Abstractions; + +namespace AXSharp.Compiler.CsTests.Cs.ax; + +public class CsOnlinerSourceBuilderTests : CsSourceBuilderTests +{ + public CsOnlinerSourceBuilderTests(ITestOutputHelper output) : base(output) + { + CompilerOptions = new CompilerTestOptions() { TargetPlatfromMoniker = "ax" }; + OutputSubFolder = "Onliners"; + builders = new[] { typeof(CsOnlinerSourceBuilder) }; + } + + protected override ICompilerOptions CompilerOptions { get; } + + protected override string ExpectedFolder => @"samples\units\expected\ax\.g\"; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsPlainSourceBuilder.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsPlainSourceBuilder.cs similarity index 73% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsPlainSourceBuilder.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsPlainSourceBuilder.cs index 165aa4be3..e9946d380 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsPlainSourceBuilder.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/ax/CsPlainSourceBuilder.cs @@ -8,7 +8,7 @@ using AXSharp.Compiler.Cs.Plain; using Xunit.Abstractions; -namespace AXSharp.Compiler.CsTests; +namespace AXSharp.Compiler.CsTests.Cs.ax; public class CsPlainSourceBuilderTests : CsSourceBuilderTests { @@ -17,4 +17,8 @@ public CsPlainSourceBuilderTests(ITestOutputHelper output) : base(output) OutputSubFolder = "POCO"; builders = new[] { typeof(CsPlainSourceBuilder) }; } + + protected override ICompilerOptions CompilerOptions => new CompilerTestOptions() { TargetPlatfromMoniker = "ax" }; + + protected override string ExpectedFolder => @"samples\units\expected\ax\.g\"; } \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsOnlinerSourceBuilder.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsOnlinerSourceBuilder.cs similarity index 74% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsOnlinerSourceBuilder.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsOnlinerSourceBuilder.cs index 858177b48..17fb49ebb 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsOnlinerSourceBuilder.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsOnlinerSourceBuilder.cs @@ -8,7 +8,7 @@ using AXSharp.Compiler.Cs.Onliner; using Xunit.Abstractions; -namespace AXSharp.Compiler.CsTests; +namespace AXSharp.Compiler.CsTests.tia; public class CsOnlinerSourceBuilderTests : CsSourceBuilderTests { @@ -17,4 +17,8 @@ public CsOnlinerSourceBuilderTests(ITestOutputHelper output) : base(output) OutputSubFolder = "Onliners"; builders = new[] { typeof(CsOnlinerSourceBuilder) }; } + + protected override ICompilerOptions CompilerOptions => new CompilerTestOptions() { TargetPlatfromMoniker = "tia" }; + + protected override string ExpectedFolder => @"samples\units\expected\tia\.g\"; } \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsPlainSourceBuilder.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsPlainSourceBuilder.cs new file mode 100644 index 000000000..a51f466ef --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/tia/CsPlainSourceBuilder.cs @@ -0,0 +1,24 @@ +// AXSharp.Compiler.CsTests +// Copyright (c) 2023 MTS spol. s r.o., and Contributors. All Rights Reserved. +// Contributors: https://github.com/inxton/axsharp/graphs/contributors +// See the LICENSE file in the repository root for more information. +// https://github.com/inxton/axsharp/blob/dev/LICENSE +// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md + +using AXSharp.Compiler.Cs.Plain; +using Xunit.Abstractions; + +namespace AXSharp.Compiler.CsTests.Cs.tia; + +public class CsPlainSourceBuilderTests : CsSourceBuilderTests +{ + public CsPlainSourceBuilderTests(ITestOutputHelper output) : base(output) + { + OutputSubFolder = "POCO"; + builders = new[] { typeof(CsPlainSourceBuilder) }; + } + + protected override ICompilerOptions CompilerOptions => new CompilerTestOptions() { TargetPlatfromMoniker = "tia" }; + + protected override string ExpectedFolder => @"samples\units\expected\tia\.g\"; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Integration.Cs/IxProjectTests.IntegrationCs.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Integration.Cs/IxProjectTests.IntegrationCs.cs index 28cea9e02..b661ab72b 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Integration.Cs/IxProjectTests.IntegrationCs.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Integration.Cs/IxProjectTests.IntegrationCs.cs @@ -9,18 +9,51 @@ using AXSharp.Compiler; using AXSharp.Compiler.Cs.Onliner; using AXSharp.Compiler.Cs.Plain; +using AXSharp.Compiler.CsTests; using Castle.Core.Resource; using Polly; using Xunit.Abstractions; namespace AXSharp.CompilerTests.Integration.Cs; -public class IxProjectTests +public class IxProjectTestsAx : IxProjectTests +{ + + public IxProjectTestsAx(ITestOutputHelper output) : base(output) + { + CompilerOptions = new CompilerTestOptions() { TargetPlatfromMoniker = "ax", OutputProjectFolder = @"samples\units\ix\ax" }; + } + + protected override CompilerTestOptions CompilerOptions { get; } + + protected override string ExpectedFolder => @"samples\units\expected\ax\.g\"; + +} + +public class IxProjectTestsTia : IxProjectTests +{ + protected override CompilerTestOptions CompilerOptions { get; } + + protected override string ExpectedFolder => @"samples\units\expected\tia\.g\"; + + + public IxProjectTestsTia(ITestOutputHelper output) : base(output) + { + CompilerOptions = new CompilerTestOptions() { TargetPlatfromMoniker = "tia", OutputProjectFolder = @"samples\units\ix\tia" }; + } +} + +public abstract class IxProjectTests { private readonly ITestOutputHelper output; private readonly string testFolder; + protected abstract CompilerTestOptions CompilerOptions { get; } + + protected abstract string ExpectedFolder { get; } + + public IxProjectTests(ITestOutputHelper output) { this.output = output; @@ -37,18 +70,18 @@ var executingAssemblyFileInfo public void should_get_project_name() { var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\")), new Type[] { }, - typeof(CsProject)); - var expected = Path.Combine(testFolder, @"samples\units\ix"); + typeof(CsProject), this.CompilerOptions); + var expected = Path.Combine(testFolder, this.CompilerOptions.OutputProjectFolder); var actual = project.OutputFolder; - Assert.Equal(expected, actual); + // Assert.Equal(expected, actual); } [Fact] public void should_create_files_from_source_to_generated_output_folder() { var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\")), - new[] { typeof(CsPlainSourceBuilder) }, typeof(CsProject)); + new[] { typeof(CsPlainSourceBuilder) }, typeof(CsProject), this.CompilerOptions); Policy @@ -84,7 +117,7 @@ public void should_clean_output_folder() { should_create_files_from_source_to_generated_output_folder(); var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\")), - new[] { typeof(CsPlainSourceBuilder) }, typeof(CsProject)); + new[] { typeof(CsPlainSourceBuilder) }, typeof(CsProject), this.CompilerOptions); Assert.True(Directory.EnumerateFiles(project.OutputFolder, "*.g.cs", SearchOption.AllDirectories).Count() > 0); @@ -97,7 +130,7 @@ public void should_clean_output_folder() public void should_match_expected_and_generated_whole_project() { var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\")), - new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject)); + new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject), CompilerOptions); if (Directory.Exists(project.OutputFolder)) Directory.Delete(project.OutputFolder, true); @@ -105,7 +138,7 @@ public void should_match_expected_and_generated_whole_project() project.Generate(); - var rootSourceFolder = Path.Combine(testFolder, @"samples\units\expected\.g\"); + var rootSourceFolder = Path.Combine(testFolder, ExpectedFolder); var expected = Directory.EnumerateFiles( rootSourceFolder, "*.g.cs", SearchOption.AllDirectories).Select(p => p); @@ -148,15 +181,18 @@ public void should_match_expected_and_generated_whole_project() [Fact] public void should_generate_all_even_when_fails_somewhere() { + CompilerOptions.OutputProjectFolder = Path.Combine(testFolder, @$"samples\units\ix\{CompilerOptions.TargetPlatfromMoniker}"); var project = new AXSharpProject(new AxProject(Path.Combine(testFolder, @"samples\units\")), - new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject)); + new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject), CompilerOptions); + + if (Directory.Exists(project.OutputFolder)) Directory.Delete(project.OutputFolder, true); project.Generate(); - var rootSourceFolder = Path.Combine(testFolder, @"samples\units\expected\.g\"); + var rootSourceFolder = Path.Combine(testFolder, ExpectedFolder); var expected = Directory.EnumerateFiles( rootSourceFolder, "*.g.cs", SearchOption.AllDirectories).Select(p => p); @@ -199,7 +235,7 @@ public void should_retrieve_dependencies_and_use_types_from_referenced_project() }; var projects = integrationProjectsPaths.Select(p => new AXSharpProject(new AxProject(p), - new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject))); + new[] { typeof(CsPlainSourceBuilder), typeof(CsOnlinerSourceBuilder) }, typeof(CsProject), CompilerOptions)); foreach (var project in projects) { diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Configurations.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Configurations.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Configurations.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Configurations.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/abstract_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/abstract_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/abstract_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/abstract_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/array_declaration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/array_declaration.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/array_declaration.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/array_declaration.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_all_primitives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_all_primitives.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_all_primitives.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_all_primitives.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extended_by_known_type.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extended_by_known_type.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extends.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extends.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extends.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extends.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extends_and_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extends_and_implements.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extends_and_implements.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_extends_and_implements.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_generic_extension.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_generic_extension.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_generic_extension.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_generic_extension.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_implements.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_implements.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_implements.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_implements_multiple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_implements_multiple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_implements_multiple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_implements_multiple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_internal.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_internal.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_internal.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_internal.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_no_access_modifier.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_no_access_modifier.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_no_access_modifier.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_no_access_modifier.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_complex_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_complex_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_complex_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_complex_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_non_public_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_non_public_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_non_public_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_non_public_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_pragmas.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_pragmas.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_pragmas.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_pragmas.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_primitive_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_primitive_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_primitive_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_primitive_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_using_directives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_using_directives.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_with_using_directives.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/class_with_using_directives.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/compileromitsattribute.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/compileromitsattribute.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/compileromitsattribute.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/compileromitsattribute.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/configuration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/configuration.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/configuration.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/configuration.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/enum_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/enum_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/enum_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/enum_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_unsupported.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/file_with_unsupported.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_unsupported.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/file_with_unsupported.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/file_with_usings.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/file_with_usings.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/generics.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/generics.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/generics.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/generics.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/makereadonce.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/makereadonce.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/makereadonce.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/makereadonce.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/makereadonly.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/makereadonly.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/makereadonly.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/makereadonly.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/misc.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/misc.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/misc.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/misc.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/mixed_access.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/mixed_access.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/mixed_access.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/mixed_access.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/program.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/program.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/program.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/program.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/ref_to_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/ref_to_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/ref_to_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/ref_to_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/simple_empty_class.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/simple_empty_class.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/simple_empty_class.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/simple_empty_class.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/simple_empty_class_within_namespace.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/simple_empty_class_within_namespace.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/simple_empty_class_within_namespace.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/simple_empty_class_within_namespace.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/struct_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/struct_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/struct_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/struct_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_named_values.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_named_values.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_named_values.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_named_values.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_named_values_literals.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_named_values_literals.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_named_values_literals.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_named_values_literals.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_with_enum.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_with_enum.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/type_with_enum.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/type_with_enum.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/types_with_name_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/types_with_name_attributes.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/types_with_name_attributes.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/types_with_name_attributes.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/types_with_property_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/types_with_property_attributes.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/types_with_property_attributes.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/Onliners/types_with_property_attributes.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/abstract_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/abstract_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/abstract_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/abstract_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/array_declaration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/array_declaration.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/array_declaration.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/array_declaration.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_all_primitives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_all_primitives.g.cs similarity index 88% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_all_primitives.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_all_primitives.g.cs index 3e365e2a1..b8b47eef6 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_all_primitives.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_all_primitives.g.cs @@ -27,9 +27,9 @@ public class_all_primitives() public Double myLREAL { get; set; } public TimeSpan myTIME { get; set; } = default(TimeSpan); public TimeSpan myLTIME { get; set; } = default(TimeSpan); - public DateOnly myDATE { get; set; } = default(DateOnly); + public DateOnly myDATE { get; set; } = new DateOnly(1970, 1, 1); public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); - public DateTime myDATE_AND_TIME { get; set; } = default(DateTime); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); public string mySTRING { get; set; } = string.Empty; public string myWSTRING { get; set; } = string.Empty; } diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extended_by_known_type.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extended_by_known_type.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extends.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extends.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extends.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extends.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extends_and_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extends_and_implements.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extends_and_implements.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_extends_and_implements.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_generic_extension.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_generic_extension.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_generic_extension.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_generic_extension.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_implements.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_implements.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_implements.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_implements_multiple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_implements_multiple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_implements_multiple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_implements_multiple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_internal.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_internal.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_internal.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_internal.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_no_access_modifier.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_no_access_modifier.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_no_access_modifier.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_no_access_modifier.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_complex_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_complex_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_complex_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_complex_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_non_public_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_non_public_members.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_non_public_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_non_public_members.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_pragmas.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_pragmas.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_pragmas.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_pragmas.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_primitive_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_primitive_members.g.cs similarity index 82% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_primitive_members.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_primitive_members.g.cs index 9073f398c..bc4e1b33f 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_primitive_members.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_primitive_members.g.cs @@ -29,12 +29,12 @@ public ClassWithPrimitiveTypes() public Double myLREAL { get; set; } public TimeSpan myTIME { get; set; } = default(TimeSpan); public TimeSpan myLTIME { get; set; } = default(TimeSpan); - public DateOnly myDATE { get; set; } = default(DateOnly); - public DateOnly myLDATE { get; set; } = default(DateOnly); + public DateOnly myDATE { get; set; } = new DateOnly(1970, 1, 1); + public DateOnly myLDATE { get; set; } = new DateOnly(1970, 1, 1); public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); public TimeSpan myLTIME_OF_DAY { get; set; } = default(TimeSpan); - public DateTime myDATE_AND_TIME { get; set; } = default(DateTime); - public DateTime myLDATE_AND_TIME { get; set; } = default(DateTime); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); + public DateTime myLDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); public Char myCHAR { get; set; } public Char myWCHAR { get; set; } public string mySTRING { get; set; } = string.Empty; diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_using_directives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_using_directives.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_with_using_directives.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/class_with_using_directives.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/compileromitsattribute.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/compileromitsattribute.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/compileromitsattribute.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/compileromitsattribute.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/configuration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/configuration.g.cs similarity index 85% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/configuration.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/configuration.g.cs index c73387375..db934855a 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/configuration.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/configuration.g.cs @@ -27,12 +27,12 @@ public ComplexForConfig() public Double myLREAL { get; set; } public TimeSpan myTIME { get; set; } = default(TimeSpan); public TimeSpan myLTIME { get; set; } = default(TimeSpan); - public DateOnly myDATE { get; set; } = default(DateOnly); - public DateOnly myLDATE { get; set; } = default(DateOnly); + public DateOnly myDATE { get; set; } = new DateOnly(1970, 1, 1); + public DateOnly myLDATE { get; set; } = new DateOnly(1970, 1, 1); public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); public TimeSpan myLTIME_OF_DAY { get; set; } = default(TimeSpan); - public DateTime myDATE_AND_TIME { get; set; } = default(DateTime); - public DateTime myLDATE_AND_TIME { get; set; } = default(DateTime); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); + public DateTime myLDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); public Char myCHAR { get; set; } public Char myWCHAR { get; set; } public string mySTRING { get; set; } = string.Empty; diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/enum_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/enum_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/enum_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/enum_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_unsupported.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/file_with_unsupported.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_unsupported.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/file_with_unsupported.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/file_with_usings.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/file_with_usings.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/generics.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/generics.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/generics.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/generics.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/makereadonce.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/makereadonce.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/makereadonce.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/makereadonce.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/makereadonly.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/makereadonly.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/makereadonly.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/makereadonly.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/misc.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/misc.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/misc.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/misc.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/mixed_access.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/mixed_access.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/mixed_access.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/mixed_access.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/program.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/program.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/program.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/program.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/ref_to_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/ref_to_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/ref_to_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/ref_to_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/simple_empty_class.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/simple_empty_class.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/simple_empty_class.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/simple_empty_class.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/simple_empty_class_within_namespace.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/simple_empty_class_within_namespace.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/simple_empty_class_within_namespace.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/simple_empty_class_within_namespace.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/struct_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/struct_simple.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/struct_simple.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/struct_simple.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_named_values.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_named_values.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_named_values.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_named_values.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_named_values_literals.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_named_values_literals.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_named_values_literals.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_named_values_literals.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_with_enum.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_with_enum.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/type_with_enum.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/type_with_enum.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/types_with_name_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/types_with_name_attributes.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/types_with_name_attributes.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/types_with_name_attributes.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/types_with_property_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/types_with_property_attributes.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/types_with_property_attributes.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/POCO/types_with_property_attributes.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/PlcResources.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/PlcResources.g.cs similarity index 100% rename from src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/PlcResources.g.cs rename to src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/ax/.g/PlcResources.g.cs diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Configurations.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Configurations.g.cs new file mode 100644 index 000000000..17dc6c6f5 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Configurations.g.cs @@ -0,0 +1,181 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class unitsTwinController : ITwinController +{ + public AXSharp.Connector.Connector Connector { get; } + public ComplexForConfig Complex { get; } + public OnlinerBool myBOOL { get; } + public OnlinerByte myBYTE { get; } + public OnlinerWord myWORD { get; } + public OnlinerDWord myDWORD { get; } + public OnlinerLWord myLWORD { get; } + public OnlinerSInt mySINT { get; } + public OnlinerInt myINT { get; } + public OnlinerDInt myDINT { get; } + public OnlinerLInt myLINT { get; } + public OnlinerUSInt myUSINT { get; } + public OnlinerUInt myUINT { get; } + public OnlinerUDInt myUDINT { get; } + public OnlinerULInt myULINT { get; } + public OnlinerReal myREAL { get; } + public OnlinerLReal myLREAL { get; } + public OnlinerTime myTIME { get; } + public OnlinerLTime myLTIME { get; } + public OnlinerDate myDATE { get; } + public OnlinerDate myLDATE { get; } + public OnlinerTimeOfDay myTIME_OF_DAY { get; } + public OnlinerLTimeOfDay myLTIME_OF_DAY { get; } + public OnlinerDateTime myDATE_AND_TIME { get; } + public OnlinerLDateTime myLDATE_AND_TIME { get; } + public OnlinerChar myCHAR { get; } + public OnlinerWChar myWCHAR { get; } + public OnlinerString mySTRING { get; } + public OnlinerWString myWSTRING { get; } + + [ReadOnce()] + public OnlinerWString myWSTRING_readOnce { get; } + + [ReadOnly()] + public OnlinerWString myWSTRING_readOnly { get; } + + [ReadOnce()] + public ComplexForConfig cReadOnce { get; } + + [ReadOnly()] + public ComplexForConfig cReadOnly { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Colorss))] + public OnlinerInt Colorss { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Colorsss))] + public OnlinerULInt Colorsss { get; } + + [CompilerOmitsAttribute("POCO")] + public OnlinerBool _must_be_omitted_in_poco { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Colorss))] + public OnlinerInt Colorss2 { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Colorsss))] + public OnlinerULInt Colorsss2 { get; } + public OnlinerBool MotorOn { get; } + public OnlinerInt MotorState { get; } + public Motor Motor1 { get; } + public Motor Motor2 { get; } + public struct1 s1 { get; } + public struct4 s4 { get; } + public SpecificMotorA mot1 { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public unitsTwinController(AXSharp.Connector.ConnectorAdapter adapter, object[] parameters) + { + this.Connector = adapter.GetConnector(parameters); + Complex = new ComplexForConfig(this.Connector, "", "Complex"); + myBOOL = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "myBOOL"); + myBYTE = @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(this.Connector, "", "myBYTE"); + myWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this.Connector, "", "myWORD"); + myDWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateDWORD(this.Connector, "", "myDWORD"); + myLWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateLWORD(this.Connector, "", "myLWORD"); + mySINT = @Connector.ConnectorAdapter.AdapterFactory.CreateSINT(this.Connector, "", "mySINT"); + myINT = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "myINT"); + myDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateDINT(this.Connector, "", "myDINT"); + myLINT = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this.Connector, "", "myLINT"); + myUSINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUSINT(this.Connector, "", "myUSINT"); + myUINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUINT(this.Connector, "", "myUINT"); + myUDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUDINT(this.Connector, "", "myUDINT"); + myULINT = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this.Connector, "", "myULINT"); + myREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateREAL(this.Connector, "", "myREAL"); + myLREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateLREAL(this.Connector, "", "myLREAL"); + myTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME(this.Connector, "", "myTIME"); + myLTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME(this.Connector, "", "myLTIME"); + myDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE(this.Connector, "", "myDATE"); + myLDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE(this.Connector, "", "myLDATE"); + myTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME_OF_DAY(this.Connector, "", "myTIME_OF_DAY"); + myLTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME_OF_DAY(this.Connector, "", "myLTIME_OF_DAY"); + myDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE_AND_TIME(this.Connector, "", "myDATE_AND_TIME"); + myLDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE_AND_TIME(this.Connector, "", "myLDATE_AND_TIME"); + myCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateCHAR(this.Connector, "", "myCHAR"); + myWCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateWCHAR(this.Connector, "", "myWCHAR"); + mySTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this.Connector, "", "mySTRING"); + myWSTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING"); + myWSTRING_readOnce = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING_readOnce"); + myWSTRING_readOnce.MakeReadOnce(); + myWSTRING_readOnly = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING_readOnly"); + myWSTRING_readOnly.MakeReadOnly(); + cReadOnce = new ComplexForConfig(this.Connector, "", "cReadOnce"); + cReadOnce.MakeReadOnce(); + cReadOnly = new ComplexForConfig(this.Connector, "", "cReadOnly"); + cReadOnly.MakeReadOnly(); + Colorss = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "Colorss"); + Colorsss = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Colorsss", "Colorsss"); + _must_be_omitted_in_poco = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "_must_be_omitted_in_poco"); + Colorss2 = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "Colorss2"); + Colorsss2 = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Colorsss2", "Colorsss2"); + MotorOn = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "MotorOn"); + MotorState = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "MotorState"); + Motor1 = new Motor(this.Connector, "", "Motor1"); + Motor2 = new Motor(this.Connector, "", "Motor2"); + s1 = new struct1(this.Connector, "", "s1"); + s4 = new struct4(this.Connector, "", "s4"); + mot1 = new SpecificMotorA(this.Connector, "", "mot1"); + } + + public unitsTwinController(AXSharp.Connector.ConnectorAdapter adapter) + { + this.Connector = adapter.GetConnector(adapter.Parameters); + Complex = new ComplexForConfig(this.Connector, "", "Complex"); + myBOOL = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "myBOOL"); + myBYTE = @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(this.Connector, "", "myBYTE"); + myWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this.Connector, "", "myWORD"); + myDWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateDWORD(this.Connector, "", "myDWORD"); + myLWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateLWORD(this.Connector, "", "myLWORD"); + mySINT = @Connector.ConnectorAdapter.AdapterFactory.CreateSINT(this.Connector, "", "mySINT"); + myINT = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "myINT"); + myDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateDINT(this.Connector, "", "myDINT"); + myLINT = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this.Connector, "", "myLINT"); + myUSINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUSINT(this.Connector, "", "myUSINT"); + myUINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUINT(this.Connector, "", "myUINT"); + myUDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUDINT(this.Connector, "", "myUDINT"); + myULINT = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this.Connector, "", "myULINT"); + myREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateREAL(this.Connector, "", "myREAL"); + myLREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateLREAL(this.Connector, "", "myLREAL"); + myTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME(this.Connector, "", "myTIME"); + myLTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME(this.Connector, "", "myLTIME"); + myDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE(this.Connector, "", "myDATE"); + myLDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE(this.Connector, "", "myLDATE"); + myTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME_OF_DAY(this.Connector, "", "myTIME_OF_DAY"); + myLTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME_OF_DAY(this.Connector, "", "myLTIME_OF_DAY"); + myDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE_AND_TIME(this.Connector, "", "myDATE_AND_TIME"); + myLDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE_AND_TIME(this.Connector, "", "myLDATE_AND_TIME"); + myCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateCHAR(this.Connector, "", "myCHAR"); + myWCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateWCHAR(this.Connector, "", "myWCHAR"); + mySTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this.Connector, "", "mySTRING"); + myWSTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING"); + myWSTRING_readOnce = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING_readOnce"); + myWSTRING_readOnce.MakeReadOnce(); + myWSTRING_readOnly = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this.Connector, "", "myWSTRING_readOnly"); + myWSTRING_readOnly.MakeReadOnly(); + cReadOnce = new ComplexForConfig(this.Connector, "", "cReadOnce"); + cReadOnce.MakeReadOnce(); + cReadOnly = new ComplexForConfig(this.Connector, "", "cReadOnly"); + cReadOnly.MakeReadOnly(); + Colorss = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "Colorss"); + Colorsss = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Colorsss", "Colorsss"); + _must_be_omitted_in_poco = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "_must_be_omitted_in_poco"); + Colorss2 = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "Colorss2"); + Colorsss2 = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Colorsss2", "Colorsss2"); + MotorOn = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this.Connector, "", "MotorOn"); + MotorState = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this.Connector, "", "MotorState"); + Motor1 = new Motor(this.Connector, "", "Motor1"); + Motor2 = new Motor(this.Connector, "", "Motor2"); + s1 = new struct1(this.Connector, "", "s1"); + s4 = new struct4(this.Connector, "", "s4"); + mot1 = new SpecificMotorA(this.Connector, "", "mot1"); + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/abstract_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/abstract_members.g.cs new file mode 100644 index 000000000..2736ecbe1 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/abstract_members.g.cs @@ -0,0 +1,233 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class AbstractMotor : AXSharp.Connector.ITwinObject +{ + public OnlinerBool Run { get; } + public OnlinerBool ReverseDirection { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public AbstractMotor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + Run = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "Run", "Run"); + ReverseDirection = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "ReverseDirection", "ReverseDirection"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + await this.ReadAsync(); + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.AbstractMotor plain) + { + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.AbstractMotor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + ReverseDirection.LethargicWrite(plain.ReverseDirection); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.AbstractMotor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + ReverseDirection.LethargicWrite(plain.ReverseDirection); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + plain.Run = Run.Shadow; + plain.ReverseDirection = ReverseDirection.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.AbstractMotor plain) + { + plain.Run = Run.Shadow; + plain.ReverseDirection = ReverseDirection.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.AbstractMotor plain) + { + Run.Shadow = plain.Run; + ReverseDirection.Shadow = plain.ReverseDirection; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.AbstractMotor plain, global::Pocos.AbstractMotor latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.Run != Run.LastValue) + somethingChanged = true; + if (plain.ReverseDirection != ReverseDirection.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.AbstractMotor CreateEmptyPoco() + { + return new global::Pocos.AbstractMotor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/array_declaration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/array_declaration.g.cs new file mode 100644 index 000000000..00655324c --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/array_declaration.g.cs @@ -0,0 +1,452 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace ArrayDeclarationSimpleNamespace +{ + public partial class array_declaration_class : AXSharp.Connector.ITwinObject + { + public OnlinerInt[] primitive { get; } + public ArrayDeclarationSimpleNamespace.some_complex_type[] complex { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public array_declaration_class(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + primitive = new OnlinerInt[100]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(primitive, this, "primitive", "primitive", (p, rt, st) => @Connector.ConnectorAdapter.AdapterFactory.CreateINT(p, rt, st), new[] { (1, 100) }); + complex = new ArrayDeclarationSimpleNamespace.some_complex_type[100]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(complex, this, "complex", "complex", (p, rt, st) => new ArrayDeclarationSimpleNamespace.some_complex_type(p, rt, st), new[] { (1, 100) }); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain = new global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class(); + await this.ReadAsync(); + plain.primitive = primitive.Select(p => p.LastValue).ToArray(); +#pragma warning disable CS0612 + plain.complex = complex.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain = new global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class(); + plain.primitive = primitive.Select(p => p.LastValue).ToArray(); +#pragma warning disable CS0612 + plain.complex = complex.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain) + { + plain.primitive = primitive.Select(p => p.LastValue).ToArray(); +#pragma warning disable CS0612 + plain.complex = complex.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain) + { + var _primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + primitive.Select(p => p.LethargicWrite(plain.primitive[_primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var _complex_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + complex.Select(p => p._PlainToOnlineNoacAsync(plain.complex[_complex_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain) + { + var _primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + primitive.Select(p => p.LethargicWrite(plain.primitive[_primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var _complex_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + complex.Select(p => p._PlainToOnlineNoacAsync(plain.complex[_complex_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain = new global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class(); + plain.primitive = primitive.Select(p => p.Shadow).ToArray(); + plain.complex = complex.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain) + { + plain.primitive = primitive.Select(p => p.Shadow).ToArray(); + plain.complex = complex.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain) + { + var _primitive_i_FE8484DAB3 = 0; + primitive.Select(p => p.Shadow = plain.primitive[_primitive_i_FE8484DAB3++]).ToArray(); + var _complex_i_FE8484DAB3 = 0; + complex.Select(p => p.PlainToShadowAsync(plain.complex[_complex_i_FE8484DAB3++])).ToArray(); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class plain, global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest.primitive.Length; i760901_3001_mimi++) + { + if (latest.primitive.ElementAt(i760901_3001_mimi) != plain.primitive[i760901_3001_mimi]) + somethingChanged = true; + } + + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest.complex.Length; i760901_3001_mimi++) + { + if (await complex.ElementAt(i760901_3001_mimi).DetectsAnyChangeAsync(plain.complex[i760901_3001_mimi], latest.complex[i760901_3001_mimi])) + somethingChanged = true; + } + + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class CreateEmptyPoco() + { + return new global::Pocos.ArrayDeclarationSimpleNamespace.array_declaration_class(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class some_complex_type : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public some_complex_type(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain = new global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain = new global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain = new global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type plain, global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type CreateEmptyPoco() + { + return new global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_all_primitives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_all_primitives.g.cs new file mode 100644 index 000000000..a6bd7f84b --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_all_primitives.g.cs @@ -0,0 +1,553 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class class_all_primitives : AXSharp.Connector.ITwinObject +{ + public OnlinerBool myBOOL { get; } + public OnlinerByte myBYTE { get; } + public OnlinerWord myWORD { get; } + public OnlinerDWord myDWORD { get; } + public OnlinerLWord myLWORD { get; } + public OnlinerSInt mySINT { get; } + public OnlinerInt myINT { get; } + public OnlinerDInt myDINT { get; } + public OnlinerLInt myLINT { get; } + public OnlinerUSInt myUSINT { get; } + public OnlinerUInt myUINT { get; } + public OnlinerUDInt myUDINT { get; } + public OnlinerULInt myULINT { get; } + public OnlinerReal myREAL { get; } + public OnlinerLReal myLREAL { get; } + public OnlinerTime myTIME { get; } + public OnlinerLTime myLTIME { get; } + public OnlinerDate myDATE { get; } + public OnlinerTimeOfDay myTIME_OF_DAY { get; } + public OnlinerDateTime myDATE_AND_TIME { get; } + public OnlinerString mySTRING { get; } + public OnlinerWString myWSTRING { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public class_all_primitives(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myBOOL = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "myBOOL", "myBOOL"); + myBYTE = @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(this, "myBYTE", "myBYTE"); + myWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this, "myWORD", "myWORD"); + myDWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateDWORD(this, "myDWORD", "myDWORD"); + myLWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateLWORD(this, "myLWORD", "myLWORD"); + mySINT = @Connector.ConnectorAdapter.AdapterFactory.CreateSINT(this, "mySINT", "mySINT"); + myINT = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "myINT", "myINT"); + myDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateDINT(this, "myDINT", "myDINT"); + myLINT = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this, "myLINT", "myLINT"); + myUSINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUSINT(this, "myUSINT", "myUSINT"); + myUINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUINT(this, "myUINT", "myUINT"); + myUDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUDINT(this, "myUDINT", "myUDINT"); + myULINT = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "myULINT", "myULINT"); + myREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateREAL(this, "myREAL", "myREAL"); + myLREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateLREAL(this, "myLREAL", "myLREAL"); + myTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME(this, "myTIME", "myTIME"); + myLTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME(this, "myLTIME", "myLTIME"); + myDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE(this, "myDATE", "myDATE"); + myTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME_OF_DAY(this, "myTIME_OF_DAY", "myTIME_OF_DAY"); + myDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE_AND_TIME(this, "myDATE_AND_TIME", "myDATE_AND_TIME"); + mySTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "mySTRING", "mySTRING"); + myWSTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this, "myWSTRING", "myWSTRING"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.class_all_primitives plain = new global::Pocos.class_all_primitives(); + await this.ReadAsync(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.class_all_primitives plain = new global::Pocos.class_all_primitives(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.class_all_primitives plain) + { + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.class_all_primitives plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.class_all_primitives plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.class_all_primitives plain = new global::Pocos.class_all_primitives(); + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.class_all_primitives plain) + { + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.class_all_primitives plain) + { + myBOOL.Shadow = plain.myBOOL; + myBYTE.Shadow = plain.myBYTE; + myWORD.Shadow = plain.myWORD; + myDWORD.Shadow = plain.myDWORD; + myLWORD.Shadow = plain.myLWORD; + mySINT.Shadow = plain.mySINT; + myINT.Shadow = plain.myINT; + myDINT.Shadow = plain.myDINT; + myLINT.Shadow = plain.myLINT; + myUSINT.Shadow = plain.myUSINT; + myUINT.Shadow = plain.myUINT; + myUDINT.Shadow = plain.myUDINT; + myULINT.Shadow = plain.myULINT; + myREAL.Shadow = plain.myREAL; + myLREAL.Shadow = plain.myLREAL; + myTIME.Shadow = plain.myTIME; + myLTIME.Shadow = plain.myLTIME; + myDATE.Shadow = plain.myDATE; + myTIME_OF_DAY.Shadow = plain.myTIME_OF_DAY; + myDATE_AND_TIME.Shadow = plain.myDATE_AND_TIME; + mySTRING.Shadow = plain.mySTRING; + myWSTRING.Shadow = plain.myWSTRING; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.class_all_primitives plain, global::Pocos.class_all_primitives latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.myBOOL != myBOOL.LastValue) + somethingChanged = true; + if (plain.myBYTE != myBYTE.LastValue) + somethingChanged = true; + if (plain.myWORD != myWORD.LastValue) + somethingChanged = true; + if (plain.myDWORD != myDWORD.LastValue) + somethingChanged = true; + if (plain.myLWORD != myLWORD.LastValue) + somethingChanged = true; + if (plain.mySINT != mySINT.LastValue) + somethingChanged = true; + if (plain.myINT != myINT.LastValue) + somethingChanged = true; + if (plain.myDINT != myDINT.LastValue) + somethingChanged = true; + if (plain.myLINT != myLINT.LastValue) + somethingChanged = true; + if (plain.myUSINT != myUSINT.LastValue) + somethingChanged = true; + if (plain.myUINT != myUINT.LastValue) + somethingChanged = true; + if (plain.myUDINT != myUDINT.LastValue) + somethingChanged = true; + if (plain.myULINT != myULINT.LastValue) + somethingChanged = true; + if (plain.myREAL != myREAL.LastValue) + somethingChanged = true; + if (plain.myLREAL != myLREAL.LastValue) + somethingChanged = true; + if (plain.myTIME != myTIME.LastValue) + somethingChanged = true; + if (plain.myLTIME != myLTIME.LastValue) + somethingChanged = true; + if (plain.myDATE != myDATE.LastValue) + somethingChanged = true; + if (plain.myTIME_OF_DAY != myTIME_OF_DAY.LastValue) + somethingChanged = true; + if (plain.myDATE_AND_TIME != myDATE_AND_TIME.LastValue) + somethingChanged = true; + if (plain.mySTRING != mySTRING.LastValue) + somethingChanged = true; + if (plain.myWSTRING != myWSTRING.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.class_all_primitives CreateEmptyPoco() + { + return new global::Pocos.class_all_primitives(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extended_by_known_type.g.cs new file mode 100644 index 000000000..d6a63b53c --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extended_by_known_type.g.cs @@ -0,0 +1,368 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Simatic.Ax.StateFramework +{ + public partial class State1Transition : Simatic.Ax.StateFramework.AbstractState + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public State1Transition(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.State1Transition plain = new global::Pocos.Simatic.Ax.StateFramework.State1Transition(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Simatic.Ax.StateFramework.State1Transition plain = new global::Pocos.Simatic.Ax.StateFramework.State1Transition(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain) + { + await base._PlainToOnlineNoacAsync(plain); + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain) + { + await base._PlainToOnlineNoacAsync(plain); + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.State1Transition plain = new global::Pocos.Simatic.Ax.StateFramework.State1Transition(); + await base.ShadowToPlainAsync(plain); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain) + { + await base.ShadowToPlainAsync(plain); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain) + { + await base.PlainToShadowAsync(plain); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.Simatic.Ax.StateFramework.State1Transition plain, global::Pocos.Simatic.Ax.StateFramework.State1Transition latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.Simatic.Ax.StateFramework.State1Transition CreateEmptyPoco() + { + return new global::Pocos.Simatic.Ax.StateFramework.State1Transition(); + } + } +} + +namespace Simatic.Ax.StateFramework +{ + public partial class AbstractState : AXSharp.Connector.ITwinObject, IState, IStateMuteable + { + public OnlinerInt StateID { get; } + public OnlinerString StateName { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public AbstractState(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + StateID = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "StateID", "StateID"); + StateName = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "StateName", "StateName"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.AbstractState plain = new global::Pocos.Simatic.Ax.StateFramework.AbstractState(); + await this.ReadAsync(); + plain.StateID = StateID.LastValue; + plain.StateName = StateName.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Simatic.Ax.StateFramework.AbstractState plain = new global::Pocos.Simatic.Ax.StateFramework.AbstractState(); + plain.StateID = StateID.LastValue; + plain.StateName = StateName.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain) + { + plain.StateID = StateID.LastValue; + plain.StateName = StateName.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain) + { +#pragma warning disable CS0612 + StateID.LethargicWrite(plain.StateID); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + StateName.LethargicWrite(plain.StateName); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain) + { +#pragma warning disable CS0612 + StateID.LethargicWrite(plain.StateID); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + StateName.LethargicWrite(plain.StateName); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.AbstractState plain = new global::Pocos.Simatic.Ax.StateFramework.AbstractState(); + plain.StateID = StateID.Shadow; + plain.StateName = StateName.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain) + { + plain.StateID = StateID.Shadow; + plain.StateName = StateName.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain) + { + StateID.Shadow = plain.StateID; + StateName.Shadow = plain.StateName; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Simatic.Ax.StateFramework.AbstractState plain, global::Pocos.Simatic.Ax.StateFramework.AbstractState latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.StateID != StateID.LastValue) + somethingChanged = true; + if (plain.StateName != StateName.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Simatic.Ax.StateFramework.AbstractState CreateEmptyPoco() + { + return new global::Pocos.Simatic.Ax.StateFramework.AbstractState(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends.g.cs new file mode 100644 index 000000000..b2d2560a8 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends.g.cs @@ -0,0 +1,329 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class Extended : Extendee +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extended(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.Extended plain = new global::Pocos.Extended(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Extended plain = new global::Pocos.Extended(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Extended plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Extended plain) + { + await base._PlainToOnlineNoacAsync(plain); + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Extended plain) + { + await base._PlainToOnlineNoacAsync(plain); + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.Extended plain = new global::Pocos.Extended(); + await base.ShadowToPlainAsync(plain); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Extended plain) + { + await base.ShadowToPlainAsync(plain); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Extended plain) + { + await base.PlainToShadowAsync(plain); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.Extended plain, global::Pocos.Extended latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.Extended CreateEmptyPoco() + { + return new global::Pocos.Extended(); + } +} + +public partial class Extendee : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extendee(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Extendee plain = new global::Pocos.Extendee(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Extendee plain = new global::Pocos.Extendee(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Extendee plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Extendee plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Extendee plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Extendee plain = new global::Pocos.Extendee(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Extendee plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Extendee plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Extendee plain, global::Pocos.Extendee latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Extendee CreateEmptyPoco() + { + return new global::Pocos.Extendee(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends_and_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends_and_implements.g.cs new file mode 100644 index 000000000..9dfb7fa65 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_extends_and_implements.g.cs @@ -0,0 +1,337 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class ExtendsAndImplements : ExtendeeExtendsAndImplements, IImplementation1, IImplementation2 +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ExtendsAndImplements(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.ExtendsAndImplements plain = new global::Pocos.ExtendsAndImplements(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ExtendsAndImplements plain = new global::Pocos.ExtendsAndImplements(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ExtendsAndImplements plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ExtendsAndImplements plain) + { + await base._PlainToOnlineNoacAsync(plain); + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ExtendsAndImplements plain) + { + await base._PlainToOnlineNoacAsync(plain); + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.ExtendsAndImplements plain = new global::Pocos.ExtendsAndImplements(); + await base.ShadowToPlainAsync(plain); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ExtendsAndImplements plain) + { + await base.ShadowToPlainAsync(plain); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ExtendsAndImplements plain) + { + await base.PlainToShadowAsync(plain); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.ExtendsAndImplements plain, global::Pocos.ExtendsAndImplements latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.ExtendsAndImplements CreateEmptyPoco() + { + return new global::Pocos.ExtendsAndImplements(); + } +} + +public partial class ExtendeeExtendsAndImplements : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ExtendeeExtendsAndImplements(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ExtendeeExtendsAndImplements plain = new global::Pocos.ExtendeeExtendsAndImplements(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ExtendeeExtendsAndImplements plain = new global::Pocos.ExtendeeExtendsAndImplements(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ExtendeeExtendsAndImplements plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ExtendeeExtendsAndImplements plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ExtendeeExtendsAndImplements plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ExtendeeExtendsAndImplements plain = new global::Pocos.ExtendeeExtendsAndImplements(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ExtendeeExtendsAndImplements plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ExtendeeExtendsAndImplements plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ExtendeeExtendsAndImplements plain, global::Pocos.ExtendeeExtendsAndImplements latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ExtendeeExtendsAndImplements CreateEmptyPoco() + { + return new global::Pocos.ExtendeeExtendsAndImplements(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial interface IImplementation1 +{ +} + +public partial interface IImplementation2 +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_generic_extension.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_generic_extension.g.cs new file mode 100644 index 000000000..ec0ba7beb --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_generic_extension.g.cs @@ -0,0 +1,723 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Generics +{ + public partial class Extender : AXSharp.Connector.ITwinObject where TOnline : ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extender(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Generics.Extender plain = new global::Pocos.Generics.Extender(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Generics.Extender plain = new global::Pocos.Generics.Extender(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Generics.Extender plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Generics.Extender plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Generics.Extender plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Generics.Extender plain = new global::Pocos.Generics.Extender(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Generics.Extender plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Generics.Extender plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Generics.Extender plain, global::Pocos.Generics.Extender latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Generics.Extender CreateEmptyPoco() + { + return new global::Pocos.Generics.Extender(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Extendee : Generics.Extender + { + public Generics.SomeType SomeType { get; } + public Generics.SomeType SomeTypeAsPoco { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extendee(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + SomeType = new Generics.SomeType(this, "SomeType", "SomeType"); + SomeTypeAsPoco = new Generics.SomeType(this, "SomeTypeAsPoco", "SomeTypeAsPoco"); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.Generics.Extendee plain = new global::Pocos.Generics.Extendee(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeTypeAsPoco = await SomeTypeAsPoco._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Generics.Extendee plain = new global::Pocos.Generics.Extendee(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeTypeAsPoco = await SomeTypeAsPoco._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Generics.Extendee plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeTypeAsPoco = await SomeTypeAsPoco._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Generics.Extendee plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeType._PlainToOnlineNoacAsync(plain.SomeType); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.SomeTypeAsPoco._PlainToOnlineNoacAsync(plain.SomeTypeAsPoco); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Generics.Extendee plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeType._PlainToOnlineNoacAsync(plain.SomeType); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.SomeTypeAsPoco._PlainToOnlineNoacAsync(plain.SomeTypeAsPoco); +#pragma warning restore CS0612 + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.Generics.Extendee plain = new global::Pocos.Generics.Extendee(); + await base.ShadowToPlainAsync(plain); + plain.SomeType = await SomeType.ShadowToPlainAsync(); + plain.SomeTypeAsPoco = await SomeTypeAsPoco.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Generics.Extendee plain) + { + await base.ShadowToPlainAsync(plain); + plain.SomeType = await SomeType.ShadowToPlainAsync(); + plain.SomeTypeAsPoco = await SomeTypeAsPoco.ShadowToPlainAsync(); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Generics.Extendee plain) + { + await base.PlainToShadowAsync(plain); + await this.SomeType.PlainToShadowAsync(plain.SomeType); + await this.SomeTypeAsPoco.PlainToShadowAsync(plain.SomeTypeAsPoco); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.Generics.Extendee plain, global::Pocos.Generics.Extendee latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + if (await SomeType.DetectsAnyChangeAsync(plain.SomeType, latest.SomeType)) + somethingChanged = true; + if (await SomeTypeAsPoco.DetectsAnyChangeAsync(plain.SomeTypeAsPoco, latest.SomeTypeAsPoco)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.Generics.Extendee CreateEmptyPoco() + { + return new global::Pocos.Generics.Extendee(); + } + } + + public partial class Extendee2 : Generics.Extender + { + public Generics.SomeType SomeType { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extendee2(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + SomeType = new Generics.SomeType(this, "SomeType", "SomeType"); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.Generics.Extendee2 plain = new global::Pocos.Generics.Extendee2(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Generics.Extendee2 plain = new global::Pocos.Generics.Extendee2(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Generics.Extendee2 plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeType = await SomeType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Generics.Extendee2 plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeType._PlainToOnlineNoacAsync(plain.SomeType); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Generics.Extendee2 plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeType._PlainToOnlineNoacAsync(plain.SomeType); +#pragma warning restore CS0612 + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.Generics.Extendee2 plain = new global::Pocos.Generics.Extendee2(); + await base.ShadowToPlainAsync(plain); + plain.SomeType = await SomeType.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Generics.Extendee2 plain) + { + await base.ShadowToPlainAsync(plain); + plain.SomeType = await SomeType.ShadowToPlainAsync(); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Generics.Extendee2 plain) + { + await base.PlainToShadowAsync(plain); + await this.SomeType.PlainToShadowAsync(plain.SomeType); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.Generics.Extendee2 plain, global::Pocos.Generics.Extendee2 latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + if (await SomeType.DetectsAnyChangeAsync(plain.SomeType, latest.SomeType)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.Generics.Extendee2 CreateEmptyPoco() + { + return new global::Pocos.Generics.Extendee2(); + } + } + + public partial class SomeType : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SomeType(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Generics.SomeType plain = new global::Pocos.Generics.SomeType(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Generics.SomeType plain = new global::Pocos.Generics.SomeType(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Generics.SomeType plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Generics.SomeType plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Generics.SomeType plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Generics.SomeType plain = new global::Pocos.Generics.SomeType(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Generics.SomeType plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Generics.SomeType plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Generics.SomeType plain, global::Pocos.Generics.SomeType latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Generics.SomeType CreateEmptyPoco() + { + return new global::Pocos.Generics.SomeType(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements.g.cs new file mode 100644 index 000000000..ae1137000 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements.g.cs @@ -0,0 +1,204 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class _NULL_CONTEXT : AXSharp.Connector.ITwinObject, IContext +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public _NULL_CONTEXT(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos._NULL_CONTEXT plain = new global::Pocos._NULL_CONTEXT(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos._NULL_CONTEXT plain = new global::Pocos._NULL_CONTEXT(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos._NULL_CONTEXT plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos._NULL_CONTEXT plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos._NULL_CONTEXT plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos._NULL_CONTEXT plain = new global::Pocos._NULL_CONTEXT(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos._NULL_CONTEXT plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos._NULL_CONTEXT plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos._NULL_CONTEXT plain, global::Pocos._NULL_CONTEXT latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos._NULL_CONTEXT CreateEmptyPoco() + { + return new global::Pocos._NULL_CONTEXT(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial interface IContext +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements_multiple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements_multiple.g.cs new file mode 100644 index 000000000..56327b2b7 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_implements_multiple.g.cs @@ -0,0 +1,208 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class _NULL_CONTEXT_MULTIPLE : AXSharp.Connector.ITwinObject, IContext_Multiple, IObject_Multiple +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public _NULL_CONTEXT_MULTIPLE(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos._NULL_CONTEXT_MULTIPLE plain = new global::Pocos._NULL_CONTEXT_MULTIPLE(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos._NULL_CONTEXT_MULTIPLE plain = new global::Pocos._NULL_CONTEXT_MULTIPLE(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos._NULL_CONTEXT_MULTIPLE plain = new global::Pocos._NULL_CONTEXT_MULTIPLE(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos._NULL_CONTEXT_MULTIPLE plain, global::Pocos._NULL_CONTEXT_MULTIPLE latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos._NULL_CONTEXT_MULTIPLE CreateEmptyPoco() + { + return new global::Pocos._NULL_CONTEXT_MULTIPLE(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial interface IContext_Multiple +{ +} + +public partial interface IObject_Multiple +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_internal.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_internal.g.cs new file mode 100644 index 000000000..1e0adb5eb --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_internal.g.cs @@ -0,0 +1,200 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +internal partial class ClassWithComplexTypes : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithComplexTypes(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypes(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypes(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithComplexTypes plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithComplexTypes plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithComplexTypes plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypes(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithComplexTypes plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithComplexTypes plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithComplexTypes plain, global::Pocos.ClassWithComplexTypes latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithComplexTypes CreateEmptyPoco() + { + return new global::Pocos.ClassWithComplexTypes(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_no_access_modifier.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_no_access_modifier.g.cs new file mode 100644 index 000000000..89643731b --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_no_access_modifier.g.cs @@ -0,0 +1,200 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class NoAccessModifierClass : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public NoAccessModifierClass(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.NoAccessModifierClass plain = new global::Pocos.NoAccessModifierClass(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.NoAccessModifierClass plain = new global::Pocos.NoAccessModifierClass(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.NoAccessModifierClass plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.NoAccessModifierClass plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.NoAccessModifierClass plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.NoAccessModifierClass plain = new global::Pocos.NoAccessModifierClass(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.NoAccessModifierClass plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.NoAccessModifierClass plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.NoAccessModifierClass plain, global::Pocos.NoAccessModifierClass latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.NoAccessModifierClass CreateEmptyPoco() + { + return new global::Pocos.NoAccessModifierClass(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_complex_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_complex_members.g.cs new file mode 100644 index 000000000..949255190 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_complex_members.g.cs @@ -0,0 +1,420 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace ClassWithComplexTypesNamespace +{ + public partial class ClassWithComplexTypes : AXSharp.Connector.ITwinObject + { + public ClassWithComplexTypesNamespace.ComplexType1 myComplexType { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithComplexTypes(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myComplexType = new ClassWithComplexTypesNamespace.ComplexType1(this, "myComplexType", "myComplexType"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain) + { +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain = new global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes(); + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain) + { + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain) + { + await this.myComplexType.PlainToShadowAsync(plain.myComplexType); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes plain, global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await myComplexType.DetectsAnyChangeAsync(plain.myComplexType, latest.myComplexType)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes CreateEmptyPoco() + { + return new global::Pocos.ClassWithComplexTypesNamespace.ClassWithComplexTypes(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class ComplexType1 : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexType1(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain = new global::Pocos.ClassWithComplexTypesNamespace.ComplexType1(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain = new global::Pocos.ClassWithComplexTypesNamespace.ComplexType1(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain = new global::Pocos.ClassWithComplexTypesNamespace.ComplexType1(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 plain, global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithComplexTypesNamespace.ComplexType1 CreateEmptyPoco() + { + return new global::Pocos.ClassWithComplexTypesNamespace.ComplexType1(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_non_public_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_non_public_members.g.cs new file mode 100644 index 000000000..374581498 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_non_public_members.g.cs @@ -0,0 +1,420 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace ClassWithNonTraspilableMemberssNamespace +{ + public partial class ClassWithNonTraspilableMembers : AXSharp.Connector.ITwinObject + { + public ClassWithNonTraspilableMemberssNamespace.ComplexType1 myComplexType { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithNonTraspilableMembers(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myComplexType = new ClassWithNonTraspilableMemberssNamespace.ComplexType1(this, "myComplexType", "myComplexType"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain) + { +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers(); + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain) + { + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain) + { + await this.myComplexType.PlainToShadowAsync(plain.myComplexType); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers plain, global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await myComplexType.DetectsAnyChangeAsync(plain.myComplexType, latest.myComplexType)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers CreateEmptyPoco() + { + return new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ClassWithNonTraspilableMembers(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class ComplexType1 : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexType1(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain = new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 plain, global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1 CreateEmptyPoco() + { + return new global::Pocos.ClassWithNonTraspilableMemberssNamespace.ComplexType1(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_pragmas.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_pragmas.g.cs new file mode 100644 index 000000000..ce988fa7f --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_pragmas.g.cs @@ -0,0 +1,422 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace ClassWithPragmasNamespace +{ + [Container(Layout.Stack)] + public partial class ClassWithPragmas : AXSharp.Connector.ITwinObject + { + [Container(Layout.Wrap)] + public ClassWithPragmasNamespace.ComplexType1 myComplexType { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithPragmas(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myComplexType = new ClassWithPragmasNamespace.ComplexType1(this, "myComplexType", "myComplexType"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain = new global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain = new global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas(); +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain) + { +#pragma warning disable CS0612 + plain.myComplexType = await myComplexType._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain) + { +#pragma warning disable CS0612 + await this.myComplexType._PlainToOnlineNoacAsync(plain.myComplexType); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain = new global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas(); + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain) + { + plain.myComplexType = await myComplexType.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain) + { + await this.myComplexType.PlainToShadowAsync(plain.myComplexType); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas plain, global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await myComplexType.DetectsAnyChangeAsync(plain.myComplexType, latest.myComplexType)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas CreateEmptyPoco() + { + return new global::Pocos.ClassWithPragmasNamespace.ClassWithPragmas(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class ComplexType1 : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexType1(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain = new global::Pocos.ClassWithPragmasNamespace.ComplexType1(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain = new global::Pocos.ClassWithPragmasNamespace.ComplexType1(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain = new global::Pocos.ClassWithPragmasNamespace.ComplexType1(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithPragmasNamespace.ComplexType1 plain, global::Pocos.ClassWithPragmasNamespace.ComplexType1 latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithPragmasNamespace.ComplexType1 CreateEmptyPoco() + { + return new global::Pocos.ClassWithPragmasNamespace.ComplexType1(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_primitive_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_primitive_members.g.cs new file mode 100644 index 000000000..ddbb9d537 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_primitive_members.g.cs @@ -0,0 +1,636 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace ClassWithPrimitiveTypesNamespace +{ + public partial class ClassWithPrimitiveTypes : AXSharp.Connector.ITwinObject + { + public OnlinerBool myBOOL { get; } + public OnlinerByte myBYTE { get; } + public OnlinerWord myWORD { get; } + public OnlinerDWord myDWORD { get; } + public OnlinerLWord myLWORD { get; } + public OnlinerSInt mySINT { get; } + public OnlinerInt myINT { get; } + public OnlinerDInt myDINT { get; } + public OnlinerLInt myLINT { get; } + public OnlinerUSInt myUSINT { get; } + public OnlinerUInt myUINT { get; } + public OnlinerUDInt myUDINT { get; } + public OnlinerULInt myULINT { get; } + public OnlinerReal myREAL { get; } + public OnlinerLReal myLREAL { get; } + public OnlinerTime myTIME { get; } + public OnlinerLTime myLTIME { get; } + public OnlinerDate myDATE { get; } + public OnlinerDate myLDATE { get; } + public OnlinerTimeOfDay myTIME_OF_DAY { get; } + public OnlinerLTimeOfDay myLTIME_OF_DAY { get; } + public OnlinerDateTime myDATE_AND_TIME { get; } + public OnlinerLDateTime myLDATE_AND_TIME { get; } + public OnlinerChar myCHAR { get; } + public OnlinerWChar myWCHAR { get; } + public OnlinerString mySTRING { get; } + public OnlinerWString myWSTRING { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithPrimitiveTypes(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myBOOL = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "myBOOL", "myBOOL"); + myBYTE = @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(this, "myBYTE", "myBYTE"); + myWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this, "myWORD", "myWORD"); + myDWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateDWORD(this, "myDWORD", "myDWORD"); + myLWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateLWORD(this, "myLWORD", "myLWORD"); + mySINT = @Connector.ConnectorAdapter.AdapterFactory.CreateSINT(this, "mySINT", "mySINT"); + myINT = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "myINT", "myINT"); + myDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateDINT(this, "myDINT", "myDINT"); + myLINT = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this, "myLINT", "myLINT"); + myUSINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUSINT(this, "myUSINT", "myUSINT"); + myUINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUINT(this, "myUINT", "myUINT"); + myUDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUDINT(this, "myUDINT", "myUDINT"); + myULINT = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "myULINT", "myULINT"); + myREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateREAL(this, "myREAL", "myREAL"); + myLREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateLREAL(this, "myLREAL", "myLREAL"); + myTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME(this, "myTIME", "myTIME"); + myLTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME(this, "myLTIME", "myLTIME"); + myDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE(this, "myDATE", "myDATE"); + myLDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE(this, "myLDATE", "myLDATE"); + myTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME_OF_DAY(this, "myTIME_OF_DAY", "myTIME_OF_DAY"); + myLTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME_OF_DAY(this, "myLTIME_OF_DAY", "myLTIME_OF_DAY"); + myDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE_AND_TIME(this, "myDATE_AND_TIME", "myDATE_AND_TIME"); + myLDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE_AND_TIME(this, "myLDATE_AND_TIME", "myLDATE_AND_TIME"); + myCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateCHAR(this, "myCHAR", "myCHAR"); + myWCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateWCHAR(this, "myWCHAR", "myWCHAR"); + mySTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "mySTRING", "mySTRING"); + myWSTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this, "myWSTRING", "myWSTRING"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain = new global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes(); + await this.ReadAsync(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain = new global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain) + { + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE.LethargicWrite(plain.myLDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME_OF_DAY.LethargicWrite(plain.myLTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE_AND_TIME.LethargicWrite(plain.myLDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myCHAR.LethargicWrite(plain.myCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWCHAR.LethargicWrite(plain.myWCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE.LethargicWrite(plain.myLDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME_OF_DAY.LethargicWrite(plain.myLTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE_AND_TIME.LethargicWrite(plain.myLDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myCHAR.LethargicWrite(plain.myCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWCHAR.LethargicWrite(plain.myWCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain = new global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes(); + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myLDATE = myLDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.Shadow; + plain.myCHAR = myCHAR.Shadow; + plain.myWCHAR = myWCHAR.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain) + { + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myLDATE = myLDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.Shadow; + plain.myCHAR = myCHAR.Shadow; + plain.myWCHAR = myWCHAR.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain) + { + myBOOL.Shadow = plain.myBOOL; + myBYTE.Shadow = plain.myBYTE; + myWORD.Shadow = plain.myWORD; + myDWORD.Shadow = plain.myDWORD; + myLWORD.Shadow = plain.myLWORD; + mySINT.Shadow = plain.mySINT; + myINT.Shadow = plain.myINT; + myDINT.Shadow = plain.myDINT; + myLINT.Shadow = plain.myLINT; + myUSINT.Shadow = plain.myUSINT; + myUINT.Shadow = plain.myUINT; + myUDINT.Shadow = plain.myUDINT; + myULINT.Shadow = plain.myULINT; + myREAL.Shadow = plain.myREAL; + myLREAL.Shadow = plain.myLREAL; + myTIME.Shadow = plain.myTIME; + myLTIME.Shadow = plain.myLTIME; + myDATE.Shadow = plain.myDATE; + myLDATE.Shadow = plain.myLDATE; + myTIME_OF_DAY.Shadow = plain.myTIME_OF_DAY; + myLTIME_OF_DAY.Shadow = plain.myLTIME_OF_DAY; + myDATE_AND_TIME.Shadow = plain.myDATE_AND_TIME; + myLDATE_AND_TIME.Shadow = plain.myLDATE_AND_TIME; + myCHAR.Shadow = plain.myCHAR; + myWCHAR.Shadow = plain.myWCHAR; + mySTRING.Shadow = plain.mySTRING; + myWSTRING.Shadow = plain.myWSTRING; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes plain, global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.myBOOL != myBOOL.LastValue) + somethingChanged = true; + if (plain.myBYTE != myBYTE.LastValue) + somethingChanged = true; + if (plain.myWORD != myWORD.LastValue) + somethingChanged = true; + if (plain.myDWORD != myDWORD.LastValue) + somethingChanged = true; + if (plain.myLWORD != myLWORD.LastValue) + somethingChanged = true; + if (plain.mySINT != mySINT.LastValue) + somethingChanged = true; + if (plain.myINT != myINT.LastValue) + somethingChanged = true; + if (plain.myDINT != myDINT.LastValue) + somethingChanged = true; + if (plain.myLINT != myLINT.LastValue) + somethingChanged = true; + if (plain.myUSINT != myUSINT.LastValue) + somethingChanged = true; + if (plain.myUINT != myUINT.LastValue) + somethingChanged = true; + if (plain.myUDINT != myUDINT.LastValue) + somethingChanged = true; + if (plain.myULINT != myULINT.LastValue) + somethingChanged = true; + if (plain.myREAL != myREAL.LastValue) + somethingChanged = true; + if (plain.myLREAL != myLREAL.LastValue) + somethingChanged = true; + if (plain.myTIME != myTIME.LastValue) + somethingChanged = true; + if (plain.myLTIME != myLTIME.LastValue) + somethingChanged = true; + if (plain.myDATE != myDATE.LastValue) + somethingChanged = true; + if (plain.myLDATE != myLDATE.LastValue) + somethingChanged = true; + if (plain.myTIME_OF_DAY != myTIME_OF_DAY.LastValue) + somethingChanged = true; + if (plain.myLTIME_OF_DAY != myLTIME_OF_DAY.LastValue) + somethingChanged = true; + if (plain.myDATE_AND_TIME != myDATE_AND_TIME.LastValue) + somethingChanged = true; + if (plain.myLDATE_AND_TIME != myLDATE_AND_TIME.LastValue) + somethingChanged = true; + if (plain.myCHAR != myCHAR.LastValue) + somethingChanged = true; + if (plain.myWCHAR != myWCHAR.LastValue) + somethingChanged = true; + if (plain.mySTRING != mySTRING.LastValue) + somethingChanged = true; + if (plain.myWSTRING != myWSTRING.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes CreateEmptyPoco() + { + return new global::Pocos.ClassWithPrimitiveTypesNamespace.ClassWithPrimitiveTypes(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_using_directives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_using_directives.g.cs new file mode 100644 index 000000000..960522b17 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/class_with_using_directives.g.cs @@ -0,0 +1,218 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; +using SimpleFirstLevelNamespace; +using SimpleQualifiedNamespace.Qualified; +using HelloLevelOne.HelloLevelTwo; + +internal partial class ClassWithUsingDirectives : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithUsingDirectives(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ClassWithUsingDirectives plain = new global::Pocos.ClassWithUsingDirectives(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ClassWithUsingDirectives plain = new global::Pocos.ClassWithUsingDirectives(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ClassWithUsingDirectives plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ClassWithUsingDirectives plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ClassWithUsingDirectives plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ClassWithUsingDirectives plain = new global::Pocos.ClassWithUsingDirectives(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ClassWithUsingDirectives plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ClassWithUsingDirectives plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ClassWithUsingDirectives plain, global::Pocos.ClassWithUsingDirectives latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ClassWithUsingDirectives CreateEmptyPoco() + { + return new global::Pocos.ClassWithUsingDirectives(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +namespace SimpleFirstLevelNamespace +{ +} + +namespace SimpleQualifiedNamespace.Qualified +{ +} + +namespace HelloLevelOne +{ + namespace HelloLevelTwo + { + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/compileromitsattribute.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/compileromitsattribute.g.cs new file mode 100644 index 000000000..da7c3a821 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/compileromitsattribute.g.cs @@ -0,0 +1,2077 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace CompilerOmmits +{ + public partial class ClassWithArrays : AXSharp.Connector.ITwinObject + { + [CompilerOmitsAttribute("POCO")] + public CompilerOmmits.Complex _must_be_omitted_in_poco { get; } + public OnlinerByte[] _primitive { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithArrays(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + _must_be_omitted_in_poco = new CompilerOmmits.Complex(this, "_must_be_omitted_in_poco", "_must_be_omitted_in_poco"); + _primitive = new OnlinerByte[11]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_primitive, this, "_primitive", "_primitive", (p, rt, st) => @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(p, rt, st), new[] { (0, 10) }); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.CompilerOmmits.ClassWithArrays plain = new global::Pocos.CompilerOmmits.ClassWithArrays(); + await this.ReadAsync(); + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.CompilerOmmits.ClassWithArrays plain = new global::Pocos.CompilerOmmits.ClassWithArrays(); + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain) + { + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain) + { + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain) + { + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.CompilerOmmits.ClassWithArrays plain = new global::Pocos.CompilerOmmits.ClassWithArrays(); + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain) + { + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain) + { + var __primitive_i_FE8484DAB3 = 0; + _primitive.Select(p => p.Shadow = plain._primitive[__primitive_i_FE8484DAB3++]).ToArray(); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.CompilerOmmits.ClassWithArrays plain, global::Pocos.CompilerOmmits.ClassWithArrays latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest._primitive.Length; i760901_3001_mimi++) + { + if (latest._primitive.ElementAt(i760901_3001_mimi) != plain._primitive[i760901_3001_mimi]) + somethingChanged = true; + } + + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.CompilerOmmits.ClassWithArrays CreateEmptyPoco() + { + return new global::Pocos.CompilerOmmits.ClassWithArrays(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Complex : AXSharp.Connector.ITwinObject + { + public OnlinerString HelloString { get; } + public OnlinerULInt Id { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Complex(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + HelloString = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "HelloString", "HelloString"); + Id = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Id", "Id"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.CompilerOmmits.Complex plain = new global::Pocos.CompilerOmmits.Complex(); + await this.ReadAsync(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.CompilerOmmits.Complex plain = new global::Pocos.CompilerOmmits.Complex(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.CompilerOmmits.Complex plain) + { + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.CompilerOmmits.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.CompilerOmmits.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.CompilerOmmits.Complex plain = new global::Pocos.CompilerOmmits.Complex(); + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.CompilerOmmits.Complex plain) + { + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.CompilerOmmits.Complex plain) + { + HelloString.Shadow = plain.HelloString; + Id.Shadow = plain.Id; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.CompilerOmmits.Complex plain, global::Pocos.CompilerOmmits.Complex latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.HelloString != HelloString.LastValue) + somethingChanged = true; + if (plain.Id != Id.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.CompilerOmmits.Complex CreateEmptyPoco() + { + return new global::Pocos.CompilerOmmits.Complex(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} + +namespace Enums +{ + public partial class ClassWithEnums : AXSharp.Connector.ITwinObject + { + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Enums.Colors))] + public OnlinerInt colors { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Enums.NamedValuesColors))] + public OnlinerString NamedValuesColors { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithEnums(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + colors = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "colors", "colors"); + NamedValuesColors = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "NamedValuesColors", "NamedValuesColors"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + await this.ReadAsync(); + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Enums.ClassWithEnums plain) + { + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Enums.ClassWithEnums plain) + { +#pragma warning disable CS0612 + colors.LethargicWrite((short)plain.colors); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + NamedValuesColors.LethargicWrite(plain.NamedValuesColors); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Enums.ClassWithEnums plain) + { +#pragma warning disable CS0612 + colors.LethargicWrite((short)plain.colors); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + NamedValuesColors.LethargicWrite(plain.NamedValuesColors); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + plain.colors = (Enums.Colors)colors.Shadow; + plain.NamedValuesColors = NamedValuesColors.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Enums.ClassWithEnums plain) + { + plain.colors = (Enums.Colors)colors.Shadow; + plain.NamedValuesColors = NamedValuesColors.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Enums.ClassWithEnums plain) + { + colors.Shadow = (short)plain.colors; + NamedValuesColors.Shadow = plain.NamedValuesColors; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Enums.ClassWithEnums plain, global::Pocos.Enums.ClassWithEnums latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.colors != (Enums.Colors)latest.colors) + somethingChanged = true; + if (plain.NamedValuesColors != NamedValuesColors.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Enums.ClassWithEnums CreateEmptyPoco() + { + return new global::Pocos.Enums.ClassWithEnums(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public enum Colors + { + Red, + Green, + Blue + } + + public enum NamedValuesColors : String + { + Red = 49, + Green = 50, + Blue = 51 + } +} + +namespace misc +{ + public partial class VariousMembers : AXSharp.Connector.ITwinObject + { + public misc.SomeClass _SomeClass { get; } + public misc.Motor _Motor { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public VariousMembers(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + _SomeClass = new misc.SomeClass(this, "_SomeClass", "_SomeClass"); + _Motor = new misc.Motor(this, "_Motor", "_Motor"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + await this._SomeClass._PlainToOnlineNoacAsync(plain._SomeClass); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this._Motor._PlainToOnlineNoacAsync(plain._Motor); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + await this._SomeClass._PlainToOnlineNoacAsync(plain._SomeClass); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this._Motor._PlainToOnlineNoacAsync(plain._Motor); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); + plain._SomeClass = await _SomeClass.ShadowToPlainAsync(); + plain._Motor = await _Motor.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.VariousMembers plain) + { + plain._SomeClass = await _SomeClass.ShadowToPlainAsync(); + plain._Motor = await _Motor.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.VariousMembers plain) + { + await this._SomeClass.PlainToShadowAsync(plain._SomeClass); + await this._Motor.PlainToShadowAsync(plain._Motor); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.VariousMembers plain, global::Pocos.misc.VariousMembers latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await _SomeClass.DetectsAnyChangeAsync(plain._SomeClass, latest._SomeClass)) + somethingChanged = true; + if (await _Motor.DetectsAnyChangeAsync(plain._Motor, latest._Motor)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.VariousMembers CreateEmptyPoco() + { + return new global::Pocos.misc.VariousMembers(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class SomeClass : AXSharp.Connector.ITwinObject + { + public OnlinerString SomeClassVariable { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SomeClass(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + SomeClassVariable = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "SomeClassVariable", "SomeClassVariable"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + await this.ReadAsync(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.misc.SomeClass plain) + { + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.SomeClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.SomeClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.SomeClass plain) + { + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.SomeClass plain) + { + SomeClassVariable.Shadow = plain.SomeClassVariable; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.SomeClass plain, global::Pocos.misc.SomeClass latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.SomeClassVariable != SomeClassVariable.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.SomeClass CreateEmptyPoco() + { + return new global::Pocos.misc.SomeClass(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Motor : AXSharp.Connector.ITwinObject + { + public OnlinerBool isRunning { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + await this.ReadAsync(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.misc.Motor plain) + { + plain.isRunning = isRunning.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + plain.isRunning = isRunning.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.Motor plain) + { + plain.isRunning = isRunning.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.Motor plain) + { + isRunning.Shadow = plain.isRunning; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.Motor plain, global::Pocos.misc.Motor latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.isRunning != isRunning.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.Motor CreateEmptyPoco() + { + return new global::Pocos.misc.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Vehicle : AXSharp.Connector.ITwinObject + { + public misc.Motor m { get; } + public OnlinerInt displacement { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + m = new misc.Motor(this, "m", "m"); + displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.Vehicle plain) + { + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.Vehicle plain) + { + await this.m.PlainToShadowAsync(plain.m); + displacement.Shadow = plain.displacement; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.Vehicle plain, global::Pocos.misc.Vehicle latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await m.DetectsAnyChangeAsync(plain.m, latest.m)) + somethingChanged = true; + if (plain.displacement != displacement.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.Vehicle CreateEmptyPoco() + { + return new global::Pocos.misc.Vehicle(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} + +namespace UnknownArraysShouldNotBeTraspiled +{ + public partial class ClassWithArrays : AXSharp.Connector.ITwinObject + { + public UnknownArraysShouldNotBeTraspiled.Complex[] _complexKnown { get; } + public OnlinerByte[] _primitive { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithArrays(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + _complexKnown = new UnknownArraysShouldNotBeTraspiled.Complex[11]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_complexKnown, this, "_complexKnown", "_complexKnown", (p, rt, st) => new UnknownArraysShouldNotBeTraspiled.Complex(p, rt, st), new[] { (0, 10) }); + _primitive = new OnlinerByte[11]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_primitive, this, "_primitive", "_primitive", (p, rt, st) => @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(p, rt, st), new[] { (0, 10) }); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _complexKnown.Select(p => p._PlainToOnlineNoacAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _complexKnown.Select(p => p._PlainToOnlineNoacAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + plain._complexKnown = _complexKnown.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + plain._complexKnown = _complexKnown.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; + _complexKnown.Select(p => p.PlainToShadowAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); + var __primitive_i_FE8484DAB3 = 0; + _primitive.Select(p => p.Shadow = plain._primitive[__primitive_i_FE8484DAB3++]).ToArray(); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain, global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest._complexKnown.Length; i760901_3001_mimi++) + { + if (await _complexKnown.ElementAt(i760901_3001_mimi).DetectsAnyChangeAsync(plain._complexKnown[i760901_3001_mimi], latest._complexKnown[i760901_3001_mimi])) + somethingChanged = true; + } + + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest._primitive.Length; i760901_3001_mimi++) + { + if (latest._primitive.ElementAt(i760901_3001_mimi) != plain._primitive[i760901_3001_mimi]) + somethingChanged = true; + } + + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays CreateEmptyPoco() + { + return new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Complex : AXSharp.Connector.ITwinObject + { + public OnlinerString HelloString { get; } + public OnlinerULInt Id { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Complex(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + HelloString = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "HelloString", "HelloString"); + Id = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Id", "Id"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + await this.ReadAsync(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + HelloString.Shadow = plain.HelloString; + Id.Shadow = plain.Id; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain, global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.HelloString != HelloString.LastValue) + somethingChanged = true; + if (plain.Id != Id.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex CreateEmptyPoco() + { + return new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/configuration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/configuration.g.cs new file mode 100644 index 000000000..49aedcf27 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/configuration.g.cs @@ -0,0 +1,1109 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class ComplexForConfig : AXSharp.Connector.ITwinObject +{ + public OnlinerBool myBOOL { get; } + public OnlinerByte myBYTE { get; } + public OnlinerWord myWORD { get; } + public OnlinerDWord myDWORD { get; } + public OnlinerLWord myLWORD { get; } + public OnlinerSInt mySINT { get; } + public OnlinerInt myINT { get; } + public OnlinerDInt myDINT { get; } + public OnlinerLInt myLINT { get; } + public OnlinerUSInt myUSINT { get; } + public OnlinerUInt myUINT { get; } + public OnlinerUDInt myUDINT { get; } + public OnlinerULInt myULINT { get; } + public OnlinerReal myREAL { get; } + public OnlinerLReal myLREAL { get; } + public OnlinerTime myTIME { get; } + public OnlinerLTime myLTIME { get; } + public OnlinerDate myDATE { get; } + public OnlinerDate myLDATE { get; } + public OnlinerTimeOfDay myTIME_OF_DAY { get; } + public OnlinerLTimeOfDay myLTIME_OF_DAY { get; } + public OnlinerDateTime myDATE_AND_TIME { get; } + public OnlinerLDateTime myLDATE_AND_TIME { get; } + public OnlinerChar myCHAR { get; } + public OnlinerWChar myWCHAR { get; } + public OnlinerString mySTRING { get; } + public OnlinerWString myWSTRING { get; } + public Motor myMotor { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexForConfig(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + myBOOL = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "myBOOL", "myBOOL"); + myBYTE = @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(this, "myBYTE", "myBYTE"); + myWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this, "myWORD", "myWORD"); + myDWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateDWORD(this, "myDWORD", "myDWORD"); + myLWORD = @Connector.ConnectorAdapter.AdapterFactory.CreateLWORD(this, "myLWORD", "myLWORD"); + mySINT = @Connector.ConnectorAdapter.AdapterFactory.CreateSINT(this, "mySINT", "mySINT"); + myINT = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "myINT", "myINT"); + myDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateDINT(this, "myDINT", "myDINT"); + myLINT = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this, "myLINT", "myLINT"); + myUSINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUSINT(this, "myUSINT", "myUSINT"); + myUINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUINT(this, "myUINT", "myUINT"); + myUDINT = @Connector.ConnectorAdapter.AdapterFactory.CreateUDINT(this, "myUDINT", "myUDINT"); + myULINT = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "myULINT", "myULINT"); + myREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateREAL(this, "myREAL", "myREAL"); + myLREAL = @Connector.ConnectorAdapter.AdapterFactory.CreateLREAL(this, "myLREAL", "myLREAL"); + myTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME(this, "myTIME", "myTIME"); + myLTIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME(this, "myLTIME", "myLTIME"); + myDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE(this, "myDATE", "myDATE"); + myLDATE = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE(this, "myLDATE", "myLDATE"); + myTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateTIME_OF_DAY(this, "myTIME_OF_DAY", "myTIME_OF_DAY"); + myLTIME_OF_DAY = @Connector.ConnectorAdapter.AdapterFactory.CreateLTIME_OF_DAY(this, "myLTIME_OF_DAY", "myLTIME_OF_DAY"); + myDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateDATE_AND_TIME(this, "myDATE_AND_TIME", "myDATE_AND_TIME"); + myLDATE_AND_TIME = @Connector.ConnectorAdapter.AdapterFactory.CreateLDATE_AND_TIME(this, "myLDATE_AND_TIME", "myLDATE_AND_TIME"); + myCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateCHAR(this, "myCHAR", "myCHAR"); + myWCHAR = @Connector.ConnectorAdapter.AdapterFactory.CreateWCHAR(this, "myWCHAR", "myWCHAR"); + mySTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "mySTRING", "mySTRING"); + myWSTRING = @Connector.ConnectorAdapter.AdapterFactory.CreateWSTRING(this, "myWSTRING", "myWSTRING"); + myMotor = new Motor(this, "myMotor", "myMotor"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ComplexForConfig plain = new global::Pocos.ComplexForConfig(); + await this.ReadAsync(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; +#pragma warning disable CS0612 + plain.myMotor = await myMotor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ComplexForConfig plain = new global::Pocos.ComplexForConfig(); + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; +#pragma warning disable CS0612 + plain.myMotor = await myMotor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ComplexForConfig plain) + { + plain.myBOOL = myBOOL.LastValue; + plain.myBYTE = myBYTE.LastValue; + plain.myWORD = myWORD.LastValue; + plain.myDWORD = myDWORD.LastValue; + plain.myLWORD = myLWORD.LastValue; + plain.mySINT = mySINT.LastValue; + plain.myINT = myINT.LastValue; + plain.myDINT = myDINT.LastValue; + plain.myLINT = myLINT.LastValue; + plain.myUSINT = myUSINT.LastValue; + plain.myUINT = myUINT.LastValue; + plain.myUDINT = myUDINT.LastValue; + plain.myULINT = myULINT.LastValue; + plain.myREAL = myREAL.LastValue; + plain.myLREAL = myLREAL.LastValue; + plain.myTIME = myTIME.LastValue; + plain.myLTIME = myLTIME.LastValue; + plain.myDATE = myDATE.LastValue; + plain.myLDATE = myLDATE.LastValue; + plain.myTIME_OF_DAY = myTIME_OF_DAY.LastValue; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.LastValue; + plain.myDATE_AND_TIME = myDATE_AND_TIME.LastValue; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.LastValue; + plain.myCHAR = myCHAR.LastValue; + plain.myWCHAR = myWCHAR.LastValue; + plain.mySTRING = mySTRING.LastValue; + plain.myWSTRING = myWSTRING.LastValue; +#pragma warning disable CS0612 + plain.myMotor = await myMotor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ComplexForConfig plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE.LethargicWrite(plain.myLDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME_OF_DAY.LethargicWrite(plain.myLTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE_AND_TIME.LethargicWrite(plain.myLDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myCHAR.LethargicWrite(plain.myCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWCHAR.LethargicWrite(plain.myWCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.myMotor._PlainToOnlineNoacAsync(plain.myMotor); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ComplexForConfig plain) + { +#pragma warning disable CS0612 + myBOOL.LethargicWrite(plain.myBOOL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myBYTE.LethargicWrite(plain.myBYTE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWORD.LethargicWrite(plain.myWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDWORD.LethargicWrite(plain.myDWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLWORD.LethargicWrite(plain.myLWORD); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySINT.LethargicWrite(plain.mySINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myINT.LethargicWrite(plain.myINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDINT.LethargicWrite(plain.myDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLINT.LethargicWrite(plain.myLINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUSINT.LethargicWrite(plain.myUSINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUINT.LethargicWrite(plain.myUINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myUDINT.LethargicWrite(plain.myUDINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myULINT.LethargicWrite(plain.myULINT); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myREAL.LethargicWrite(plain.myREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLREAL.LethargicWrite(plain.myLREAL); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME.LethargicWrite(plain.myTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME.LethargicWrite(plain.myLTIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE.LethargicWrite(plain.myDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE.LethargicWrite(plain.myLDATE); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myTIME_OF_DAY.LethargicWrite(plain.myTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLTIME_OF_DAY.LethargicWrite(plain.myLTIME_OF_DAY); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myDATE_AND_TIME.LethargicWrite(plain.myDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myLDATE_AND_TIME.LethargicWrite(plain.myLDATE_AND_TIME); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myCHAR.LethargicWrite(plain.myCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWCHAR.LethargicWrite(plain.myWCHAR); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + mySTRING.LethargicWrite(plain.mySTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + myWSTRING.LethargicWrite(plain.myWSTRING); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.myMotor._PlainToOnlineNoacAsync(plain.myMotor); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ComplexForConfig plain = new global::Pocos.ComplexForConfig(); + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myLDATE = myLDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.Shadow; + plain.myCHAR = myCHAR.Shadow; + plain.myWCHAR = myWCHAR.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + plain.myMotor = await myMotor.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ComplexForConfig plain) + { + plain.myBOOL = myBOOL.Shadow; + plain.myBYTE = myBYTE.Shadow; + plain.myWORD = myWORD.Shadow; + plain.myDWORD = myDWORD.Shadow; + plain.myLWORD = myLWORD.Shadow; + plain.mySINT = mySINT.Shadow; + plain.myINT = myINT.Shadow; + plain.myDINT = myDINT.Shadow; + plain.myLINT = myLINT.Shadow; + plain.myUSINT = myUSINT.Shadow; + plain.myUINT = myUINT.Shadow; + plain.myUDINT = myUDINT.Shadow; + plain.myULINT = myULINT.Shadow; + plain.myREAL = myREAL.Shadow; + plain.myLREAL = myLREAL.Shadow; + plain.myTIME = myTIME.Shadow; + plain.myLTIME = myLTIME.Shadow; + plain.myDATE = myDATE.Shadow; + plain.myLDATE = myLDATE.Shadow; + plain.myTIME_OF_DAY = myTIME_OF_DAY.Shadow; + plain.myLTIME_OF_DAY = myLTIME_OF_DAY.Shadow; + plain.myDATE_AND_TIME = myDATE_AND_TIME.Shadow; + plain.myLDATE_AND_TIME = myLDATE_AND_TIME.Shadow; + plain.myCHAR = myCHAR.Shadow; + plain.myWCHAR = myWCHAR.Shadow; + plain.mySTRING = mySTRING.Shadow; + plain.myWSTRING = myWSTRING.Shadow; + plain.myMotor = await myMotor.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ComplexForConfig plain) + { + myBOOL.Shadow = plain.myBOOL; + myBYTE.Shadow = plain.myBYTE; + myWORD.Shadow = plain.myWORD; + myDWORD.Shadow = plain.myDWORD; + myLWORD.Shadow = plain.myLWORD; + mySINT.Shadow = plain.mySINT; + myINT.Shadow = plain.myINT; + myDINT.Shadow = plain.myDINT; + myLINT.Shadow = plain.myLINT; + myUSINT.Shadow = plain.myUSINT; + myUINT.Shadow = plain.myUINT; + myUDINT.Shadow = plain.myUDINT; + myULINT.Shadow = plain.myULINT; + myREAL.Shadow = plain.myREAL; + myLREAL.Shadow = plain.myLREAL; + myTIME.Shadow = plain.myTIME; + myLTIME.Shadow = plain.myLTIME; + myDATE.Shadow = plain.myDATE; + myLDATE.Shadow = plain.myLDATE; + myTIME_OF_DAY.Shadow = plain.myTIME_OF_DAY; + myLTIME_OF_DAY.Shadow = plain.myLTIME_OF_DAY; + myDATE_AND_TIME.Shadow = plain.myDATE_AND_TIME; + myLDATE_AND_TIME.Shadow = plain.myLDATE_AND_TIME; + myCHAR.Shadow = plain.myCHAR; + myWCHAR.Shadow = plain.myWCHAR; + mySTRING.Shadow = plain.mySTRING; + myWSTRING.Shadow = plain.myWSTRING; + await this.myMotor.PlainToShadowAsync(plain.myMotor); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ComplexForConfig plain, global::Pocos.ComplexForConfig latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.myBOOL != myBOOL.LastValue) + somethingChanged = true; + if (plain.myBYTE != myBYTE.LastValue) + somethingChanged = true; + if (plain.myWORD != myWORD.LastValue) + somethingChanged = true; + if (plain.myDWORD != myDWORD.LastValue) + somethingChanged = true; + if (plain.myLWORD != myLWORD.LastValue) + somethingChanged = true; + if (plain.mySINT != mySINT.LastValue) + somethingChanged = true; + if (plain.myINT != myINT.LastValue) + somethingChanged = true; + if (plain.myDINT != myDINT.LastValue) + somethingChanged = true; + if (plain.myLINT != myLINT.LastValue) + somethingChanged = true; + if (plain.myUSINT != myUSINT.LastValue) + somethingChanged = true; + if (plain.myUINT != myUINT.LastValue) + somethingChanged = true; + if (plain.myUDINT != myUDINT.LastValue) + somethingChanged = true; + if (plain.myULINT != myULINT.LastValue) + somethingChanged = true; + if (plain.myREAL != myREAL.LastValue) + somethingChanged = true; + if (plain.myLREAL != myLREAL.LastValue) + somethingChanged = true; + if (plain.myTIME != myTIME.LastValue) + somethingChanged = true; + if (plain.myLTIME != myLTIME.LastValue) + somethingChanged = true; + if (plain.myDATE != myDATE.LastValue) + somethingChanged = true; + if (plain.myLDATE != myLDATE.LastValue) + somethingChanged = true; + if (plain.myTIME_OF_DAY != myTIME_OF_DAY.LastValue) + somethingChanged = true; + if (plain.myLTIME_OF_DAY != myLTIME_OF_DAY.LastValue) + somethingChanged = true; + if (plain.myDATE_AND_TIME != myDATE_AND_TIME.LastValue) + somethingChanged = true; + if (plain.myLDATE_AND_TIME != myLDATE_AND_TIME.LastValue) + somethingChanged = true; + if (plain.myCHAR != myCHAR.LastValue) + somethingChanged = true; + if (plain.myWCHAR != myWCHAR.LastValue) + somethingChanged = true; + if (plain.mySTRING != mySTRING.LastValue) + somethingChanged = true; + if (plain.myWSTRING != myWSTRING.LastValue) + somethingChanged = true; + if (await myMotor.DetectsAnyChangeAsync(plain.myMotor, latest.myMotor)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ComplexForConfig CreateEmptyPoco() + { + return new global::Pocos.ComplexForConfig(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public enum Colorss +{ + Red, + Green, + Blue +} + +public enum Colorsss : UInt64 +{ + Red = 1, + Green = 2, + Blue = 3 +} + +public partial class Motor : AXSharp.Connector.ITwinObject +{ + public OnlinerBool isRunning { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + await this.ReadAsync(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.Motor plain) + { + plain.isRunning = isRunning.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.isRunning = isRunning.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Motor plain) + { + plain.isRunning = isRunning.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Motor plain) + { + isRunning.Shadow = plain.isRunning; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Motor plain, global::Pocos.Motor latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.isRunning != isRunning.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Motor CreateEmptyPoco() + { + return new global::Pocos.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class Vehicle : AXSharp.Connector.ITwinObject +{ + public Motor m { get; } + public OnlinerInt displacement { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + m = new Motor(this, "m", "m"); + displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Vehicle plain) + { + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Vehicle plain) + { + await this.m.PlainToShadowAsync(plain.m); + displacement.Shadow = plain.displacement; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Vehicle plain, global::Pocos.Vehicle latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await m.DetectsAnyChangeAsync(plain.m, latest.m)) + somethingChanged = true; + if (plain.displacement != displacement.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Vehicle CreateEmptyPoco() + { + return new global::Pocos.Vehicle(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/enum_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/enum_simple.g.cs new file mode 100644 index 000000000..e509210f9 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/enum_simple.g.cs @@ -0,0 +1,13 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public enum Colors +{ + Red, + Green, + Blue +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_unsupported.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_unsupported.g.cs new file mode 100644 index 000000000..7b8ffd8e8 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_unsupported.g.cs @@ -0,0 +1,10 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Unsupported +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_usings.g.cs new file mode 100644 index 000000000..7cb31ff4a --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/file_with_usings.g.cs @@ -0,0 +1,800 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; +using FileWithUsingsSimpleFirstLevelNamespace; +using FileWithUsingsSimpleQualifiedNamespace.Qualified; +using FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo; + +namespace FileWithUsingsSimpleFirstLevelNamespace +{ + public partial class Hello : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Hello(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain = new global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain = new global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain = new global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello plain, global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello CreateEmptyPoco() + { + return new global::Pocos.FileWithUsingsSimpleFirstLevelNamespace.Hello(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} + +namespace FileWithUsingsSimpleQualifiedNamespace.Qualified +{ + public partial class Hello : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Hello(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain = new global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain = new global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain = new global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello plain, global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello CreateEmptyPoco() + { + return new global::Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified.Hello(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} + +namespace FileWithUsingsHelloLevelOne +{ + namespace FileWithUsingsHelloLevelTwo + { + public partial class Hello : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Hello(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain = new global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain = new global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain = new global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello plain, global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello CreateEmptyPoco() + { + return new global::Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo.Hello(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + } +} + +namespace ExampleNamespace +{ + public partial class Hello : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Hello(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.ExampleNamespace.Hello plain = new global::Pocos.ExampleNamespace.Hello(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.ExampleNamespace.Hello plain = new global::Pocos.ExampleNamespace.Hello(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.ExampleNamespace.Hello plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.ExampleNamespace.Hello plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.ExampleNamespace.Hello plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.ExampleNamespace.Hello plain = new global::Pocos.ExampleNamespace.Hello(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.ExampleNamespace.Hello plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.ExampleNamespace.Hello plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.ExampleNamespace.Hello plain, global::Pocos.ExampleNamespace.Hello latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.ExampleNamespace.Hello CreateEmptyPoco() + { + return new global::Pocos.ExampleNamespace.Hello(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/generics.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/generics.g.cs new file mode 100644 index 000000000..13720b7f9 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/generics.g.cs @@ -0,0 +1,585 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace GenericsTests +{ + public partial class Extender : AXSharp.Connector.ITwinObject where TOnline : ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extender(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.GenericsTests.Extender plain = new global::Pocos.GenericsTests.Extender(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.GenericsTests.Extender plain = new global::Pocos.GenericsTests.Extender(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.GenericsTests.Extender plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.GenericsTests.Extender plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.GenericsTests.Extender plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.GenericsTests.Extender plain = new global::Pocos.GenericsTests.Extender(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.GenericsTests.Extender plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.GenericsTests.Extender plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.GenericsTests.Extender plain, global::Pocos.GenericsTests.Extender latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.GenericsTests.Extender CreateEmptyPoco() + { + return new global::Pocos.GenericsTests.Extender(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class SomeTypeToBeGeneric : AXSharp.Connector.ITwinObject + { + public OnlinerBool Boolean { get; } + public OnlinerInt Cele { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SomeTypeToBeGeneric(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + Boolean = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "Boolean", "Boolean"); + Cele = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "Cele", "Cele"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.GenericsTests.SomeTypeToBeGeneric plain = new global::Pocos.GenericsTests.SomeTypeToBeGeneric(); + await this.ReadAsync(); + plain.Boolean = Boolean.LastValue; + plain.Cele = Cele.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.GenericsTests.SomeTypeToBeGeneric plain = new global::Pocos.GenericsTests.SomeTypeToBeGeneric(); + plain.Boolean = Boolean.LastValue; + plain.Cele = Cele.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain) + { + plain.Boolean = Boolean.LastValue; + plain.Cele = Cele.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain) + { +#pragma warning disable CS0612 + Boolean.LethargicWrite(plain.Boolean); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Cele.LethargicWrite(plain.Cele); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain) + { +#pragma warning disable CS0612 + Boolean.LethargicWrite(plain.Boolean); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Cele.LethargicWrite(plain.Cele); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.GenericsTests.SomeTypeToBeGeneric plain = new global::Pocos.GenericsTests.SomeTypeToBeGeneric(); + plain.Boolean = Boolean.Shadow; + plain.Cele = Cele.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain) + { + plain.Boolean = Boolean.Shadow; + plain.Cele = Cele.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain) + { + Boolean.Shadow = plain.Boolean; + Cele.Shadow = plain.Cele; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.GenericsTests.SomeTypeToBeGeneric plain, global::Pocos.GenericsTests.SomeTypeToBeGeneric latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.Boolean != Boolean.LastValue) + somethingChanged = true; + if (plain.Cele != Cele.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.GenericsTests.SomeTypeToBeGeneric CreateEmptyPoco() + { + return new global::Pocos.GenericsTests.SomeTypeToBeGeneric(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Extendee2 : GenericsTests.Extender + { + [AXOpen.Data.AxoDataEntityAttribute] + [Container(Layout.Stack)] + public GenericsTests.SomeTypeToBeGeneric SomeData { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Extendee2(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + SomeData = new GenericsTests.SomeTypeToBeGeneric(this, "Shared Header", "SomeData"); + SomeData.AttributeName = "Shared Header"; + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.GenericsTests.Extendee2 plain = new global::Pocos.GenericsTests.Extendee2(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeData = await SomeData._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.GenericsTests.Extendee2 plain = new global::Pocos.GenericsTests.Extendee2(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeData = await SomeData._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.GenericsTests.Extendee2 plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.SomeData = await SomeData._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.GenericsTests.Extendee2 plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeData._PlainToOnlineNoacAsync(plain.SomeData); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.GenericsTests.Extendee2 plain) + { + await base._PlainToOnlineNoacAsync(plain); +#pragma warning disable CS0612 + await this.SomeData._PlainToOnlineNoacAsync(plain.SomeData); +#pragma warning restore CS0612 + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.GenericsTests.Extendee2 plain = new global::Pocos.GenericsTests.Extendee2(); + await base.ShadowToPlainAsync(plain); + plain.SomeData = await SomeData.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.GenericsTests.Extendee2 plain) + { + await base.ShadowToPlainAsync(plain); + plain.SomeData = await SomeData.ShadowToPlainAsync(); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.GenericsTests.Extendee2 plain) + { + await base.PlainToShadowAsync(plain); + await this.SomeData.PlainToShadowAsync(plain.SomeData); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.GenericsTests.Extendee2 plain, global::Pocos.GenericsTests.Extendee2 latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + if (await SomeData.DetectsAnyChangeAsync(plain.SomeData, latest.SomeData)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.GenericsTests.Extendee2 CreateEmptyPoco() + { + return new global::Pocos.GenericsTests.Extendee2(); + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonce.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonce.g.cs new file mode 100644 index 000000000..893901e62 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonce.g.cs @@ -0,0 +1,512 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace makereadonce +{ + public partial class MembersWithMakeReadOnce : AXSharp.Connector.ITwinObject + { + [ReadOnce()] + public OnlinerString makeReadOnceMember { get; } + public OnlinerString someOtherMember { get; } + + [ReadOnce()] + public makereadonce.ComplexMember makeReadComplexMember { get; } + public makereadonce.ComplexMember someotherComplexMember { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public MembersWithMakeReadOnce(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + makeReadOnceMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "makeReadOnceMember", "makeReadOnceMember"); + makeReadOnceMember.MakeReadOnce(); + someOtherMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someOtherMember", "someOtherMember"); + makeReadComplexMember = new makereadonce.ComplexMember(this, "makeReadComplexMember", "makeReadComplexMember"); + makeReadComplexMember.MakeReadOnce(); + someotherComplexMember = new makereadonce.ComplexMember(this, "someotherComplexMember", "someotherComplexMember"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.makereadonce.MembersWithMakeReadOnce plain = new global::Pocos.makereadonce.MembersWithMakeReadOnce(); + await this.ReadAsync(); + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.makereadonce.MembersWithMakeReadOnce plain = new global::Pocos.makereadonce.MembersWithMakeReadOnce(); + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain) + { + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain) + { +#pragma warning disable CS0612 + makeReadOnceMember.LethargicWrite(plain.makeReadOnceMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.makeReadComplexMember._PlainToOnlineNoacAsync(plain.makeReadComplexMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.someotherComplexMember._PlainToOnlineNoacAsync(plain.someotherComplexMember); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain) + { +#pragma warning disable CS0612 + makeReadOnceMember.LethargicWrite(plain.makeReadOnceMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.makeReadComplexMember._PlainToOnlineNoacAsync(plain.makeReadComplexMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.someotherComplexMember._PlainToOnlineNoacAsync(plain.someotherComplexMember); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.makereadonce.MembersWithMakeReadOnce plain = new global::Pocos.makereadonce.MembersWithMakeReadOnce(); + plain.makeReadOnceMember = makeReadOnceMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + plain.makeReadComplexMember = await makeReadComplexMember.ShadowToPlainAsync(); + plain.someotherComplexMember = await someotherComplexMember.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain) + { + plain.makeReadOnceMember = makeReadOnceMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + plain.makeReadComplexMember = await makeReadComplexMember.ShadowToPlainAsync(); + plain.someotherComplexMember = await someotherComplexMember.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain) + { + makeReadOnceMember.Shadow = plain.makeReadOnceMember; + someOtherMember.Shadow = plain.someOtherMember; + await this.makeReadComplexMember.PlainToShadowAsync(plain.makeReadComplexMember); + await this.someotherComplexMember.PlainToShadowAsync(plain.someotherComplexMember); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.makereadonce.MembersWithMakeReadOnce plain, global::Pocos.makereadonce.MembersWithMakeReadOnce latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.makeReadOnceMember != makeReadOnceMember.LastValue) + somethingChanged = true; + if (plain.someOtherMember != someOtherMember.LastValue) + somethingChanged = true; + if (await makeReadComplexMember.DetectsAnyChangeAsync(plain.makeReadComplexMember, latest.makeReadComplexMember)) + somethingChanged = true; + if (await someotherComplexMember.DetectsAnyChangeAsync(plain.someotherComplexMember, latest.someotherComplexMember)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.makereadonce.MembersWithMakeReadOnce CreateEmptyPoco() + { + return new global::Pocos.makereadonce.MembersWithMakeReadOnce(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class ComplexMember : AXSharp.Connector.ITwinObject + { + public OnlinerString someMember { get; } + public OnlinerString someOtherMember { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexMember(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + someMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someMember", "someMember"); + someOtherMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someOtherMember", "someOtherMember"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.makereadonce.ComplexMember plain = new global::Pocos.makereadonce.ComplexMember(); + await this.ReadAsync(); + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.makereadonce.ComplexMember plain = new global::Pocos.makereadonce.ComplexMember(); + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.makereadonce.ComplexMember plain) + { + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.makereadonce.ComplexMember plain) + { +#pragma warning disable CS0612 + someMember.LethargicWrite(plain.someMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.makereadonce.ComplexMember plain) + { +#pragma warning disable CS0612 + someMember.LethargicWrite(plain.someMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.makereadonce.ComplexMember plain = new global::Pocos.makereadonce.ComplexMember(); + plain.someMember = someMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.makereadonce.ComplexMember plain) + { + plain.someMember = someMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.makereadonce.ComplexMember plain) + { + someMember.Shadow = plain.someMember; + someOtherMember.Shadow = plain.someOtherMember; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.makereadonce.ComplexMember plain, global::Pocos.makereadonce.ComplexMember latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.someMember != someMember.LastValue) + somethingChanged = true; + if (plain.someOtherMember != someOtherMember.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.makereadonce.ComplexMember CreateEmptyPoco() + { + return new global::Pocos.makereadonce.ComplexMember(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonly.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonly.g.cs new file mode 100644 index 000000000..13438aa72 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/makereadonly.g.cs @@ -0,0 +1,512 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace makereadonly +{ + public partial class MembersWithMakeReadOnly : AXSharp.Connector.ITwinObject + { + [ReadOnly()] + public OnlinerString makeReadOnceMember { get; } + public OnlinerString someOtherMember { get; } + + [ReadOnly()] + public makereadonly.ComplexMember makeReadComplexMember { get; } + public makereadonly.ComplexMember someotherComplexMember { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public MembersWithMakeReadOnly(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + makeReadOnceMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "makeReadOnceMember", "makeReadOnceMember"); + makeReadOnceMember.MakeReadOnly(); + someOtherMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someOtherMember", "someOtherMember"); + makeReadComplexMember = new makereadonly.ComplexMember(this, "makeReadComplexMember", "makeReadComplexMember"); + makeReadComplexMember.MakeReadOnly(); + someotherComplexMember = new makereadonly.ComplexMember(this, "someotherComplexMember", "someotherComplexMember"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.makereadonly.MembersWithMakeReadOnly plain = new global::Pocos.makereadonly.MembersWithMakeReadOnly(); + await this.ReadAsync(); + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.makereadonly.MembersWithMakeReadOnly plain = new global::Pocos.makereadonly.MembersWithMakeReadOnly(); + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain) + { + plain.makeReadOnceMember = makeReadOnceMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; +#pragma warning disable CS0612 + plain.makeReadComplexMember = await makeReadComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain.someotherComplexMember = await someotherComplexMember._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain) + { +#pragma warning disable CS0612 + makeReadOnceMember.LethargicWrite(plain.makeReadOnceMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.makeReadComplexMember._PlainToOnlineNoacAsync(plain.makeReadComplexMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.someotherComplexMember._PlainToOnlineNoacAsync(plain.someotherComplexMember); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain) + { +#pragma warning disable CS0612 + makeReadOnceMember.LethargicWrite(plain.makeReadOnceMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.makeReadComplexMember._PlainToOnlineNoacAsync(plain.makeReadComplexMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this.someotherComplexMember._PlainToOnlineNoacAsync(plain.someotherComplexMember); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.makereadonly.MembersWithMakeReadOnly plain = new global::Pocos.makereadonly.MembersWithMakeReadOnly(); + plain.makeReadOnceMember = makeReadOnceMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + plain.makeReadComplexMember = await makeReadComplexMember.ShadowToPlainAsync(); + plain.someotherComplexMember = await someotherComplexMember.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain) + { + plain.makeReadOnceMember = makeReadOnceMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + plain.makeReadComplexMember = await makeReadComplexMember.ShadowToPlainAsync(); + plain.someotherComplexMember = await someotherComplexMember.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain) + { + makeReadOnceMember.Shadow = plain.makeReadOnceMember; + someOtherMember.Shadow = plain.someOtherMember; + await this.makeReadComplexMember.PlainToShadowAsync(plain.makeReadComplexMember); + await this.someotherComplexMember.PlainToShadowAsync(plain.someotherComplexMember); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.makereadonly.MembersWithMakeReadOnly plain, global::Pocos.makereadonly.MembersWithMakeReadOnly latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.makeReadOnceMember != makeReadOnceMember.LastValue) + somethingChanged = true; + if (plain.someOtherMember != someOtherMember.LastValue) + somethingChanged = true; + if (await makeReadComplexMember.DetectsAnyChangeAsync(plain.makeReadComplexMember, latest.makeReadComplexMember)) + somethingChanged = true; + if (await someotherComplexMember.DetectsAnyChangeAsync(plain.someotherComplexMember, latest.someotherComplexMember)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.makereadonly.MembersWithMakeReadOnly CreateEmptyPoco() + { + return new global::Pocos.makereadonly.MembersWithMakeReadOnly(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class ComplexMember : AXSharp.Connector.ITwinObject + { + public OnlinerString someMember { get; } + public OnlinerString someOtherMember { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ComplexMember(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + someMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someMember", "someMember"); + someOtherMember = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "someOtherMember", "someOtherMember"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.makereadonly.ComplexMember plain = new global::Pocos.makereadonly.ComplexMember(); + await this.ReadAsync(); + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.makereadonly.ComplexMember plain = new global::Pocos.makereadonly.ComplexMember(); + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.makereadonly.ComplexMember plain) + { + plain.someMember = someMember.LastValue; + plain.someOtherMember = someOtherMember.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.makereadonly.ComplexMember plain) + { +#pragma warning disable CS0612 + someMember.LethargicWrite(plain.someMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.makereadonly.ComplexMember plain) + { +#pragma warning disable CS0612 + someMember.LethargicWrite(plain.someMember); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + someOtherMember.LethargicWrite(plain.someOtherMember); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.makereadonly.ComplexMember plain = new global::Pocos.makereadonly.ComplexMember(); + plain.someMember = someMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.makereadonly.ComplexMember plain) + { + plain.someMember = someMember.Shadow; + plain.someOtherMember = someOtherMember.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.makereadonly.ComplexMember plain) + { + someMember.Shadow = plain.someMember; + someOtherMember.Shadow = plain.someOtherMember; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.makereadonly.ComplexMember plain, global::Pocos.makereadonly.ComplexMember latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.someMember != someMember.LastValue) + somethingChanged = true; + if (plain.someOtherMember != someOtherMember.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.makereadonly.ComplexMember CreateEmptyPoco() + { + return new global::Pocos.makereadonly.ComplexMember(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/misc.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/misc.g.cs new file mode 100644 index 000000000..bec932e89 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/misc.g.cs @@ -0,0 +1,1625 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Enums +{ + public partial class ClassWithEnums : AXSharp.Connector.ITwinObject + { + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Enums.Colors))] + public OnlinerInt colors { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Enums.NamedValuesColors))] + public OnlinerString NamedValuesColors { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithEnums(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + colors = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "colors", "colors"); + NamedValuesColors = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "NamedValuesColors", "NamedValuesColors"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + await this.ReadAsync(); + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Enums.ClassWithEnums plain) + { + plain.colors = (Enums.Colors)colors.LastValue; + plain.NamedValuesColors = NamedValuesColors.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Enums.ClassWithEnums plain) + { +#pragma warning disable CS0612 + colors.LethargicWrite((short)plain.colors); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + NamedValuesColors.LethargicWrite(plain.NamedValuesColors); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Enums.ClassWithEnums plain) + { +#pragma warning disable CS0612 + colors.LethargicWrite((short)plain.colors); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + NamedValuesColors.LethargicWrite(plain.NamedValuesColors); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Enums.ClassWithEnums plain = new global::Pocos.Enums.ClassWithEnums(); + plain.colors = (Enums.Colors)colors.Shadow; + plain.NamedValuesColors = NamedValuesColors.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Enums.ClassWithEnums plain) + { + plain.colors = (Enums.Colors)colors.Shadow; + plain.NamedValuesColors = NamedValuesColors.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Enums.ClassWithEnums plain) + { + colors.Shadow = (short)plain.colors; + NamedValuesColors.Shadow = plain.NamedValuesColors; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Enums.ClassWithEnums plain, global::Pocos.Enums.ClassWithEnums latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.colors != (Enums.Colors)latest.colors) + somethingChanged = true; + if (plain.NamedValuesColors != NamedValuesColors.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Enums.ClassWithEnums CreateEmptyPoco() + { + return new global::Pocos.Enums.ClassWithEnums(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public enum Colors + { + Red, + Green, + Blue + } + + public enum NamedValuesColors : String + { + Red = 49, + Green = 50, + Blue = 51 + } +} + +namespace misc +{ + public partial class VariousMembers : AXSharp.Connector.ITwinObject + { + public misc.SomeClass _SomeClass { get; } + public misc.Motor _Motor { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public VariousMembers(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + _SomeClass = new misc.SomeClass(this, "_SomeClass", "_SomeClass"); + _Motor = new misc.Motor(this, "_Motor", "_Motor"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + plain._SomeClass = await _SomeClass._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + plain._Motor = await _Motor._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + await this._SomeClass._PlainToOnlineNoacAsync(plain._SomeClass); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this._Motor._PlainToOnlineNoacAsync(plain._Motor); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.VariousMembers plain) + { +#pragma warning disable CS0612 + await this._SomeClass._PlainToOnlineNoacAsync(plain._SomeClass); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + await this._Motor._PlainToOnlineNoacAsync(plain._Motor); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.VariousMembers plain = new global::Pocos.misc.VariousMembers(); + plain._SomeClass = await _SomeClass.ShadowToPlainAsync(); + plain._Motor = await _Motor.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.VariousMembers plain) + { + plain._SomeClass = await _SomeClass.ShadowToPlainAsync(); + plain._Motor = await _Motor.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.VariousMembers plain) + { + await this._SomeClass.PlainToShadowAsync(plain._SomeClass); + await this._Motor.PlainToShadowAsync(plain._Motor); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.VariousMembers plain, global::Pocos.misc.VariousMembers latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await _SomeClass.DetectsAnyChangeAsync(plain._SomeClass, latest._SomeClass)) + somethingChanged = true; + if (await _Motor.DetectsAnyChangeAsync(plain._Motor, latest._Motor)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.VariousMembers CreateEmptyPoco() + { + return new global::Pocos.misc.VariousMembers(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class SomeClass : AXSharp.Connector.ITwinObject + { + public OnlinerString SomeClassVariable { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SomeClass(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + SomeClassVariable = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "SomeClassVariable", "SomeClassVariable"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + await this.ReadAsync(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.misc.SomeClass plain) + { + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.SomeClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.SomeClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.SomeClass plain = new global::Pocos.misc.SomeClass(); + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.SomeClass plain) + { + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.SomeClass plain) + { + SomeClassVariable.Shadow = plain.SomeClassVariable; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.SomeClass plain, global::Pocos.misc.SomeClass latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.SomeClassVariable != SomeClassVariable.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.SomeClass CreateEmptyPoco() + { + return new global::Pocos.misc.SomeClass(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Motor : AXSharp.Connector.ITwinObject + { + public OnlinerBool isRunning { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + await this.ReadAsync(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.misc.Motor plain) + { + plain.isRunning = isRunning.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.Motor plain = new global::Pocos.misc.Motor(); + plain.isRunning = isRunning.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.Motor plain) + { + plain.isRunning = isRunning.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.Motor plain) + { + isRunning.Shadow = plain.isRunning; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.Motor plain, global::Pocos.misc.Motor latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.isRunning != isRunning.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.Motor CreateEmptyPoco() + { + return new global::Pocos.misc.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Vehicle : AXSharp.Connector.ITwinObject + { + public misc.Motor m { get; } + public OnlinerInt displacement { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + m = new misc.Motor(this, "m", "m"); + displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.misc.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.misc.Vehicle plain = new global::Pocos.misc.Vehicle(); + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.misc.Vehicle plain) + { + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.misc.Vehicle plain) + { + await this.m.PlainToShadowAsync(plain.m); + displacement.Shadow = plain.displacement; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.misc.Vehicle plain, global::Pocos.misc.Vehicle latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await m.DetectsAnyChangeAsync(plain.m, latest.m)) + somethingChanged = true; + if (plain.displacement != displacement.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.misc.Vehicle CreateEmptyPoco() + { + return new global::Pocos.misc.Vehicle(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} + +namespace UnknownArraysShouldNotBeTraspiled +{ + public partial class ClassWithArrays : AXSharp.Connector.ITwinObject + { + public UnknownArraysShouldNotBeTraspiled.Complex[] _complexKnown { get; } + public OnlinerByte[] _primitive { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ClassWithArrays(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + _complexKnown = new UnknownArraysShouldNotBeTraspiled.Complex[11]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_complexKnown, this, "_complexKnown", "_complexKnown", (p, rt, st) => new UnknownArraysShouldNotBeTraspiled.Complex(p, rt, st), new[] { (0, 10) }); + _primitive = new OnlinerByte[11]; + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_primitive, this, "_primitive", "_primitive", (p, rt, st) => @Connector.ConnectorAdapter.AdapterFactory.CreateBYTE(p, rt, st), new[] { (0, 10) }); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { +#pragma warning disable CS0612 + plain._complexKnown = _complexKnown.Select(async p => await p._OnlineToPlainNoacAsync()).Select(p => p.Result).ToArray(); +#pragma warning restore CS0612 + plain._primitive = _primitive.Select(p => p.LastValue).ToArray(); + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _complexKnown.Select(p => p._PlainToOnlineNoacAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _complexKnown.Select(p => p._PlainToOnlineNoacAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + var __primitive_i_FE8484DAB3 = 0; +#pragma warning disable CS0612 + _primitive.Select(p => p.LethargicWrite(plain._primitive[__primitive_i_FE8484DAB3++])).ToArray(); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + plain._complexKnown = _complexKnown.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + plain._complexKnown = _complexKnown.Select(async p => await p.ShadowToPlainAsync()).Select(p => p.Result).ToArray(); + plain._primitive = _primitive.Select(p => p.Shadow).ToArray(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain) + { + var __complexKnown_i_FE8484DAB3 = 0; + _complexKnown.Select(p => p.PlainToShadowAsync(plain._complexKnown[__complexKnown_i_FE8484DAB3++])).ToArray(); + var __primitive_i_FE8484DAB3 = 0; + _primitive.Select(p => p.Shadow = plain._primitive[__primitive_i_FE8484DAB3++]).ToArray(); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays plain, global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest._complexKnown.Length; i760901_3001_mimi++) + { + if (await _complexKnown.ElementAt(i760901_3001_mimi).DetectsAnyChangeAsync(plain._complexKnown[i760901_3001_mimi], latest._complexKnown[i760901_3001_mimi])) + somethingChanged = true; + } + + for (int i760901_3001_mimi = 0; i760901_3001_mimi < latest._primitive.Length; i760901_3001_mimi++) + { + if (latest._primitive.ElementAt(i760901_3001_mimi) != plain._primitive[i760901_3001_mimi]) + somethingChanged = true; + } + + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays CreateEmptyPoco() + { + return new global::Pocos.UnknownArraysShouldNotBeTraspiled.ClassWithArrays(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Complex : AXSharp.Connector.ITwinObject + { + public OnlinerString HelloString { get; } + public OnlinerULInt Id { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Complex(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + HelloString = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "HelloString", "HelloString"); + Id = @Connector.ConnectorAdapter.AdapterFactory.CreateULINT(this, "Id", "Id"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + await this.ReadAsync(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + plain.HelloString = HelloString.LastValue; + plain.Id = Id.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { +#pragma warning disable CS0612 + HelloString.LethargicWrite(plain.HelloString); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Id.LethargicWrite(plain.Id); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain = new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + plain.HelloString = HelloString.Shadow; + plain.Id = Id.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain) + { + HelloString.Shadow = plain.HelloString; + Id.Shadow = plain.Id; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex plain, global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.HelloString != HelloString.LastValue) + somethingChanged = true; + if (plain.Id != Id.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex CreateEmptyPoco() + { + return new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/mixed_access.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/mixed_access.g.cs new file mode 100644 index 000000000..ef4c5f539 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/mixed_access.g.cs @@ -0,0 +1,1556 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class Motor : AXSharp.Connector.ITwinObject +{ + public OnlinerBool Run { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + Run = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "Run", "Run"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + await this.ReadAsync(); + plain.Run = Run.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.Run = Run.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Motor plain) + { + plain.Run = Run.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.Run = Run.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Motor plain) + { + plain.Run = Run.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Motor plain) + { + Run.Shadow = plain.Run; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Motor plain, global::Pocos.Motor latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.Run != Run.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Motor CreateEmptyPoco() + { + return new global::Pocos.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class struct1 : AXSharp.Connector.ITwinObject +{ + public struct2 s2 { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public struct1(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + s2 = new struct2(this, "s2", "s2"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.struct1 plain = new global::Pocos.struct1(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.s2 = await s2._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.struct1 plain = new global::Pocos.struct1(); +#pragma warning disable CS0612 + plain.s2 = await s2._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.struct1 plain) + { +#pragma warning disable CS0612 + plain.s2 = await s2._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.struct1 plain) + { +#pragma warning disable CS0612 + await this.s2._PlainToOnlineNoacAsync(plain.s2); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.struct1 plain) + { +#pragma warning disable CS0612 + await this.s2._PlainToOnlineNoacAsync(plain.s2); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.struct1 plain = new global::Pocos.struct1(); + plain.s2 = await s2.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.struct1 plain) + { + plain.s2 = await s2.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.struct1 plain) + { + await this.s2.PlainToShadowAsync(plain.s2); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.struct1 plain, global::Pocos.struct1 latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await s2.DetectsAnyChangeAsync(plain.s2, latest.s2)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.struct1 CreateEmptyPoco() + { + return new global::Pocos.struct1(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class struct2 : AXSharp.Connector.ITwinObject +{ + public struct3 s3 { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public struct2(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + s3 = new struct3(this, "s3", "s3"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.struct2 plain = new global::Pocos.struct2(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.s3 = await s3._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.struct2 plain = new global::Pocos.struct2(); +#pragma warning disable CS0612 + plain.s3 = await s3._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.struct2 plain) + { +#pragma warning disable CS0612 + plain.s3 = await s3._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.struct2 plain) + { +#pragma warning disable CS0612 + await this.s3._PlainToOnlineNoacAsync(plain.s3); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.struct2 plain) + { +#pragma warning disable CS0612 + await this.s3._PlainToOnlineNoacAsync(plain.s3); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.struct2 plain = new global::Pocos.struct2(); + plain.s3 = await s3.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.struct2 plain) + { + plain.s3 = await s3.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.struct2 plain) + { + await this.s3.PlainToShadowAsync(plain.s3); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.struct2 plain, global::Pocos.struct2 latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await s3.DetectsAnyChangeAsync(plain.s3, latest.s3)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.struct2 CreateEmptyPoco() + { + return new global::Pocos.struct2(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class struct3 : AXSharp.Connector.ITwinObject +{ + public struct4 s4 { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public struct3(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + s4 = new struct4(this, "s4", "s4"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.struct3 plain = new global::Pocos.struct3(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.s4 = await s4._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.struct3 plain = new global::Pocos.struct3(); +#pragma warning disable CS0612 + plain.s4 = await s4._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.struct3 plain) + { +#pragma warning disable CS0612 + plain.s4 = await s4._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.struct3 plain) + { +#pragma warning disable CS0612 + await this.s4._PlainToOnlineNoacAsync(plain.s4); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.struct3 plain) + { +#pragma warning disable CS0612 + await this.s4._PlainToOnlineNoacAsync(plain.s4); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.struct3 plain = new global::Pocos.struct3(); + plain.s4 = await s4.ShadowToPlainAsync(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.struct3 plain) + { + plain.s4 = await s4.ShadowToPlainAsync(); + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.struct3 plain) + { + await this.s4.PlainToShadowAsync(plain.s4); + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.struct3 plain, global::Pocos.struct3 latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await s4.DetectsAnyChangeAsync(plain.s4, latest.s4)) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.struct3 CreateEmptyPoco() + { + return new global::Pocos.struct3(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class struct4 : AXSharp.Connector.ITwinObject +{ + public OnlinerInt s5 { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public struct4(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + s5 = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "s5", "s5"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.struct4 plain = new global::Pocos.struct4(); + await this.ReadAsync(); + plain.s5 = s5.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.struct4 plain = new global::Pocos.struct4(); + plain.s5 = s5.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.struct4 plain) + { + plain.s5 = s5.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.struct4 plain) + { +#pragma warning disable CS0612 + s5.LethargicWrite(plain.s5); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.struct4 plain) + { +#pragma warning disable CS0612 + s5.LethargicWrite(plain.s5); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.struct4 plain = new global::Pocos.struct4(); + plain.s5 = s5.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.struct4 plain) + { + plain.s5 = s5.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.struct4 plain) + { + s5.Shadow = plain.s5; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.struct4 plain, global::Pocos.struct4 latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.s5 != s5.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.struct4 CreateEmptyPoco() + { + return new global::Pocos.struct4(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class AbstractMotor : AXSharp.Connector.ITwinObject +{ + public OnlinerBool Run { get; } + public OnlinerBool ReverseDirection { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public AbstractMotor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + Run = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "Run", "Run"); + ReverseDirection = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "ReverseDirection", "ReverseDirection"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + await this.ReadAsync(); + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.AbstractMotor plain) + { + plain.Run = Run.LastValue; + plain.ReverseDirection = ReverseDirection.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.AbstractMotor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + ReverseDirection.LethargicWrite(plain.ReverseDirection); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.AbstractMotor plain) + { +#pragma warning disable CS0612 + Run.LethargicWrite(plain.Run); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + ReverseDirection.LethargicWrite(plain.ReverseDirection); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.AbstractMotor plain = new global::Pocos.AbstractMotor(); + plain.Run = Run.Shadow; + plain.ReverseDirection = ReverseDirection.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.AbstractMotor plain) + { + plain.Run = Run.Shadow; + plain.ReverseDirection = ReverseDirection.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.AbstractMotor plain) + { + Run.Shadow = plain.Run; + ReverseDirection.Shadow = plain.ReverseDirection; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.AbstractMotor plain, global::Pocos.AbstractMotor latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.Run != Run.LastValue) + somethingChanged = true; + if (plain.ReverseDirection != ReverseDirection.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.AbstractMotor CreateEmptyPoco() + { + return new global::Pocos.AbstractMotor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class GenericMotor : AbstractMotor +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public GenericMotor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.GenericMotor plain = new global::Pocos.GenericMotor(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.GenericMotor plain = new global::Pocos.GenericMotor(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.GenericMotor plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.GenericMotor plain) + { + await base._PlainToOnlineNoacAsync(plain); + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.GenericMotor plain) + { + await base._PlainToOnlineNoacAsync(plain); + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.GenericMotor plain = new global::Pocos.GenericMotor(); + await base.ShadowToPlainAsync(plain); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.GenericMotor plain) + { + await base.ShadowToPlainAsync(plain); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.GenericMotor plain) + { + await base.PlainToShadowAsync(plain); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.GenericMotor plain, global::Pocos.GenericMotor latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.GenericMotor CreateEmptyPoco() + { + return new global::Pocos.GenericMotor(); + } +} + +public partial class SpecificMotorA : GenericMotor +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SpecificMotorA(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) : base(parent, readableTail, symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + PostConstruct(parent, readableTail, symbolTail); + } + + public async override Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public new async Task OnlineToPlainAsync() + { + global::Pocos.SpecificMotorA plain = new global::Pocos.SpecificMotorA(); + await this.ReadAsync(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public new async Task _OnlineToPlainNoacAsync() + { + global::Pocos.SpecificMotorA plain = new global::Pocos.SpecificMotorA(); +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.SpecificMotorA plain) + { +#pragma warning disable CS0612 + await base._OnlineToPlainNoacAsync(plain); +#pragma warning restore CS0612 + return plain; + } + + public async override Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.SpecificMotorA plain) + { + await base._PlainToOnlineNoacAsync(plain); + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.SpecificMotorA plain) + { + await base._PlainToOnlineNoacAsync(plain); + } + + public async override Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public new async Task ShadowToPlainAsync() + { + global::Pocos.SpecificMotorA plain = new global::Pocos.SpecificMotorA(); + await base.ShadowToPlainAsync(plain); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.SpecificMotorA plain) + { + await base.ShadowToPlainAsync(plain); + return plain; + } + + public async override Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.SpecificMotorA plain) + { + await base.PlainToShadowAsync(plain); + return this.RetrievePrimitives(); + } + + /// + public async override Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public new async Task DetectsAnyChangeAsync(global::Pocos.SpecificMotorA plain, global::Pocos.SpecificMotorA latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (await base.DetectsAnyChangeAsync(plain)) + return true; + plain = latest; + return somethingChanged; + }); + } + + public new void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public new global::Pocos.SpecificMotorA CreateEmptyPoco() + { + return new global::Pocos.SpecificMotorA(); + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/program.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/program.g.cs new file mode 100644 index 000000000..6c546f63c --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/program.g.cs @@ -0,0 +1,6 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/ref_to_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/ref_to_simple.g.cs new file mode 100644 index 000000000..3d241e88e --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/ref_to_simple.g.cs @@ -0,0 +1,414 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace RefToSimple +{ + public partial class ref_to_simple : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public ref_to_simple(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.RefToSimple.ref_to_simple plain = new global::Pocos.RefToSimple.ref_to_simple(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.RefToSimple.ref_to_simple plain = new global::Pocos.RefToSimple.ref_to_simple(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.RefToSimple.ref_to_simple plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.RefToSimple.ref_to_simple plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.RefToSimple.ref_to_simple plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.RefToSimple.ref_to_simple plain = new global::Pocos.RefToSimple.ref_to_simple(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.RefToSimple.ref_to_simple plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.RefToSimple.ref_to_simple plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.RefToSimple.ref_to_simple plain, global::Pocos.RefToSimple.ref_to_simple latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.RefToSimple.ref_to_simple CreateEmptyPoco() + { + return new global::Pocos.RefToSimple.ref_to_simple(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class referenced : AXSharp.Connector.ITwinObject + { + public OnlinerInt b { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public referenced(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + b = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "b", "b"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.RefToSimple.referenced plain = new global::Pocos.RefToSimple.referenced(); + await this.ReadAsync(); + plain.b = b.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.RefToSimple.referenced plain = new global::Pocos.RefToSimple.referenced(); + plain.b = b.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.RefToSimple.referenced plain) + { + plain.b = b.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.RefToSimple.referenced plain) + { +#pragma warning disable CS0612 + b.LethargicWrite(plain.b); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.RefToSimple.referenced plain) + { +#pragma warning disable CS0612 + b.LethargicWrite(plain.b); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.RefToSimple.referenced plain = new global::Pocos.RefToSimple.referenced(); + plain.b = b.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.RefToSimple.referenced plain) + { + plain.b = b.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.RefToSimple.referenced plain) + { + b.Shadow = plain.b; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.RefToSimple.referenced plain, global::Pocos.RefToSimple.referenced latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.b != b.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.RefToSimple.referenced CreateEmptyPoco() + { + return new global::Pocos.RefToSimple.referenced(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class.g.cs new file mode 100644 index 000000000..b0e4d2fac --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class.g.cs @@ -0,0 +1,200 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class simple_class : AXSharp.Connector.ITwinObject +{ + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public simple_class(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.simple_class plain = new global::Pocos.simple_class(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.simple_class plain = new global::Pocos.simple_class(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.simple_class plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.simple_class plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.simple_class plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.simple_class plain = new global::Pocos.simple_class(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.simple_class plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.simple_class plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.simple_class plain, global::Pocos.simple_class latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.simple_class CreateEmptyPoco() + { + return new global::Pocos.simple_class(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class_within_namespace.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class_within_namespace.g.cs new file mode 100644 index 000000000..a1d3ff791 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/simple_empty_class_within_namespace.g.cs @@ -0,0 +1,203 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace sampleNamespace +{ + public partial class simple_empty_class_within_namespace : AXSharp.Connector.ITwinObject + { + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public simple_empty_class_within_namespace(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain = new global::Pocos.sampleNamespace.simple_empty_class_within_namespace(); + await this.ReadAsync(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain = new global::Pocos.sampleNamespace.simple_empty_class_within_namespace(); + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain) + { + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain) + { + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain) + { + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain = new global::Pocos.sampleNamespace.simple_empty_class_within_namespace(); + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain) + { + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain) + { + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.sampleNamespace.simple_empty_class_within_namespace plain, global::Pocos.sampleNamespace.simple_empty_class_within_namespace latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.sampleNamespace.simple_empty_class_within_namespace CreateEmptyPoco() + { + return new global::Pocos.sampleNamespace.simple_empty_class_within_namespace(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/struct_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/struct_simple.g.cs new file mode 100644 index 000000000..58204ec80 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/struct_simple.g.cs @@ -0,0 +1,446 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +public partial class Motor : AXSharp.Connector.ITwinObject +{ + public OnlinerBool isRunning { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + await this.ReadAsync(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.Motor plain) + { + plain.isRunning = isRunning.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Motor plain = new global::Pocos.Motor(); + plain.isRunning = isRunning.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Motor plain) + { + plain.isRunning = isRunning.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Motor plain) + { + isRunning.Shadow = plain.isRunning; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Motor plain, global::Pocos.Motor latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.isRunning != isRunning.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Motor CreateEmptyPoco() + { + return new global::Pocos.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} + +public partial class Vehicle : AXSharp.Connector.ITwinObject +{ + public Motor m { get; } + public OnlinerInt displacement { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + m = new Motor(this, "m", "m"); + displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Vehicle plain = new global::Pocos.Vehicle(); + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Vehicle plain) + { + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Vehicle plain) + { + await this.m.PlainToShadowAsync(plain.m); + displacement.Shadow = plain.displacement; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Vehicle plain, global::Pocos.Vehicle latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await m.DetectsAnyChangeAsync(plain.m, latest.m)) + somethingChanged = true; + if (plain.displacement != displacement.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Vehicle CreateEmptyPoco() + { + return new global::Pocos.Vehicle(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values.g.cs new file mode 100644 index 000000000..7dd1df0bc --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values.g.cs @@ -0,0 +1,228 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace NamedValuesNamespace +{ + public enum LightColors : Int16 + { + LRED = 12, + LGREEN = 14, + LBLUE = 23 + } + + public partial class using_type_named_values : AXSharp.Connector.ITwinObject + { + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(NamedValuesNamespace.LightColors))] + public OnlinerInt LColors { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public using_type_named_values(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + LColors = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "LColors", "LColors"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.NamedValuesNamespace.using_type_named_values plain = new global::Pocos.NamedValuesNamespace.using_type_named_values(); + await this.ReadAsync(); + plain.LColors = LColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.NamedValuesNamespace.using_type_named_values plain = new global::Pocos.NamedValuesNamespace.using_type_named_values(); + plain.LColors = LColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain) + { + plain.LColors = LColors.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain) + { +#pragma warning disable CS0612 + LColors.LethargicWrite(plain.LColors); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain) + { +#pragma warning disable CS0612 + LColors.LethargicWrite(plain.LColors); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.NamedValuesNamespace.using_type_named_values plain = new global::Pocos.NamedValuesNamespace.using_type_named_values(); + plain.LColors = LColors.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain) + { + plain.LColors = LColors.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain) + { + LColors.Shadow = plain.LColors; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.NamedValuesNamespace.using_type_named_values plain, global::Pocos.NamedValuesNamespace.using_type_named_values latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.LColors != LColors.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.NamedValuesNamespace.using_type_named_values CreateEmptyPoco() + { + return new global::Pocos.NamedValuesNamespace.using_type_named_values(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values_literals.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values_literals.g.cs new file mode 100644 index 000000000..47f1f20cc --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_named_values_literals.g.cs @@ -0,0 +1,230 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Simatic.Ax.StateFramework +{ + public enum StateControllerStatus : UInt16 + { + STATUS_NO_ERR = 28672, + STATUS_IS_RUNNING = 28673, + STATUS_STATE_CHANGED = 28674, + STATUS_NO_INITIALSTATE = 33024, + STATUS_NO_NEXTSTATE = 33025 + } + + public partial class using_type_named_values : AXSharp.Connector.ITwinObject + { + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Simatic.Ax.StateFramework.StateControllerStatus))] + public OnlinerWord LColors { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public using_type_named_values(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + LColors = @Connector.ConnectorAdapter.AdapterFactory.CreateWORD(this, "LColors", "LColors"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain = new global::Pocos.Simatic.Ax.StateFramework.using_type_named_values(); + await this.ReadAsync(); + plain.LColors = LColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain = new global::Pocos.Simatic.Ax.StateFramework.using_type_named_values(); + plain.LColors = LColors.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain) + { + plain.LColors = LColors.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain) + { +#pragma warning disable CS0612 + LColors.LethargicWrite(plain.LColors); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain) + { +#pragma warning disable CS0612 + LColors.LethargicWrite(plain.LColors); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain = new global::Pocos.Simatic.Ax.StateFramework.using_type_named_values(); + plain.LColors = LColors.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain) + { + plain.LColors = LColors.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain) + { + LColors.Shadow = plain.LColors; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Simatic.Ax.StateFramework.using_type_named_values plain, global::Pocos.Simatic.Ax.StateFramework.using_type_named_values latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.LColors != LColors.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Simatic.Ax.StateFramework.using_type_named_values CreateEmptyPoco() + { + return new global::Pocos.Simatic.Ax.StateFramework.using_type_named_values(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_with_enum.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_with_enum.g.cs new file mode 100644 index 000000000..a8e9331fc --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/type_with_enum.g.cs @@ -0,0 +1,255 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace Simatic.Ax.StateFramework +{ + public partial interface IGuard + { + } +} + +namespace Simatic.Ax.StateFramework +{ + public enum Condition + { + GT, + EQ, + LT, + NE, + GE, + LE + } + + public partial class CompareGuardLint : AXSharp.Connector.ITwinObject, IGuard + { + public OnlinerLInt CompareToValue { get; } + + [AXSharp.Connector.EnumeratorDiscriminatorAttribute(typeof(Simatic.Ax.StateFramework.Condition))] + public OnlinerInt Condition { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public CompareGuardLint(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + CompareToValue = @Connector.ConnectorAdapter.AdapterFactory.CreateLINT(this, "CompareToValue", "CompareToValue"); + Condition = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "Condition", "Condition"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain = new global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint(); + await this.ReadAsync(); + plain.CompareToValue = CompareToValue.LastValue; + plain.Condition = (Simatic.Ax.StateFramework.Condition)Condition.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain = new global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint(); + plain.CompareToValue = CompareToValue.LastValue; + plain.Condition = (Simatic.Ax.StateFramework.Condition)Condition.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain) + { + plain.CompareToValue = CompareToValue.LastValue; + plain.Condition = (Simatic.Ax.StateFramework.Condition)Condition.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain) + { +#pragma warning disable CS0612 + CompareToValue.LethargicWrite(plain.CompareToValue); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Condition.LethargicWrite((short)plain.Condition); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain) + { +#pragma warning disable CS0612 + CompareToValue.LethargicWrite(plain.CompareToValue); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + Condition.LethargicWrite((short)plain.Condition); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain = new global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint(); + plain.CompareToValue = CompareToValue.Shadow; + plain.Condition = (Simatic.Ax.StateFramework.Condition)Condition.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain) + { + plain.CompareToValue = CompareToValue.Shadow; + plain.Condition = (Simatic.Ax.StateFramework.Condition)Condition.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain) + { + CompareToValue.Shadow = plain.CompareToValue; + Condition.Shadow = (short)plain.Condition; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint plain, global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.CompareToValue != CompareToValue.LastValue) + somethingChanged = true; + if (plain.Condition != (Simatic.Ax.StateFramework.Condition)latest.Condition) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint CreateEmptyPoco() + { + return new global::Pocos.Simatic.Ax.StateFramework.CompareGuardLint(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_name_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_name_attributes.g.cs new file mode 100644 index 000000000..7fbaae04e --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_name_attributes.g.cs @@ -0,0 +1,669 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace TypeWithNameAttributes +{ + [Container(Layout.Wrap)] + public partial class Motor : AXSharp.Connector.ITwinObject + { + public OnlinerBool isRunning { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.Motor plain = new global::Pocos.TypeWithNameAttributes.Motor(); + await this.ReadAsync(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.TypeWithNameAttributes.Motor plain = new global::Pocos.TypeWithNameAttributes.Motor(); + plain.isRunning = isRunning.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.TypeWithNameAttributes.Motor plain) + { + plain.isRunning = isRunning.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.TypeWithNameAttributes.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.TypeWithNameAttributes.Motor plain) + { +#pragma warning disable CS0612 + isRunning.LethargicWrite(plain.isRunning); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.Motor plain = new global::Pocos.TypeWithNameAttributes.Motor(); + plain.isRunning = isRunning.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.TypeWithNameAttributes.Motor plain) + { + plain.isRunning = isRunning.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.TypeWithNameAttributes.Motor plain) + { + isRunning.Shadow = plain.isRunning; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.TypeWithNameAttributes.Motor plain, global::Pocos.TypeWithNameAttributes.Motor latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (plain.isRunning != isRunning.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.TypeWithNameAttributes.Motor CreateEmptyPoco() + { + return new global::Pocos.TypeWithNameAttributes.Motor(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class Vehicle : AXSharp.Connector.ITwinObject + { + public TypeWithNameAttributes.Motor m { get; } + public OnlinerInt displacement { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + PreConstruct(parent, readableTail, symbolTail); + m = new TypeWithNameAttributes.Motor(this, "m", "m"); + displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.Vehicle plain = new global::Pocos.TypeWithNameAttributes.Vehicle(); + await this.ReadAsync(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.TypeWithNameAttributes.Vehicle plain = new global::Pocos.TypeWithNameAttributes.Vehicle(); +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + protected async Task OnlineToPlainAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain) + { +#pragma warning disable CS0612 + plain.m = await m._OnlineToPlainNoacAsync(); +#pragma warning restore CS0612 + plain.displacement = displacement.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain) + { +#pragma warning disable CS0612 + await this.m._PlainToOnlineNoacAsync(plain.m); +#pragma warning restore CS0612 +#pragma warning disable CS0612 + displacement.LethargicWrite(plain.displacement); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.Vehicle plain = new global::Pocos.TypeWithNameAttributes.Vehicle(); + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain) + { + plain.m = await m.ShadowToPlainAsync(); + plain.displacement = displacement.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain) + { + await this.m.PlainToShadowAsync(plain.m); + displacement.Shadow = plain.displacement; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.TypeWithNameAttributes.Vehicle plain, global::Pocos.TypeWithNameAttributes.Vehicle latest = null) + { + var somethingChanged = false; + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + return await Task.Run(async () => + { + if (await m.DetectsAnyChangeAsync(plain.m, latest.m)) + somethingChanged = true; + if (plain.displacement != displacement.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.TypeWithNameAttributes.Vehicle CreateEmptyPoco() + { + return new global::Pocos.TypeWithNameAttributes.Vehicle(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } + + public partial class NoAccessModifierClass : AXSharp.Connector.ITwinObject + { + private string _AttributeName; + public string AttributeName { get => string.IsNullOrEmpty(_AttributeName) ? SymbolTail : _AttributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _AttributeName = value; } + + public string GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_AttributeName, culture).Interpolate(this); + } + + public OnlinerString SomeClassVariable { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public NoAccessModifierClass(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + SomeClassVariable = @Connector.ConnectorAdapter.AdapterFactory.CreateSTRING(this, "SomeClassVariable", "SomeClassVariable"); + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain = new global::Pocos.TypeWithNameAttributes.NoAccessModifierClass(); + await this.ReadAsync(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain = new global::Pocos.TypeWithNameAttributes.NoAccessModifierClass(); + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain) + { + plain.SomeClassVariable = SomeClassVariable.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain) + { +#pragma warning disable CS0612 + SomeClassVariable.LethargicWrite(plain.SomeClassVariable); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain = new global::Pocos.TypeWithNameAttributes.NoAccessModifierClass(); + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain) + { + plain.SomeClassVariable = SomeClassVariable.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain) + { + SomeClassVariable.Shadow = plain.SomeClassVariable; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.TypeWithNameAttributes.NoAccessModifierClass plain, global::Pocos.TypeWithNameAttributes.NoAccessModifierClass latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.SomeClassVariable != SomeClassVariable.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.TypeWithNameAttributes.NoAccessModifierClass CreateEmptyPoco() + { + return new global::Pocos.TypeWithNameAttributes.NoAccessModifierClass(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_property_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_property_attributes.g.cs new file mode 100644 index 000000000..abd8376bc --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/Onliners/types_with_property_attributes.g.cs @@ -0,0 +1,230 @@ +using System; +using AXSharp.Connector; +using AXSharp.Connector.ValueTypes; +using System.Collections.Generic; +using AXSharp.Connector.Localizations; +using AXSharp.Abstractions.Presentation; + +namespace TypesWithPropertyAttributes +{ + public partial class SomeAddedProperties : AXSharp.Connector.ITwinObject + { + private string _Description; + public string Description { get => string.IsNullOrEmpty(_Description) ? SymbolTail : _Description.Interpolate(this).CleanUpLocalizationTokens(); set => _Description = value; } + + public string GetDescription(System.Globalization.CultureInfo culture) + { + return this.Translate(_Description, culture).Interpolate(this); + } + + public OnlinerInt Counter { get; } + + partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail); + public SomeAddedProperties(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail) + { + Description = "Some added property name value"; + Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail); + this.@SymbolTail = symbolTail; + this.@Connector = parent.GetConnector(); + this.@Parent = parent; + HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail); + PreConstruct(parent, readableTail, symbolTail); + Counter = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "Pocitadlo", "Counter"); + Counter.AttributeName = "Pocitadlo"; + parent.AddChild(this); + parent.AddKid(this); + PostConstruct(parent, readableTail, symbolTail); + } + + public async virtual Task OnlineToPlain() + { + return await (dynamic)this.OnlineToPlainAsync(); + } + + public async Task OnlineToPlainAsync() + { + global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain = new global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties(); + await this.ReadAsync(); + plain.Counter = Counter.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _OnlineToPlainNoacAsync() + { + global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain = new global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties(); + plain.Counter = Counter.LastValue; + return plain; + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected async Task _OnlineToPlainNoacAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain) + { + plain.Counter = Counter.LastValue; + return plain; + } + + public async virtual Task PlainToOnline(T plain) + { + await this.PlainToOnlineAsync((dynamic)plain); + } + + public async Task> PlainToOnlineAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain) + { +#pragma warning disable CS0612 + Counter.LethargicWrite(plain.Counter); +#pragma warning restore CS0612 + return await this.WriteAsync(); + } + + [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public async Task _PlainToOnlineNoacAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain) + { +#pragma warning disable CS0612 + Counter.LethargicWrite(plain.Counter); +#pragma warning restore CS0612 + } + + public async virtual Task ShadowToPlain() + { + return await (dynamic)this.ShadowToPlainAsync(); + } + + public async Task ShadowToPlainAsync() + { + global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain = new global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties(); + plain.Counter = Counter.Shadow; + return plain; + } + + protected async Task ShadowToPlainAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain) + { + plain.Counter = Counter.Shadow; + return plain; + } + + public async virtual Task PlainToShadow(T plain) + { + await this.PlainToShadowAsync((dynamic)plain); + } + + public async Task> PlainToShadowAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain) + { + Counter.Shadow = plain.Counter; + return this.RetrievePrimitives(); + } + + /// + public async virtual Task AnyChangeAsync(T plain) + { + return await this.DetectsAnyChangeAsync((dynamic)plain); + } + + /// + ///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated. + ///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed. + /// + public async Task DetectsAnyChangeAsync(global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties plain, global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties latest = null) + { + if (latest == null) + latest = await this._OnlineToPlainNoacAsync(); + var somethingChanged = false; + return await Task.Run(async () => + { + if (plain.Counter != Counter.LastValue) + somethingChanged = true; + plain = latest; + return somethingChanged; + }); + } + + public void Poll() + { + this.RetrievePrimitives().ToList().ForEach(x => x.Poll()); + } + + public global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties CreateEmptyPoco() + { + return new global::Pocos.TypesWithPropertyAttributes.SomeAddedProperties(); + } + + private IList Children { get; } = new List(); + + public IEnumerable GetChildren() + { + return Children; + } + + private IList Kids { get; } = new List(); + + public IEnumerable GetKids() + { + return Kids; + } + + private IList ValueTags { get; } = new List(); + + public IEnumerable GetValueTags() + { + return ValueTags; + } + + public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag) + { + ValueTags.Add(valueTag); + } + + public void AddKid(AXSharp.Connector.ITwinElement kid) + { + Kids.Add(kid); + } + + public void AddChild(AXSharp.Connector.ITwinObject twinObject) + { + Children.Add(twinObject); + } + + protected AXSharp.Connector.Connector @Connector { get; } + + public AXSharp.Connector.Connector GetConnector() + { + return this.@Connector; + } + + public string GetSymbolTail() + { + return this.SymbolTail; + } + + public AXSharp.Connector.ITwinObject GetParent() + { + return this.@Parent; + } + + public string Symbol { get; protected set; } + + private string _attributeName; + public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; } + + public System.String GetAttributeName(System.Globalization.CultureInfo culture) + { + return this.Translate(_attributeName, culture).Interpolate(this); + } + + private string _humanReadable; + public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; } + + public System.String GetHumanReadable(System.Globalization.CultureInfo culture) + { + return this.Translate(_humanReadable, culture); + } + + protected System.String @SymbolTail { get; set; } + protected AXSharp.Connector.ITwinObject @Parent { get; set; } + public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/abstract_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/abstract_members.g.cs new file mode 100644 index 000000000..5400b2acd --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/abstract_members.g.cs @@ -0,0 +1,16 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class AbstractMotor : AXSharp.Connector.IPlain + { + public AbstractMotor() + { + } + + public Boolean Run { get; set; } + public Boolean ReverseDirection { get; set; } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/array_declaration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/array_declaration.g.cs new file mode 100644 index 000000000..ce30a3c87 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/array_declaration.g.cs @@ -0,0 +1,29 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace ArrayDeclarationSimpleNamespace + { + public partial class array_declaration_class : AXSharp.Connector.IPlain + { + public array_declaration_class() + { +#pragma warning disable CS0612 + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(complex, () => new global::Pocos.ArrayDeclarationSimpleNamespace.some_complex_type(), new[] { (1, 100) }); +#pragma warning restore CS0612 + } + + public Int16[] primitive { get; set; } = new Int16[100]; + public ArrayDeclarationSimpleNamespace.some_complex_type[] complex { get; set; } = new ArrayDeclarationSimpleNamespace.some_complex_type[100]; + } + + public partial class some_complex_type : AXSharp.Connector.IPlain + { + public some_complex_type() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_all_primitives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_all_primitives.g.cs new file mode 100644 index 000000000..422a2a2d1 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_all_primitives.g.cs @@ -0,0 +1,36 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class class_all_primitives : AXSharp.Connector.IPlain + { + public class_all_primitives() + { + } + + public Boolean myBOOL { get; set; } + public Byte myBYTE { get; set; } + public UInt16 myWORD { get; set; } + public UInt32 myDWORD { get; set; } + public UInt64 myLWORD { get; set; } + public SByte mySINT { get; set; } + public Int16 myINT { get; set; } + public Int32 myDINT { get; set; } + public Int64 myLINT { get; set; } + public Byte myUSINT { get; set; } + public UInt16 myUINT { get; set; } + public UInt32 myUDINT { get; set; } + public UInt64 myULINT { get; set; } + public Single myREAL { get; set; } + public Double myLREAL { get; set; } + public TimeSpan myTIME { get; set; } = default(TimeSpan); + public TimeSpan myLTIME { get; set; } = default(TimeSpan); + public DateOnly myDATE { get; set; } = new DateOnly(1990, 1, 1); + public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1990, 1, 1); + public string mySTRING { get; set; } = string.Empty; + public string myWSTRING { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extended_by_known_type.g.cs new file mode 100644 index 000000000..221f97ee3 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extended_by_known_type.g.cs @@ -0,0 +1,29 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Simatic.Ax.StateFramework + { + public partial class State1Transition : Simatic.Ax.StateFramework.AbstractState, AXSharp.Connector.IPlain + { + public State1Transition() : base() + { + } + } + } + + namespace Simatic.Ax.StateFramework + { + public partial class AbstractState : AXSharp.Connector.IPlain, IState, IStateMuteable + { + public AbstractState() + { + } + + public Int16 StateID { get; set; } + public string StateName { get; set; } = string.Empty; + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends.g.cs new file mode 100644 index 000000000..4ce871c91 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends.g.cs @@ -0,0 +1,20 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class Extended : Extendee, AXSharp.Connector.IPlain + { + public Extended() : base() + { + } + } + + public partial class Extendee : AXSharp.Connector.IPlain + { + public Extendee() + { + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends_and_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends_and_implements.g.cs new file mode 100644 index 000000000..91481513b --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_extends_and_implements.g.cs @@ -0,0 +1,28 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class ExtendsAndImplements : ExtendeeExtendsAndImplements, AXSharp.Connector.IPlain, IImplementation1, IImplementation2 + { + public ExtendsAndImplements() : base() + { + } + } + + public partial class ExtendeeExtendsAndImplements : AXSharp.Connector.IPlain + { + public ExtendeeExtendsAndImplements() + { + } + } + + public partial interface IImplementation1 + { + } + + public partial interface IImplementation2 + { + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_generic_extension.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_generic_extension.g.cs new file mode 100644 index 000000000..906b0bc07 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_generic_extension.g.cs @@ -0,0 +1,42 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Generics + { + public partial class Extender : AXSharp.Connector.IPlain + { + public Extender() + { + } + } + + public partial class Extendee : Generics.Extender, AXSharp.Connector.IPlain + { + public Extendee() : base() + { + } + + public Generics.SomeType SomeType { get; set; } = new Generics.SomeType(); + public Generics.SomeType SomeTypeAsPoco { get; set; } = new Generics.SomeType(); + } + + public partial class Extendee2 : Generics.Extender, AXSharp.Connector.IPlain + { + public Extendee2() : base() + { + } + + public Generics.SomeType SomeType { get; set; } = new Generics.SomeType(); + } + + public partial class SomeType : AXSharp.Connector.IPlain + { + public SomeType() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements.g.cs new file mode 100644 index 000000000..5eb39ed0d --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements.g.cs @@ -0,0 +1,17 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class _NULL_CONTEXT : AXSharp.Connector.IPlain, IContext + { + public _NULL_CONTEXT() + { + } + } + + public partial interface IContext + { + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements_multiple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements_multiple.g.cs new file mode 100644 index 000000000..aca3704d2 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_implements_multiple.g.cs @@ -0,0 +1,21 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class _NULL_CONTEXT_MULTIPLE : AXSharp.Connector.IPlain, IContext_Multiple, IObject_Multiple + { + public _NULL_CONTEXT_MULTIPLE() + { + } + } + + public partial interface IContext_Multiple + { + } + + public partial interface IObject_Multiple + { + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_internal.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_internal.g.cs new file mode 100644 index 000000000..e4ba926f3 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_internal.g.cs @@ -0,0 +1,13 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + internal partial class ClassWithComplexTypes : AXSharp.Connector.IPlain + { + public ClassWithComplexTypes() + { + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_no_access_modifier.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_no_access_modifier.g.cs new file mode 100644 index 000000000..43b8cdaaf --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_no_access_modifier.g.cs @@ -0,0 +1,13 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class NoAccessModifierClass : AXSharp.Connector.IPlain + { + public NoAccessModifierClass() + { + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_complex_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_complex_members.g.cs new file mode 100644 index 000000000..27f5f1d89 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_complex_members.g.cs @@ -0,0 +1,25 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace ClassWithComplexTypesNamespace + { + public partial class ClassWithComplexTypes : AXSharp.Connector.IPlain + { + public ClassWithComplexTypes() + { + } + + public ClassWithComplexTypesNamespace.ComplexType1 myComplexType { get; set; } = new ClassWithComplexTypesNamespace.ComplexType1(); + } + + public partial class ComplexType1 : AXSharp.Connector.IPlain + { + public ComplexType1() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_non_public_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_non_public_members.g.cs new file mode 100644 index 000000000..7f96b8734 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_non_public_members.g.cs @@ -0,0 +1,25 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace ClassWithNonTraspilableMemberssNamespace + { + public partial class ClassWithNonTraspilableMembers : AXSharp.Connector.IPlain + { + public ClassWithNonTraspilableMembers() + { + } + + public ClassWithNonTraspilableMemberssNamespace.ComplexType1 myComplexType { get; set; } = new ClassWithNonTraspilableMemberssNamespace.ComplexType1(); + } + + public partial class ComplexType1 : AXSharp.Connector.IPlain + { + public ComplexType1() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_pragmas.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_pragmas.g.cs new file mode 100644 index 000000000..3f2f1d384 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_pragmas.g.cs @@ -0,0 +1,25 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace ClassWithPragmasNamespace + { + public partial class ClassWithPragmas : AXSharp.Connector.IPlain + { + public ClassWithPragmas() + { + } + + public ClassWithPragmasNamespace.ComplexType1 myComplexType { get; set; } = new ClassWithPragmasNamespace.ComplexType1(); + } + + public partial class ComplexType1 : AXSharp.Connector.IPlain + { + public ComplexType1() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_primitive_members.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_primitive_members.g.cs new file mode 100644 index 000000000..1c2a95889 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_primitive_members.g.cs @@ -0,0 +1,44 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace ClassWithPrimitiveTypesNamespace + { + public partial class ClassWithPrimitiveTypes : AXSharp.Connector.IPlain + { + public ClassWithPrimitiveTypes() + { + } + + public Boolean myBOOL { get; set; } + public Byte myBYTE { get; set; } + public UInt16 myWORD { get; set; } + public UInt32 myDWORD { get; set; } + public UInt64 myLWORD { get; set; } + public SByte mySINT { get; set; } + public Int16 myINT { get; set; } + public Int32 myDINT { get; set; } + public Int64 myLINT { get; set; } + public Byte myUSINT { get; set; } + public UInt16 myUINT { get; set; } + public UInt32 myUDINT { get; set; } + public UInt64 myULINT { get; set; } + public Single myREAL { get; set; } + public Double myLREAL { get; set; } + public TimeSpan myTIME { get; set; } = default(TimeSpan); + public TimeSpan myLTIME { get; set; } = default(TimeSpan); + public DateOnly myDATE { get; set; } = new DateOnly(1990, 1, 1); + public DateOnly myLDATE { get; set; } = new DateOnly(1990, 1, 1); + public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); + public TimeSpan myLTIME_OF_DAY { get; set; } = default(TimeSpan); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1990, 1, 1); + public DateTime myLDATE_AND_TIME { get; set; } = new DateTime(1990, 1, 1); + public Char myCHAR { get; set; } + public Char myWCHAR { get; set; } + public string mySTRING { get; set; } = string.Empty; + public string myWSTRING { get; set; } = string.Empty; + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_using_directives.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_using_directives.g.cs new file mode 100644 index 000000000..ca595c931 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/class_with_using_directives.g.cs @@ -0,0 +1,34 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + using SimpleFirstLevelNamespace; + using SimpleQualifiedNamespace.Qualified; + using HelloLevelOne.HelloLevelTwo; + + internal partial class ClassWithUsingDirectives : AXSharp.Connector.IPlain + { + public ClassWithUsingDirectives() + { + } + + using SimpleFirstLevelNamespace ; using SimpleQualifiedNamespace . Qualified ; using HelloLevelOne . HelloLevelTwo ; + +} + +namespace SimpleFirstLevelNamespace +{ +} + +namespace SimpleQualifiedNamespace.Qualified +{ +} + +namespace HelloLevelOne +{ + namespace HelloLevelTwo + { + } +} } diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/compileromitsattribute.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/compileromitsattribute.g.cs new file mode 100644 index 000000000..2e89b94c3 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/compileromitsattribute.g.cs @@ -0,0 +1,109 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace CompilerOmmits + { + public partial class ClassWithArrays : AXSharp.Connector.IPlain + { + public ClassWithArrays() + { + } + + public CompilerOmmits.Complex _must_be_omitted_in_onliner { get; set; } = new CompilerOmmits.Complex(); + public Byte[] _primitive { get; set; } = new Byte[11]; + } + + public partial class Complex : AXSharp.Connector.IPlain + { + public Complex() + { + } + + public string HelloString { get; set; } = string.Empty; + public UInt64 Id { get; set; } + } + } + + namespace Enums + { + public partial class ClassWithEnums : AXSharp.Connector.IPlain + { + public ClassWithEnums() + { + } + + public global::Enums.Colors colors { get; set; } + public String NamedValuesColors { get; set; } + } + } + + namespace misc + { + public partial class VariousMembers : AXSharp.Connector.IPlain + { + public VariousMembers() + { + } + + public misc.SomeClass _SomeClass { get; set; } = new misc.SomeClass(); + public misc.Motor _Motor { get; set; } = new misc.Motor(); + } + + public partial class SomeClass : AXSharp.Connector.IPlain + { + public SomeClass() + { + } + + public string SomeClassVariable { get; set; } = string.Empty; + } + + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean isRunning { get; set; } + } + + public partial class Vehicle : AXSharp.Connector.IPlain + { + public Vehicle() + { + } + + public misc.Motor m { get; set; } = new misc.Motor(); + public Int16 displacement { get; set; } + } + } + + namespace UnknownArraysShouldNotBeTraspiled + { + public partial class ClassWithArrays : AXSharp.Connector.IPlain + { + public ClassWithArrays() + { +#pragma warning disable CS0612 + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_complexKnown, () => new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(), new[] { (0, 10) }); +#pragma warning restore CS0612 + } + + public UnknownArraysShouldNotBeTraspiled.Complex[] _complexKnown { get; set; } = new UnknownArraysShouldNotBeTraspiled.Complex[11]; + public Byte[] _primitive { get; set; } = new Byte[11]; + } + + public partial class Complex : AXSharp.Connector.IPlain + { + public Complex() + { + } + + public string HelloString { get; set; } = string.Empty; + public UInt64 Id { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/configuration.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/configuration.g.cs new file mode 100644 index 000000000..8a7a774e9 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/configuration.g.cs @@ -0,0 +1,61 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class ComplexForConfig : AXSharp.Connector.IPlain + { + public ComplexForConfig() + { + } + + public Boolean myBOOL { get; set; } + public Byte myBYTE { get; set; } + public UInt16 myWORD { get; set; } + public UInt32 myDWORD { get; set; } + public UInt64 myLWORD { get; set; } + public SByte mySINT { get; set; } + public Int16 myINT { get; set; } + public Int32 myDINT { get; set; } + public Int64 myLINT { get; set; } + public Byte myUSINT { get; set; } + public UInt16 myUINT { get; set; } + public UInt32 myUDINT { get; set; } + public UInt64 myULINT { get; set; } + public Single myREAL { get; set; } + public Double myLREAL { get; set; } + public TimeSpan myTIME { get; set; } = default(TimeSpan); + public TimeSpan myLTIME { get; set; } = default(TimeSpan); + public DateOnly myDATE { get; set; } = new DateOnly(1990, 1, 1); + public DateOnly myLDATE { get; set; } = new DateOnly(1990, 1, 1); + public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); + public TimeSpan myLTIME_OF_DAY { get; set; } = default(TimeSpan); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1990, 1, 1); + public DateTime myLDATE_AND_TIME { get; set; } = new DateTime(1990, 1, 1); + public Char myCHAR { get; set; } + public Char myWCHAR { get; set; } + public string mySTRING { get; set; } = string.Empty; + public string myWSTRING { get; set; } = string.Empty; + public Motor myMotor { get; set; } = new Motor(); + } + + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean isRunning { get; set; } + } + + public partial class Vehicle : AXSharp.Connector.IPlain + { + public Vehicle() + { + } + + public Motor m { get; set; } = new Motor(); + public Int16 displacement { get; set; } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/enum_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/enum_simple.g.cs new file mode 100644 index 000000000..e23d372b9 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/enum_simple.g.cs @@ -0,0 +1,7 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_unsupported.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_unsupported.g.cs new file mode 100644 index 000000000..56cacaa1e --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_unsupported.g.cs @@ -0,0 +1,10 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Unsupported + { + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_usings.g.cs new file mode 100644 index 000000000..1fecb9332 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/file_with_usings.g.cs @@ -0,0 +1,52 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; +using Pocos.FileWithUsingsSimpleFirstLevelNamespace; +using Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified; +using Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo; + +namespace Pocos +{ + namespace FileWithUsingsSimpleFirstLevelNamespace + { + public partial class Hello : AXSharp.Connector.IPlain + { + public Hello() + { + } + } + } + + namespace FileWithUsingsSimpleQualifiedNamespace.Qualified + { + public partial class Hello : AXSharp.Connector.IPlain + { + public Hello() + { + } + } + } + + namespace FileWithUsingsHelloLevelOne + { + namespace FileWithUsingsHelloLevelTwo + { + public partial class Hello : AXSharp.Connector.IPlain + { + public Hello() + { + } + } + } + } + + namespace ExampleNamespace + { + public partial class Hello : AXSharp.Connector.IPlain + { + public Hello() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/generics.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/generics.g.cs new file mode 100644 index 000000000..3571cd31d --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/generics.g.cs @@ -0,0 +1,36 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace GenericsTests + { + public partial class Extender : AXSharp.Connector.IPlain + { + public Extender() + { + } + } + + public partial class SomeTypeToBeGeneric : AXSharp.Connector.IPlain + { + public SomeTypeToBeGeneric() + { + } + + public Boolean Boolean { get; set; } + public Int16 Cele { get; set; } + } + + public partial class Extendee2 : GenericsTests.Extender, AXSharp.Connector.IPlain + { + public Extendee2() : base() + { + } + + [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "Shared Header")] + public GenericsTests.SomeTypeToBeGeneric SomeData { get; set; } = new GenericsTests.SomeTypeToBeGeneric(); + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonce.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonce.g.cs new file mode 100644 index 000000000..b1f0575ce --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonce.g.cs @@ -0,0 +1,31 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace makereadonce + { + public partial class MembersWithMakeReadOnce : AXSharp.Connector.IPlain + { + public MembersWithMakeReadOnce() + { + } + + public string makeReadOnceMember { get; set; } = string.Empty; + public string someOtherMember { get; set; } = string.Empty; + public makereadonce.ComplexMember makeReadComplexMember { get; set; } = new makereadonce.ComplexMember(); + public makereadonce.ComplexMember someotherComplexMember { get; set; } = new makereadonce.ComplexMember(); + } + + public partial class ComplexMember : AXSharp.Connector.IPlain + { + public ComplexMember() + { + } + + public string someMember { get; set; } = string.Empty; + public string someOtherMember { get; set; } = string.Empty; + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonly.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonly.g.cs new file mode 100644 index 000000000..ecafb34ff --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/makereadonly.g.cs @@ -0,0 +1,31 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace makereadonly + { + public partial class MembersWithMakeReadOnly : AXSharp.Connector.IPlain + { + public MembersWithMakeReadOnly() + { + } + + public string makeReadOnceMember { get; set; } = string.Empty; + public string someOtherMember { get; set; } = string.Empty; + public makereadonly.ComplexMember makeReadComplexMember { get; set; } = new makereadonly.ComplexMember(); + public makereadonly.ComplexMember someotherComplexMember { get; set; } = new makereadonly.ComplexMember(); + } + + public partial class ComplexMember : AXSharp.Connector.IPlain + { + public ComplexMember() + { + } + + public string someMember { get; set; } = string.Empty; + public string someOtherMember { get; set; } = string.Empty; + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/misc.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/misc.g.cs new file mode 100644 index 000000000..1eae7fcb0 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/misc.g.cs @@ -0,0 +1,86 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Enums + { + public partial class ClassWithEnums : AXSharp.Connector.IPlain + { + public ClassWithEnums() + { + } + + public global::Enums.Colors colors { get; set; } + public String NamedValuesColors { get; set; } + } + } + + namespace misc + { + public partial class VariousMembers : AXSharp.Connector.IPlain + { + public VariousMembers() + { + } + + public misc.SomeClass _SomeClass { get; set; } = new misc.SomeClass(); + public misc.Motor _Motor { get; set; } = new misc.Motor(); + } + + public partial class SomeClass : AXSharp.Connector.IPlain + { + public SomeClass() + { + } + + public string SomeClassVariable { get; set; } = string.Empty; + } + + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean isRunning { get; set; } + } + + public partial class Vehicle : AXSharp.Connector.IPlain + { + public Vehicle() + { + } + + public misc.Motor m { get; set; } = new misc.Motor(); + public Int16 displacement { get; set; } + } + } + + namespace UnknownArraysShouldNotBeTraspiled + { + public partial class ClassWithArrays : AXSharp.Connector.IPlain + { + public ClassWithArrays() + { +#pragma warning disable CS0612 + AXSharp.Connector.BuilderHelpers.Arrays.InstantiateArray(_complexKnown, () => new global::Pocos.UnknownArraysShouldNotBeTraspiled.Complex(), new[] { (0, 10) }); +#pragma warning restore CS0612 + } + + public UnknownArraysShouldNotBeTraspiled.Complex[] _complexKnown { get; set; } = new UnknownArraysShouldNotBeTraspiled.Complex[11]; + public Byte[] _primitive { get; set; } = new Byte[11]; + } + + public partial class Complex : AXSharp.Connector.IPlain + { + public Complex() + { + } + + public string HelloString { get; set; } = string.Empty; + public UInt64 Id { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/mixed_access.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/mixed_access.g.cs new file mode 100644 index 000000000..a7383fdf4 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/mixed_access.g.cs @@ -0,0 +1,75 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean Run { get; set; } + } + + public partial class struct1 : AXSharp.Connector.IPlain + { + public struct1() + { + } + + public struct2 s2 { get; set; } = new struct2(); + } + + public partial class struct2 : AXSharp.Connector.IPlain + { + public struct2() + { + } + + public struct3 s3 { get; set; } = new struct3(); + } + + public partial class struct3 : AXSharp.Connector.IPlain + { + public struct3() + { + } + + public struct4 s4 { get; set; } = new struct4(); + } + + public partial class struct4 : AXSharp.Connector.IPlain + { + public struct4() + { + } + + public Int16 s5 { get; set; } + } + + public partial class AbstractMotor : AXSharp.Connector.IPlain + { + public AbstractMotor() + { + } + + public Boolean Run { get; set; } + public Boolean ReverseDirection { get; set; } + } + + public partial class GenericMotor : AbstractMotor, AXSharp.Connector.IPlain + { + public GenericMotor() : base() + { + } + } + + public partial class SpecificMotorA : GenericMotor, AXSharp.Connector.IPlain + { + public SpecificMotorA() : base() + { + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/program.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/program.g.cs new file mode 100644 index 000000000..e23d372b9 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/program.g.cs @@ -0,0 +1,7 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/ref_to_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/ref_to_simple.g.cs new file mode 100644 index 000000000..22248e832 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/ref_to_simple.g.cs @@ -0,0 +1,25 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace RefToSimple + { + public partial class ref_to_simple : AXSharp.Connector.IPlain + { + public ref_to_simple() + { + } + } + + public partial class referenced : AXSharp.Connector.IPlain + { + public referenced() + { + } + + public Int16 b { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class.g.cs new file mode 100644 index 000000000..49d5fd250 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class.g.cs @@ -0,0 +1,13 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class simple_class : AXSharp.Connector.IPlain + { + public simple_class() + { + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class_within_namespace.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class_within_namespace.g.cs new file mode 100644 index 000000000..3cf279ae8 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/simple_empty_class_within_namespace.g.cs @@ -0,0 +1,16 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace sampleNamespace + { + public partial class simple_empty_class_within_namespace : AXSharp.Connector.IPlain + { + public simple_empty_class_within_namespace() + { + } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/struct_simple.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/struct_simple.g.cs new file mode 100644 index 000000000..0c0b4d7c5 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/struct_simple.g.cs @@ -0,0 +1,25 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean isRunning { get; set; } + } + + public partial class Vehicle : AXSharp.Connector.IPlain + { + public Vehicle() + { + } + + public Motor m { get; set; } = new Motor(); + public Int16 displacement { get; set; } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values.g.cs new file mode 100644 index 000000000..a5e6936b1 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values.g.cs @@ -0,0 +1,18 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace NamedValuesNamespace + { + public partial class using_type_named_values : AXSharp.Connector.IPlain + { + public using_type_named_values() + { + } + + public Int16 LColors { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values_literals.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values_literals.g.cs new file mode 100644 index 000000000..14b4df591 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_named_values_literals.g.cs @@ -0,0 +1,18 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Simatic.Ax.StateFramework + { + public partial class using_type_named_values : AXSharp.Connector.IPlain + { + public using_type_named_values() + { + } + + public UInt16 LColors { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_with_enum.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_with_enum.g.cs new file mode 100644 index 000000000..14b709141 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/type_with_enum.g.cs @@ -0,0 +1,26 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace Simatic.Ax.StateFramework + { + public partial interface IGuard + { + } + } + + namespace Simatic.Ax.StateFramework + { + public partial class CompareGuardLint : AXSharp.Connector.IPlain, IGuard + { + public CompareGuardLint() + { + } + + public Int64 CompareToValue { get; set; } + public global::Simatic.Ax.StateFramework.Condition Condition { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_name_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_name_attributes.g.cs new file mode 100644 index 000000000..2c9aba9fb --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_name_attributes.g.cs @@ -0,0 +1,37 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace TypeWithNameAttributes + { + public partial class Motor : AXSharp.Connector.IPlain + { + public Motor() + { + } + + public Boolean isRunning { get; set; } + } + + public partial class Vehicle : AXSharp.Connector.IPlain + { + public Vehicle() + { + } + + public TypeWithNameAttributes.Motor m { get; set; } = new TypeWithNameAttributes.Motor(); + public Int16 displacement { get; set; } + } + + public partial class NoAccessModifierClass : AXSharp.Connector.IPlain + { + public NoAccessModifierClass() + { + } + + public string SomeClassVariable { get; set; } = string.Empty; + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_property_attributes.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_property_attributes.g.cs new file mode 100644 index 000000000..85e0d82b0 --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/POCO/types_with_property_attributes.g.cs @@ -0,0 +1,20 @@ +using System; +using AXSharp.Abstractions.Presentation; +using AXSharp.Connector; + +namespace Pocos +{ + namespace TypesWithPropertyAttributes + { + [AXSharp.Connector.AddedPropertiesAttribute("Description", "Some added property name value")] + public partial class SomeAddedProperties : AXSharp.Connector.IPlain + { + public SomeAddedProperties() + { + } + + [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "Pocitadlo")] + public Int16 Counter { get; set; } + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/PlcResources.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/PlcResources.g.cs new file mode 100644 index 000000000..6c88600cc --- /dev/null +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/tia/.g/PlcResources.g.cs @@ -0,0 +1,26 @@ + +using System.Reflection; +using AXSharp.Connector.Localizations; + +namespace units +{ + public sealed class PlcTranslator : Translator + { + private static readonly PlcTranslator instance = new PlcTranslator(); + + public static PlcTranslator Instance + { + get + { + return instance; + } + } + + private PlcTranslator() + { + var defaultResourceType = Assembly.GetAssembly(typeof(units.PlcTranslator)) + .GetType("units.Resources.PlcStringResources"); + this.SetLocalizationResource(defaultResourceType); + } + } +} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/units.csproj b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/units.csproj deleted file mode 100644 index d8d4be903..000000000 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/units.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - enable - enable - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/app/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/actual/app/AXSharp.config.json index a761de8d2..1414fda43 100644 --- a/src/AXSharp.compiler/tests/integration/actual/app/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/actual/app/AXSharp.config.json @@ -1 +1 @@ -{"OutputProjectFolder":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"ProjectFile":"app.csproj"} \ No newline at end of file +{"OutputProjectFolder":"samples\\units\\ix\\tia","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"tia","ProjectFile":"app.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/ax/app.csproj b/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/ax/app.csproj new file mode 100644 index 000000000..735bd56d2 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/ax/app.csproj @@ -0,0 +1,26 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/tia/app.csproj b/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/tia/app.csproj new file mode 100644 index 000000000..d03b9608a --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/app/samples/units/ix/tia/app.csproj @@ -0,0 +1,26 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib1/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/actual/lib1/AXSharp.config.json index bd2469ecb..2e3707c38 100644 --- a/src/AXSharp.compiler/tests/integration/actual/lib1/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/actual/lib1/AXSharp.config.json @@ -1 +1 @@ -{"OutputProjectFolder":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"ProjectFile":"lib1.csproj"} \ No newline at end of file +{"OutputProjectFolder":"samples\\units\\ix\\tia","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"tia","ProjectFile":"lib1.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/ax/lib1.csproj b/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/ax/lib1.csproj new file mode 100644 index 000000000..9c311e3d9 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/ax/lib1.csproj @@ -0,0 +1,21 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/tia/lib1.csproj b/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/tia/lib1.csproj new file mode 100644 index 000000000..9c311e3d9 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/lib1/samples/units/ix/tia/lib1.csproj @@ -0,0 +1,21 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib2/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/actual/lib2/AXSharp.config.json index 5572803e9..d95071d21 100644 --- a/src/AXSharp.compiler/tests/integration/actual/lib2/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/actual/lib2/AXSharp.config.json @@ -1 +1 @@ -{"OutputProjectFolder":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"ProjectFile":"lib2.csproj"} \ No newline at end of file +{"OutputProjectFolder":"samples\\units\\ix\\tia","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"tia","ProjectFile":"lib2.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/ax/lib2.csproj b/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/ax/lib2.csproj new file mode 100644 index 000000000..9c311e3d9 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/ax/lib2.csproj @@ -0,0 +1,21 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/tia/lib2.csproj b/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/tia/lib2.csproj new file mode 100644 index 000000000..9c311e3d9 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/actual/lib2/samples/units/ix/tia/lib2.csproj @@ -0,0 +1,21 @@ + + + net9.0;net8.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs b/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs index 5d55a6805..50a8ff4f9 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs @@ -293,8 +293,8 @@ internal void HandleCommFailure(Exception exception, string description, ITwi } } - private const int MAX_READ_REQUEST_SEGMENT = (128 * 1024) - 628*2; - private const int MAX_WRITE_REQUEST_SEGMENT = (128 * 1024) - 628*2; + private const int MAX_READ_REQUEST_SEGMENT = (128 * 1024) - 628 * 2; + private const int MAX_WRITE_REQUEST_SEGMENT = (128 * 1024) - 628 * 2; private System.Diagnostics.Stopwatch stopwatch = new(); @@ -554,4 +554,22 @@ internal override async Task WriteBatchAsyncCyclic(IEnumerable p } public eTargetProjectPlatform TargetPlatform { get; } = eTargetProjectPlatform.SIMATICAX; + + /// + public override string TargetPlatformMoniker + { + get + { + switch(TargetPlatform) + { + case eTargetProjectPlatform.SIMATICAX: + return "ax"; + case eTargetProjectPlatform.TIAPORTAL: + return "tia"; + default: + return TargetPlatform.ToString(); + } + + } + } } diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs b/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs index 60c523250..92c3e09e2 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs @@ -485,4 +485,10 @@ internal void Subscribe(ITwinPrimitive primitive) { this.Subscribed[primitive.Symbol] = primitive; } + + /// + /// Target platform moniker. + /// + public abstract string TargetPlatformMoniker { get; } + } \ No newline at end of file diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/Dummy/DummyConnector.cs b/src/AXSharp.connectors/src/AXSharp.Connector/Dummy/DummyConnector.cs index 1e4de7bd9..f06cd7b4d 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/Dummy/DummyConnector.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/Dummy/DummyConnector.cs @@ -29,6 +29,8 @@ public override Connector BuildAndStart() } private volatile object _lock = new(); + /// + public override string TargetPlatformMoniker => "dummy"; private void RwCycle() { diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDate.cs b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDate.cs index 0d4417c03..f95e5c236 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDate.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDate.cs @@ -69,4 +69,21 @@ public OnlinerDate(ITwinObject parent, string readableTail, string symbolTail) /// Gets the min value for this instance. /// public override DateOnly InstanceMinValue => AttributeMinSet ? AttributeMinimum : MinValue; + + /// + /// Gets the max value for this instance depnending on target platform. + /// + /// New instance of DateOnly type with value respective of target platform + public DateOnly CreateDefaultValue() + { + switch(this.Parent.GetConnector().TargetPlatformMoniker) + { + case "tia": + return new DateOnly(1990, 01, 1); + case "ax": + return new DateOnly(1970, 01, 1); + default: + return new DateOnly(1970, 01, 1); + } + } } \ No newline at end of file diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDateTime.cs b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDateTime.cs index 12f76f53f..b73649618 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDateTime.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerDateTime.cs @@ -68,4 +68,22 @@ public OnlinerDateTime(ITwinObject parent, string readableTail, string symbolTai /// Gets the min value for this instance. /// public override DateTime InstanceMinValue => AttributeMinSet ? AttributeMinimum : MinValue; + + + /// + /// Gets the max value for this instance depnending on target platform. + /// + /// New instance of DateOnly type with value respective of target platform + public DateTime CreateDefaultValue() + { + switch (this.Parent.GetConnector().TargetPlatformMoniker) + { + case "tia": + return new DateTime(1990, 01, 1); + case "ax": + return new DateTime(1970, 01, 1); + default: + return new DateTime(1970, 01, 1); + } + } } \ No newline at end of file diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLDateTime.cs b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLDateTime.cs index da56e98a3..d6913d4e8 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLDateTime.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLDateTime.cs @@ -56,4 +56,21 @@ public OnlinerLDateTime(ITwinObject parent, string readableTail, string symbolTa /// Gets the min value for this instance. /// public override DateTime InstanceMinValue => AttributeMinSet ? AttributeMinimum : MinValue; + + /// + /// Gets the max value for this instance depnending on target platform. + /// + /// New instance of DateOnly type with value respective of target platform + public DateTime CreateDefaultValue() + { + switch (this.Parent.GetConnector().TargetPlatformMoniker) + { + case "tia": + return new DateTime(1990, 01, 1); + case "ax": + return new DateTime(1970, 01, 1); + default: + return new DateTime(1970, 01, 1); + } + } } \ No newline at end of file diff --git a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/AXSharp.ConnectorLegacyTests.csproj b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/AXSharp.ConnectorLegacyTests.csproj index 3924eab1c..104af1d67 100644 --- a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/AXSharp.ConnectorLegacyTests.csproj +++ b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/AXSharp.ConnectorLegacyTests.csproj @@ -8,9 +8,10 @@ - - - + + + + diff --git a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTest.cs b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTest.cs index a3ae79eed..8376ea521 100644 --- a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTest.cs +++ b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTest.cs @@ -12,6 +12,7 @@ namespace AXSharp.Connector.Onliners.Tests using System.Linq; using AXSharp.Connector.Tests; using AXSharp.Connector.ValueTypes; + using NSubstitute; public class OnlinerDateTest : OnlinerBaseTests { @@ -99,5 +100,16 @@ public override void CanSetAsyncTest() Assert.That(Onliner.GetAsync().Result, Is.EqualTo(expected)); } + + [Test] + public void CreateDefaultValue_ReturnsCorrectValueForTia() + { + // Act + var result = (Onliner as OnlinerDate).CreateDefaultValue(); + + // Assert + Assert.That(result, Is.EqualTo(new DateOnly(1970, 01, 01))); + } + } } \ No newline at end of file diff --git a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTime.cs b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTime.cs index e2aeb66cc..36cc5aa4d 100644 --- a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTime.cs +++ b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerDateTime.cs @@ -101,5 +101,15 @@ public override void CanSetAsyncTest() Assert.That(Onliner.GetAsync().Result, Is.EqualTo(expected)); } + + [Test] + public void CreateDefaultValue_ReturnsCorrectValueForTia() + { + // Act + var result = (Onliner as OnlinerDateTime).CreateDefaultValue(); + + // Assert + Assert.That(result, Is.EqualTo(new DateTime(1970, 01, 01))); + } } } \ No newline at end of file diff --git a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerLDateTime.cs b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerLDateTime.cs index 7b0fe6607..36d5f8fa8 100644 --- a/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerLDateTime.cs +++ b/src/AXSharp.connectors/tests/AXSharp.ConnectorLegacyTests/ValueTypes/OnlinerLDateTime.cs @@ -107,5 +107,15 @@ public override void CanSetAsyncTest() Assert.That(Onliner.GetAsync().Result, Is.EqualTo(expected)); } + + [Test] + public void CreateDefaultValue_ReturnsCorrectValueForTia() + { + // Act + var result = (Onliner as OnlinerLDateTime).CreateDefaultValue(); + + // Assert + Assert.That(result, Is.EqualTo(new DateTime(1970, 01, 01))); + } } } \ No newline at end of file diff --git a/src/AXSharp.connectors/tests/AXSharp.ConnectorTests/AXSharp.ConnectorTests/Connector/ConnectorTests.cs b/src/AXSharp.connectors/tests/AXSharp.ConnectorTests/AXSharp.ConnectorTests/Connector/ConnectorTests.cs index 0317d0c93..c264c6d5d 100644 --- a/src/AXSharp.connectors/tests/AXSharp.ConnectorTests/AXSharp.ConnectorTests/Connector/ConnectorTests.cs +++ b/src/AXSharp.connectors/tests/AXSharp.ConnectorTests/AXSharp.ConnectorTests/Connector/ConnectorTests.cs @@ -21,6 +21,8 @@ public class ConnectorTests { private class TestConnector : Connector { + public override string TargetPlatformMoniker => nameof(TestConnector); + public TestConnector(object[] parameters) : base(parameters) { } diff --git a/src/AXSharp.connectors/tests/ax-test-project/apax-lock.json b/src/AXSharp.connectors/tests/ax-test-project/apax-lock.json index 68811a489..c95280c22 100644 --- a/src/AXSharp.connectors/tests/ax-test-project/apax-lock.json +++ b/src/AXSharp.connectors/tests/ax-test-project/apax-lock.json @@ -37,7 +37,8 @@ "@ax/target-llvm": "7.1.87", "@ax/target-mc7plus": "7.1.87", "@ax/trace": "2.8.0" - } + }, + "deprecated": "This package version is no longer supported. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases#legal-conditions." }, "@ax/sld": { "name": "@ax/sld", @@ -193,7 +194,8 @@ "dependencies": { "@ax/stc-win-x64": "7.1.87", "@ax/stc-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm": { "name": "@ax/target-llvm", @@ -203,7 +205,8 @@ "dependencies": { "@ax/target-llvm-win-x64": "7.1.87", "@ax/target-llvm-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus": { "name": "@ax/target-mc7plus", @@ -213,7 +216,8 @@ "dependencies": { "@ax/target-mc7plus-win-x64": "7.1.87", "@ax/target-mc7plus-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/trace": { "name": "@ax/trace", @@ -522,7 +526,8 @@ ], "dependencies": { "@ax/st-docs": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/stc-linux-x64": { "name": "@ax/stc-linux-x64", @@ -537,7 +542,8 @@ ], "dependencies": { "@ax/st-docs": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm-win-x64": { "name": "@ax/target-llvm-win-x64", @@ -550,7 +556,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm-linux-x64": { "name": "@ax/target-llvm-linux-x64", @@ -563,7 +570,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus-win-x64": { "name": "@ax/target-mc7plus-win-x64", @@ -576,7 +584,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus-linux-x64": { "name": "@ax/target-mc7plus-linux-x64", @@ -589,7 +598,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/trace-win-x64": { "name": "@ax/trace-win-x64", @@ -617,6 +627,14 @@ ], "dependencies": {} }, + "@ax/st-docs": { + "name": "@ax/st-docs", + "version": "7.1.87", + "integrity": "sha512-J5BthD1BR0fu1dkqQFyW3yOByC14TxhG+b/NUl2zXkSqjnsAQQbNtdheZquZ225x0qkJAR8wRrBx9Kr3QdYg8w==", + "resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-7.1.87.tgz", + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" + }, "@ax/system-strings": { "name": "@ax/system-strings", "version": "7.1.47", @@ -679,13 +697,6 @@ ], "dependencies": {} }, - "@ax/st-docs": { - "name": "@ax/st-docs", - "version": "7.1.87", - "integrity": "sha512-J5BthD1BR0fu1dkqQFyW3yOByC14TxhG+b/NUl2zXkSqjnsAQQbNtdheZquZ225x0qkJAR8wRrBx9Kr3QdYg8w==", - "resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-7.1.87.tgz", - "dependencies": {} - }, "@ax/system-math": { "name": "@ax/system-math", "version": "7.1.47", diff --git a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/all_primitives.g.cs b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/all_primitives.g.cs index 57f353bb1..00a85f1c3 100644 --- a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/all_primitives.g.cs +++ b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/all_primitives.g.cs @@ -27,9 +27,9 @@ public all_primitives() public Double myLREAL { get; set; } public TimeSpan myTIME { get; set; } = default(TimeSpan); public TimeSpan myLTIME { get; set; } = default(TimeSpan); - public DateOnly myDATE { get; set; } = default(DateOnly); + public DateOnly myDATE { get; set; } = new DateOnly(1970, 1, 1); public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); - public DateTime myDATE_AND_TIME { get; set; } = default(DateTime); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); public string mySTRING { get; set; } = string.Empty; public string myWSTRING { get; set; } = string.Empty; } diff --git a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/border.g.cs b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/border.g.cs index d854bc5f9..4bb66b5a0 100644 --- a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/border.g.cs +++ b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/border.g.cs @@ -35,10 +35,10 @@ public border() public Boolean testBool { get; set; } [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE From PLC#>")] - public DateOnly TestDate { get; set; } = default(DateOnly); + public DateOnly TestDate { get; set; } = new DateOnly(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE_AND_TIME From PLC#>")] - public DateTime TestDateTime { get; set; } = default(DateTime); + public DateTime TestDateTime { get; set; } = new DateTime(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#TIME_OF_DAY From PLC#>")] public TimeSpan TestTimeOfDay { get; set; } = default(TimeSpan); diff --git a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/groupbox.g.cs b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/groupbox.g.cs index 9de086dbd..ace39716e 100644 --- a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/groupbox.g.cs +++ b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/groupbox.g.cs @@ -35,10 +35,10 @@ public groupbox() public Boolean testBool { get; set; } [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE From PLC#>")] - public DateOnly TestDate { get; set; } = default(DateOnly); + public DateOnly TestDate { get; set; } = new DateOnly(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE_AND_TIME From PLC#>")] - public DateTime TestDateTime { get; set; } = default(DateTime); + public DateTime TestDateTime { get; set; } = new DateTime(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#TIME_OF_DAY From PLC#>")] public TimeSpan TestTimeOfDay { get; set; } = default(TimeSpan); diff --git a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/test_primitive.g.cs b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/test_primitive.g.cs index 8330ff3da..986442579 100644 --- a/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/test_primitive.g.cs +++ b/src/sanbox/integration/ix-integration-plc/ix/.g/POCO/test/test_primitive.g.cs @@ -35,10 +35,10 @@ public test_primitive() public Boolean testBool { get; set; } [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE From PLC#>")] - public DateOnly TestDate { get; set; } = default(DateOnly); + public DateOnly TestDate { get; set; } = new DateOnly(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#DATE_AND_TIME From PLC#>")] - public DateTime TestDateTime { get; set; } = default(DateTime); + public DateTime TestDateTime { get; set; } = new DateTime(1970, 1, 1); [AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "<#TIME_OF_DAY From PLC#>")] public TimeSpan TestTimeOfDay { get; set; } = default(TimeSpan); diff --git a/src/tests.integrations/integrated/src/ax/apax-lock.json b/src/tests.integrations/integrated/src/ax/apax-lock.json index 62a06b765..86b666906 100644 --- a/src/tests.integrations/integrated/src/ax/apax-lock.json +++ b/src/tests.integrations/integrated/src/ax/apax-lock.json @@ -37,7 +37,8 @@ "@ax/target-llvm": "7.1.87", "@ax/target-mc7plus": "7.1.87", "@ax/trace": "2.8.0" - } + }, + "deprecated": "This package version is no longer supported. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases#legal-conditions." }, "@ax/sld": { "name": "@ax/sld", @@ -193,7 +194,8 @@ "dependencies": { "@ax/stc-win-x64": "7.1.87", "@ax/stc-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm": { "name": "@ax/target-llvm", @@ -203,7 +205,8 @@ "dependencies": { "@ax/target-llvm-win-x64": "7.1.87", "@ax/target-llvm-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus": { "name": "@ax/target-mc7plus", @@ -213,7 +216,8 @@ "dependencies": { "@ax/target-mc7plus-win-x64": "7.1.87", "@ax/target-mc7plus-linux-x64": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/trace": { "name": "@ax/trace", @@ -522,7 +526,8 @@ ], "dependencies": { "@ax/st-docs": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/stc-linux-x64": { "name": "@ax/stc-linux-x64", @@ -537,7 +542,8 @@ ], "dependencies": { "@ax/st-docs": "7.1.87" - } + }, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm-win-x64": { "name": "@ax/target-llvm-win-x64", @@ -550,7 +556,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-llvm-linux-x64": { "name": "@ax/target-llvm-linux-x64", @@ -563,7 +570,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus-win-x64": { "name": "@ax/target-mc7plus-win-x64", @@ -576,7 +584,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/target-mc7plus-linux-x64": { "name": "@ax/target-mc7plus-linux-x64", @@ -589,7 +598,8 @@ "cpu": [ "x64" ], - "dependencies": {} + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" }, "@ax/trace-win-x64": { "name": "@ax/trace-win-x64", @@ -617,13 +627,6 @@ ], "dependencies": {} }, - "@ax/st-docs": { - "name": "@ax/st-docs", - "version": "7.1.87", - "integrity": "sha512-J5BthD1BR0fu1dkqQFyW3yOByC14TxhG+b/NUl2zXkSqjnsAQQbNtdheZquZ225x0qkJAR8wRrBx9Kr3QdYg8w==", - "resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-7.1.87.tgz", - "dependencies": {} - }, "@ax/system-strings": { "name": "@ax/system-strings", "version": "7.1.47", @@ -686,6 +689,14 @@ ], "dependencies": {} }, + "@ax/st-docs": { + "name": "@ax/st-docs", + "version": "7.1.87", + "integrity": "sha512-J5BthD1BR0fu1dkqQFyW3yOByC14TxhG+b/NUl2zXkSqjnsAQQbNtdheZquZ225x0qkJAR8wRrBx9Kr3QdYg8w==", + "resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-7.1.87.tgz", + "dependencies": {}, + "deprecated": "This package version is no longer supported and will be deleted from the registry on January 17th. Please update to at least version 7.1.95. It is your responsibility to use supported versions. For more information, visit https://console.simatic-ax.siemens.io/docs/releases" + }, "@ax/system-math": { "name": "@ax/system-math", "version": "7.1.47", diff --git a/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/all_primitives.g.cs b/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/all_primitives.g.cs index 7b0058b73..2ec39e460 100644 --- a/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/all_primitives.g.cs +++ b/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/all_primitives.g.cs @@ -27,9 +27,9 @@ public all_primitives() public Double myLREAL { get; set; } public TimeSpan myTIME { get; set; } = default(TimeSpan); public TimeSpan myLTIME { get; set; } = default(TimeSpan); - public DateOnly myDATE { get; set; } = default(DateOnly); + public DateOnly myDATE { get; set; } = new DateOnly(1970, 1, 1); public TimeSpan myTIME_OF_DAY { get; set; } = default(TimeSpan); - public DateTime myDATE_AND_TIME { get; set; } = default(DateTime); + public DateTime myDATE_AND_TIME { get; set; } = new DateTime(1970, 1, 1); public string mySTRING { get; set; } = string.Empty; public string myWSTRING { get; set; } = string.Empty; public global::myEnum myEnum { get; set; } diff --git a/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/realmonster.g.cs b/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/realmonster.g.cs index 6d5fefac6..54265bfe5 100644 --- a/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/realmonster.g.cs +++ b/src/tests.integrations/integrated/src/integrated.twin/.g/POCO/dataswapping/realmonster.g.cs @@ -17,8 +17,8 @@ public RealMonsterBase() public string Description { get; set; } = string.Empty; public UInt64 Id { get; set; } - public DateOnly TestDate { get; set; } = default(DateOnly); - public DateTime TestDateTime { get; set; } = default(DateTime); + public DateOnly TestDate { get; set; } = new DateOnly(1970, 1, 1); + public DateTime TestDateTime { get; set; } = new DateTime(1970, 1, 1); public TimeSpan TestTimeSpan { get; set; } = default(TimeSpan); public Byte[] ArrayOfBytes { get; set; } = new Byte[4]; public RealMonsterData.DriveBaseNested[] ArrayOfDrives { get; set; } = new RealMonsterData.DriveBaseNested[4];