diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7ae9c18a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..89030da0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,29 @@ +# Default: treat as text, normalize to LF in the repository +* text=auto eol=lf + +# Typical source files (explicit, but the default already covers these) +*.c text eol=lf +*.cpp text eol=lf +*.h text eol=lf +*.py text eol=lf +*.js text eol=lf +*.ts text eol=lf +*.sh text eol=lf +*.yaml text eol=lf +*.yml text eol=lf +*.json text eol=lf +*.css text eol=lf +*.cs text eol=lf + + +# Windows-native scripts that often *must* be CRLF in the working tree +# (repo still stores LF; checkout converts to CRLF) +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=lf + +# Binary files (never touch line endings) +*.png -text +*.jpg -text +*.zip -text +*.pdf -text \ No newline at end of file diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/CsFormatting.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/CsFormatting.cs index 6a974744..ae8dfb37 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/CsFormatting.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/CsFormatting.cs @@ -14,6 +14,6 @@ internal static class CsFormatting { public static string FormatCode(this string code) { - return CSharpSyntaxTree.ParseText(code).GetRoot().NormalizeWhitespace().SyntaxTree.GetText().ToString(); + return CSharpSyntaxTree.ParseText(code).GetRoot().NormalizeWhitespace(eol:"\n").SyntaxTree.GetText().ToString(); } } \ No newline at end of file diff --git a/src/AXSharp.compiler/src/ixc/Properties/launchSettings.json b/src/AXSharp.compiler/src/ixc/Properties/launchSettings.json index 594fce4a..aec971df 100644 --- a/src/AXSharp.compiler/src/ixc/Properties/launchSettings.json +++ b/src/AXSharp.compiler/src/ixc/Properties/launchSettings.json @@ -69,6 +69,10 @@ "axopen-traversal-in-tepmplates": { "commandName": "Project", "workingDirectory": "C:\\W\\Develop\\gh\\inxton\\simatic-ax\\axopen.templates\\axopen\\src\\traversals\\apax" + }, + "ixc_data": { + "commandName": "Project", + "workingDirectory": "D:\\github\\Inxton\\axopen\\src\\data\\tests\\AXOpen.Data.Tests_L1\\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 240cb14e..a9439f41 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/Cs/CsSourceBuilderTests.cs @@ -1,4 +1,4 @@ -// AXSharp.Compiler.CsTests +// 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. @@ -352,4 +352,4 @@ public string GetMethodName() var name = method.Name; return name; } -} \ No newline at end of file +} diff --git a/src/AXSharp.compiler/tests/integration/expected/app/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/expected/app/AXSharp.config.json index a761de8d..d6a2db64 100644 --- a/src/AXSharp.compiler/tests/integration/expected/app/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/expected/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":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"ax","ProjectFile":"app.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/meta.json b/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/meta.json deleted file mode 100644 index 752bccfe..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/meta.json +++ /dev/null @@ -1 +0,0 @@ -["NAMESPACE lib1\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE","NAMESPACE lib2\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE"] \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/sourceinfo.json b/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/sourceinfo.json deleted file mode 100644 index 424fcce0..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/app/ix/.meta/sourceinfo.json +++ /dev/null @@ -1 +0,0 @@ -{"ax-source":"../app"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/ax/app.csproj b/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/ax/app.csproj new file mode 100644 index 00000000..93d7b60f --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/ax/app.csproj @@ -0,0 +1,26 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/tia/app.csproj b/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/tia/app.csproj new file mode 100644 index 00000000..0bb09564 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/app/samples/units/ix/tia/app.csproj @@ -0,0 +1,26 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/build.ps1 b/src/AXSharp.compiler/tests/integration/expected/build.ps1 index 48b220a9..90f9c978 100644 --- a/src/AXSharp.compiler/tests/integration/expected/build.ps1 +++ b/src/AXSharp.compiler/tests/integration/expected/build.ps1 @@ -1,14 +1,15 @@ cd lib1 -dotnet run --project ..\..\..\src\ixc\AXSharp.ixc.csproj --framework net7.0 +dotnet run --project ..\..\..\..\src\ixc\AXSharp.ixc.csproj --framework net10.0 dotnet build ./ix/lib1.csproj cd .. cd lib2 -dotnet run --project ..\..\..\src\ixc\AXSharp.ixc.csproj --framework net7.0 +dotnet run --project ..\..\..\..\src\ixc\AXSharp.ixc.csproj --framework net10.0 dotnet build ./ix/lib2.csproj cd .. cd app -dotnet run --project ..\..\..\..\src\ixc\AXSharp.ixc.csproj --framework net7.0 +dotnet run --project ..\..\..\..\src\ixc\AXSharp.ixc.csproj --framework net10.0 dotnet build ./ix/app.csproj -cd .. \ No newline at end of file +cd .. + diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/expected/lib1/AXSharp.config.json index bd2469ec..e3f36078 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib1/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/expected/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":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"ax","ProjectFile":"lib1.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/Onliners/library.g.cs b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/Onliners/library.g.cs index 0c38c998..502c8cd8 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/Onliners/library.g.cs +++ b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/Onliners/library.g.cs @@ -29,15 +29,15 @@ public MyClass(AXSharp.Connector.ITwinObject parent, string readableTail, string PostConstruct(parent, readableTail, symbolTail); } - public async virtual Task OnlineToPlain() + public async virtual Task OnlineToPlain(eAccessPriority priority = eAccessPriority.Normal) { - return await (dynamic)this.OnlineToPlainAsync(); + return await (dynamic)this.OnlineToPlainAsync(priority); } - public async Task OnlineToPlainAsync() + public async Task OnlineToPlainAsync(eAccessPriority priority = eAccessPriority.Normal) { global::Pocos.lib1.MyClass plain = new global::Pocos.lib1.MyClass(); - await this.ReadAsync(); + await this.ReadAsync(priority); plain.MyString = MyString.LastValue; plain.MyInt = MyInt.LastValue; return plain; @@ -62,12 +62,12 @@ public async virtual Task OnlineToPlain() return plain; } - public async virtual Task PlainToOnline(T plain) + public async virtual Task PlainToOnline(T plain, eAccessPriority priority = eAccessPriority.Normal) { - await this.PlainToOnlineAsync((dynamic)plain); + await this.PlainToOnlineAsync((dynamic)plain, priority); } - public async Task> PlainToOnlineAsync(global::Pocos.lib1.MyClass plain) + public async Task> PlainToOnlineAsync(global::Pocos.lib1.MyClass plain, eAccessPriority priority = eAccessPriority.Normal) { #pragma warning disable CS0612 MyString.LethargicWrite(plain.MyString); @@ -75,7 +75,7 @@ public async Task> PlainToOnlineAsync(global::Pocos. #pragma warning disable CS0612 MyInt.LethargicWrite(plain.MyInt); #pragma warning restore CS0612 - return await this.WriteAsync(); + return await this.WriteAsync(priority); } [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] @@ -218,6 +218,11 @@ public AXSharp.Connector.ITwinObject GetParent() public System.String GetAttributeName(System.Globalization.CultureInfo culture) { + if (string.IsNullOrEmpty(_attributeName)) + { + return SymbolTail; + } + return this.Translate(_attributeName, culture).Interpolate(this); } diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/PlcResources.g.cs b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/PlcResources.g.cs index e09a1207..11ebf3de 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/PlcResources.g.cs +++ b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.g/PlcResources.g.cs @@ -18,9 +18,9 @@ public static PlcTranslator Instance private PlcTranslator() { - var defaultResourceType = Assembly.GetAssembly(typeof(lib1.PlcTranslator)) - .GetType("lib1.Resources.PlcStringResources"); - this.SetLocalizationResource(defaultResourceType); + var assembly = Assembly.GetAssembly(typeof(lib1.PlcTranslator)); + var resource = assembly.GetType("lib1.Resources.PlcStringResources"); + this.SetLocalizationResource(resource, assembly); } } } \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/meta.json b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/meta.json deleted file mode 100644 index 66fc8850..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/meta.json +++ /dev/null @@ -1 +0,0 @@ -["NAMESPACE lib1\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE",""] \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/sourceinfo.json b/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/sourceinfo.json deleted file mode 100644 index 8d95ff60..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/lib1/ix/.meta/sourceinfo.json +++ /dev/null @@ -1 +0,0 @@ -{"ax-source":"../lib1"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/ax/lib1.csproj b/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/ax/lib1.csproj new file mode 100644 index 00000000..2e2ada78 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/ax/lib1.csproj @@ -0,0 +1,21 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/tia/lib1.csproj b/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/tia/lib1.csproj new file mode 100644 index 00000000..2e2ada78 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/lib1/samples/units/ix/tia/lib1.csproj @@ -0,0 +1,21 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/AXSharp.config.json b/src/AXSharp.compiler/tests/integration/expected/lib2/AXSharp.config.json index 5572803e..d871745d 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib2/AXSharp.config.json +++ b/src/AXSharp.compiler/tests/integration/expected/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":"ix","UseBase":false,"NoDependencyUpdate":false,"IgnoreS7Pragmas":false,"SkipDependencyCompilation":false,"TargetPlatfromMoniker":"ax","ProjectFile":"lib2.csproj"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/Onliners/library.g.cs b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/Onliners/library.g.cs index ea3a87b3..d22b70dc 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/Onliners/library.g.cs +++ b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/Onliners/library.g.cs @@ -29,15 +29,15 @@ public MyClass(AXSharp.Connector.ITwinObject parent, string readableTail, string PostConstruct(parent, readableTail, symbolTail); } - public async virtual Task OnlineToPlain() + public async virtual Task OnlineToPlain(eAccessPriority priority = eAccessPriority.Normal) { - return await (dynamic)this.OnlineToPlainAsync(); + return await (dynamic)this.OnlineToPlainAsync(priority); } - public async Task OnlineToPlainAsync() + public async Task OnlineToPlainAsync(eAccessPriority priority = eAccessPriority.Normal) { global::Pocos.lib2.MyClass plain = new global::Pocos.lib2.MyClass(); - await this.ReadAsync(); + await this.ReadAsync(priority); plain.MyString = MyString.LastValue; plain.MyInt = MyInt.LastValue; return plain; @@ -62,12 +62,12 @@ public async virtual Task OnlineToPlain() return plain; } - public async virtual Task PlainToOnline(T plain) + public async virtual Task PlainToOnline(T plain, eAccessPriority priority = eAccessPriority.Normal) { - await this.PlainToOnlineAsync((dynamic)plain); + await this.PlainToOnlineAsync((dynamic)plain, priority); } - public async Task> PlainToOnlineAsync(global::Pocos.lib2.MyClass plain) + public async Task> PlainToOnlineAsync(global::Pocos.lib2.MyClass plain, eAccessPriority priority = eAccessPriority.Normal) { #pragma warning disable CS0612 MyString.LethargicWrite(plain.MyString); @@ -75,7 +75,7 @@ public async Task> PlainToOnlineAsync(global::Pocos. #pragma warning disable CS0612 MyInt.LethargicWrite(plain.MyInt); #pragma warning restore CS0612 - return await this.WriteAsync(); + return await this.WriteAsync(priority); } [Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")] @@ -218,6 +218,11 @@ public AXSharp.Connector.ITwinObject GetParent() public System.String GetAttributeName(System.Globalization.CultureInfo culture) { + if (string.IsNullOrEmpty(_attributeName)) + { + return SymbolTail; + } + return this.Translate(_attributeName, culture).Interpolate(this); } diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/PlcResources.g.cs b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/PlcResources.g.cs index 7781a99f..c869b240 100644 --- a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/PlcResources.g.cs +++ b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.g/PlcResources.g.cs @@ -18,9 +18,9 @@ public static PlcTranslator Instance private PlcTranslator() { - var defaultResourceType = Assembly.GetAssembly(typeof(lib2.PlcTranslator)) - .GetType("lib2.Resources.PlcStringResources"); - this.SetLocalizationResource(defaultResourceType); + var assembly = Assembly.GetAssembly(typeof(lib2.PlcTranslator)); + var resource = assembly.GetType("lib2.Resources.PlcStringResources"); + this.SetLocalizationResource(resource, assembly); } } } \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/meta.json b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/meta.json deleted file mode 100644 index 3f1fd313..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/meta.json +++ /dev/null @@ -1 +0,0 @@ -["NAMESPACE lib2\n\n{S7.extern=ReadWrite}\nCLASS MyClass \nEND_CLASS\nEND_NAMESPACE",""] \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/sourceinfo.json b/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/sourceinfo.json deleted file mode 100644 index 70de007c..00000000 --- a/src/AXSharp.compiler/tests/integration/expected/lib2/ix/.meta/sourceinfo.json +++ /dev/null @@ -1 +0,0 @@ -{"ax-source":"../lib2"} \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/ax/lib2.csproj b/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/ax/lib2.csproj new file mode 100644 index 00000000..2e2ada78 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/ax/lib2.csproj @@ -0,0 +1,21 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/tia/lib2.csproj b/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/tia/lib2.csproj new file mode 100644 index 00000000..2e2ada78 --- /dev/null +++ b/src/AXSharp.compiler/tests/integration/expected/lib2/samples/units/ix/tia/lib2.csproj @@ -0,0 +1,21 @@ + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + \ No newline at end of file