Skip to content

Commit 0271d6d

Browse files
authored
Merge pull request #478 from Inxton/477-bug-missing-support-exception-in-ixc-when-array-init-is-used
[BUG] Missing support exception in ixc when array as type declaration
2 parents d432b8c + 82ff85e commit 0271d6d

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/AXSharp.compiler/src/AXSharp.Compiler/Core/IxNodeVisitor.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,22 @@ public void Accept(IArrayRepetitionInitializerSyntax arrayRepetitionInitializerS
743743
void ISyntaxNodeVisitor<ICombinedThreeVisitor>.Accept(IArrayTypeDeclarationSyntax arrayTypeDeclarationSyntax,
744744
ICombinedThreeVisitor data)
745745
{
746-
throw new NotSupportedException();
746+
try
747+
{
748+
// Read Locations SourceText property using reflection.
749+
var locationType = arrayTypeDeclarationSyntax.Location.GetType();
750+
var sourceTextProperty = locationType.GetProperty("SourceText");
751+
var sourceText = sourceTextProperty?.GetValue(arrayTypeDeclarationSyntax.Location);
752+
var sourceTextType = sourceText?.GetType();
753+
var fileNameProperty = sourceTextType?.GetProperty("Filename") ?? sourceTextType?.GetProperty("FileName");
754+
var fileName = fileNameProperty?.GetValue(sourceText) as string ?? "unknown file";
755+
756+
Log.Logger.Warning($"Array types as declared in '{fileName}' are not supported at this time.");
757+
}
758+
catch (Exception)
759+
{
760+
Log.Logger.Warning($"Array types as declared in 'an unknown location' are not supported at this time.");
761+
}
747762
}
748763

749764
void ISyntaxNodeVisitor<ICombinedThreeVisitor>.Accept(IAsmStatementSyntax asmStatementSyntax,

src/AXSharp.compiler/src/ixc/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"axopen-traversal": {
4141
"commandName": "Project",
4242
"commandLineArgs": "--verbosity Information",
43-
"workingDirectory": "C:\\W\\Develop\\gh\\inxton\\simatic-ax\\axopen.templates\\axopen\\src\\traversals\\apax\\"
43+
"workingDirectory": "c:\\W\\Develop\\gh\\inxton\\simatic-ax\\axopen-1\\AXOpen\\src\\traversals\\apax\\"
4444
},
4545
"axopen-core": {
4646
"commandName": "Project",

src/AXSharp.compiler/tests/AXSharp.CompilerTests/Core/IxNodeVisitorTestsSemantics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ public void CanCallAcceptForISyntaxNodeVisitor_ICombinedThreeVisitor_WithArrayTy
921921
var data = new Mock<ICombinedThreeVisitor>().Object;
922922

923923
// Act
924-
Assert.Throws<NotSupportedException>(() => ((ISyntaxNodeVisitor<ICombinedThreeVisitor>)_testClass).Accept(arrayTypeDeclarationSyntax, data));
924+
((ISyntaxNodeVisitor<ICombinedThreeVisitor>)_testClass).Accept(arrayTypeDeclarationSyntax, data);
925925

926926
// Assert
927927

0 commit comments

Comments
 (0)