Skip to content

Commit d2d7e2e

Browse files
Split arrays with different ranks
Part of #544
1 parent a666da3 commit d2d7e2e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

CodeConverter/Util/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static IEnumerable<INamedTypeSymbol> GetAllBaseClassesAndInterfaces(this
6767
public static string GetFullMetadataName(this ITypeSymbol symbol)
6868
{
6969
if (symbol is IArrayTypeSymbol ats) {
70-
return GetFullMetadataName(ats.ElementType) + "[" + Enumerable.Repeat(',', ats.Rank - 1) + "]";
70+
return GetFullMetadataName(ats.ElementType) + "[" + new string(Enumerable.Repeat(',', ats.Rank - 1).ToArray()) + "]";
7171
}
7272
//This is for comaptibility with NR5 reflection name in case of generic types like T1, T2...
7373
var namedTypeSymbol = symbol as INamedTypeSymbol;

Tests/CSharp/StatementTests/StatementTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,29 @@ public static void Main()
11941194
}");
11951195
}
11961196

1197+
[Fact]
1198+
public async Task SplitArrayDeclarationsAsync()
1199+
{
1200+
await TestConversionVisualBasicToCSharpAsync($@"Imports System.Diagnostics
1201+
Imports System.Threading
1202+
1203+
Public Class AcmeClass
1204+
Public Shared Sub Main()
1205+
Dim i_Test, i_Tab(), bearb(,) As Integer
1206+
End Sub
1207+
End Class"
1208+
, @"
1209+
public partial class AcmeClass
1210+
{
1211+
public static void Main()
1212+
{
1213+
int i_Test;
1214+
int[] i_Tab;
1215+
int[,] bearb;
1216+
}
1217+
}");
1218+
}
1219+
11971220
[Fact]
11981221
public async Task DeclareStatementWithAttributesAsync()
11991222
{

0 commit comments

Comments
 (0)