Skip to content

Commit

Permalink
Merge pull request #345 from ix-ax/back-to-poco-prefixed-instead-of-p…
Browse files Browse the repository at this point in the history
…ostfixed

pocos namespaces are backed prefixed instead of postfixed
  • Loading branch information
PTKu authored Dec 2, 2024
2 parents d9e87ad + 13b62c8 commit b46bd6c
Show file tree
Hide file tree
Showing 81 changed files with 1,228 additions and 1,355 deletions.
41 changes: 28 additions & 13 deletions cake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,34 @@ public override void Run(BuildContext context)
}
if (context.BuildParameters.TestLevel >= 3)
{
context.UploadTestPlc(
Path.GetFullPath(Path.Combine(context.WorkDirName, "..//..//src//AXSharp.connectors//tests//ax-test-project//")),
Environment.GetEnvironmentVariable("AXTARGET"),
Environment.GetEnvironmentVariable("AXTARGETPLATFORMINPUT"));

context.RunTestsFromFilteredSolution(Path.Combine(context.ScrDir, "AXSharp-L3-tests_WebApi.slnf"));

context.UploadTestPlc(
Path.GetFullPath(Path.Combine(context.WorkDirName, "..//..//src//tests.integrations//integrated//src//ax")),
Environment.GetEnvironmentVariable("AXTARGET"),
Environment.GetEnvironmentVariable("AXTARGETPLATFORMINPUT"));

context.RunTestsFromFilteredSolution(Path.Combine(context.ScrDir, "AXSharp-L3-tests_Integration.slnf"));
// This must be run in a separate environment!
try
{
context.UploadTestPlc(
Path.GetFullPath(Path.Combine(context.WorkDirName, "..//..//src//AXSharp.connectors//tests//ax-test-project//")),
Environment.GetEnvironmentVariable("AXTARGET"),
Environment.GetEnvironmentVariable("AXTARGETPLATFORMINPUT"));

context.RunTestsFromFilteredSolution(Path.Combine(context.ScrDir, "AXSharp-L3-tests_WebApi.slnf"));
}
catch
{
System.Console.WriteLine("Some WebAPI tests failed. RUN IN APPROPRIATE EVNIRONMENT");
}

try
{
context.UploadTestPlc(
Path.GetFullPath(Path.Combine(context.WorkDirName, "..//..//src//tests.integrations//integrated//src//ax")),
Environment.GetEnvironmentVariable("AXTARGET"),
Environment.GetEnvironmentVariable("AXTARGETPLATFORMINPUT"));

context.RunTestsFromFilteredSolution(Path.Combine(context.ScrDir, "AXSharp-L3-tests_Integration.slnf"));
}
catch
{
System.Console.WriteLine("Some WebAPI tests failed. RUN IN APPROPRIATE EVNIRONMENT");
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public static string CreateGenericSwapperMethodFromPlainer(string methodName, st
/// <returns>Fully qualified poco name for given declarations</returns>
public static string GetFullyQualifiedPocoName(this IDeclaration declaration)
{
return declaration.ContainingNamespace.FullyQualifiedName == "$GLOBAL" ? $"global::Pocos.{declaration.Name}" : $"{declaration.ContainingNamespace.FullyQualifiedName}.Pocos.{declaration.Name}";
return declaration.ContainingNamespace.FullyQualifiedName == "$GLOBAL" ? $"global::Pocos.{declaration.Name}" : $"Pocos.{declaration.ContainingNamespace.FullyQualifiedName}.{declaration.Name}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public void CreateClassDeclaration(IClassDeclarationSyntax classDeclarationSynta
TypeCommAccessibility = eCommAccessibility.ReadOnly;
}


AddToSource($"namespace Pocos{{");

classDeclarationSyntax.UsingDirectives.ToList().ForEach(p => p.Visit(visitor, this));

var classDeclarations = this.Compilation.GetSemanticTree().Classes
Expand All @@ -82,7 +79,7 @@ public void CreateClassDeclaration(IClassDeclarationSyntax classDeclarationSynta
.Any(p => p.FullyQualifiedName == classDeclaration.ExtendedTypeAccesses.FirstOrDefault()?.Type.FullyQualifiedName);

if (isExtended)
AddToSource($" : {classDeclaration.ExtendedTypeAccesses.FirstOrDefault()?.Type.GetFullyQualifiedPocoName()}");
AddToSource($" : {classDeclaration.ExtendedTypeAccesses.FirstOrDefault()?.Type.FullyQualifiedName}");



Expand All @@ -101,8 +98,6 @@ public void CreateClassDeclaration(IClassDeclarationSyntax classDeclarationSynta
classDeclarationSyntax.UsingDirectives.ToList().ForEach(p => p.Visit(visitor, this));
classDeclaration.Fields.ToList().ForEach(p => p.Accept(visitor, this));
AddToSource("}");

AddToSource("}"); // Close namespace
}

/// <inheritdoc />
Expand Down Expand Up @@ -200,9 +195,11 @@ public void CreateFile(IFileSyntax fileSyntax, IxNodeVisitor visitor)
fileSyntax.UsingDirectives
.Where(p => this.Compilation.GetSemanticTree().Namespaces.Select(p => p.FullyQualifiedName).Contains(p.QualifiedIdentifierList.GetText())))
{
AddToSource($"using {fileSyntaxUsingDirective.QualifiedIdentifierList.GetText()}.Pocos;");
AddToSource($"using Pocos.{fileSyntaxUsingDirective.QualifiedIdentifierList.GetText()};");
}
AddToSource("namespace Pocos {");
fileSyntax.Declarations.ToList().ForEach(p => p.Visit(visitor, this));
AddToSource("}");
}

/// <inheritdoc />
Expand All @@ -212,19 +209,9 @@ public void CreateConfigDeclaration(IConfigDeclarationSyntax configDeclarationSy
{
TypeCommAccessibility = eCommAccessibility.None;

if (configurationDeclaration.ContainingNamespace.FullyQualifiedName != "$GLOBAL")
{
AddToSource($"namespace {configurationDeclaration.ContainingNamespace.FullyQualifiedName}.Pocos{{");
}
else
{
AddToSource($"namespace Pocos{{");
}

AddToSource($"public partial class {Project.TargetProject.ProjectRootNamespace}TwinController{{");
configurationDeclaration.Variables.ToList().ForEach(p => p.Accept(visitor, this));
AddToSource("}");
AddToSource("}");// closing namespace
}

/// <inheritdoc />
Expand Down Expand Up @@ -333,9 +320,7 @@ public void CreateStructuredType(IStructTypeDeclarationSyntax structTypeDeclarat
IxNodeVisitor visitor)
{
TypeCommAccessibility = structuredTypeDeclaration.GetCommAccessibility(this);

AddToSource($"namespace Pocos{{");


AddToSource(
$"{structuredTypeDeclaration.AccessModifier.Transform()}partial class {structTypeDeclarationSyntax.Name.Text} : AXSharp.Connector.IPlain");
AddToSource("{");
Expand All @@ -344,8 +329,6 @@ public void CreateStructuredType(IStructTypeDeclarationSyntax structTypeDeclarat

structuredTypeDeclaration.Fields.ToList().ForEach(p => p.Accept(visitor, this));
AddToSource("}");

AddToSource("}"); // namespace closing
}

/// <inheritdoc />
Expand All @@ -369,13 +352,13 @@ public void CreateScalarTypeDeclaration(IScalarTypeDeclaration scalarTypeDeclara
/// <inheritdoc />
public void CreateClassDeclaration(IClassDeclaration classDeclaration, IxNodeVisitor data)
{
AddToSource(classDeclaration.GetFullyQualifiedPocoName());
AddToSource(classDeclaration.GetQualifiedName());
}

/// <inheritdoc />
public void CreateInterfaceDeclaration(IInterfaceDeclaration interfaceDeclaration, IxNodeVisitor visitor)
{
AddToSource(interfaceDeclaration.GetFullyQualifiedPocoName());
AddToSource(interfaceDeclaration.GetQualifiedName());
}

/// <inheritdoc />
Expand Down Expand Up @@ -404,7 +387,7 @@ public void CreateStringTypeDeclaration(IStringTypeDeclaration stringTypeDeclara
public void CreateStructuredType(IStructuredTypeDeclaration structuredTypeDeclaration, IxNodeVisitor visitor)
{
structuredTypeDeclaration.Pragmas.ToList().ForEach(p => p.Accept(visitor, this));
AddToSource($"{structuredTypeDeclaration.GetFullyQualifiedPocoName()}");
AddToSource($"{structuredTypeDeclaration.GetQualifiedName()}");
}

/// <inheritdoc />
Expand Down
Loading

0 comments on commit b46bd6c

Please sign in to comment.