Skip to content

Commit bc3a286

Browse files
Deal with array type symbols - fixes #559
1 parent 21456bc commit bc3a286

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,6 @@ dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:non
146146

147147
# RCS1123: Add parentheses according to operator precedence.
148148
dotnet_diagnostic.RCS1123.severity = none
149+
150+
# Default severity for analyzer diagnostics with category 'Performance' - turn this up to warn when looking for performance issues
151+
dotnet_analyzer_diagnostic.category-Performance.severity = suggestion

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
99

1010

1111
### VB -> C#
12-
12+
* Improve multi-declaration field conversion for arrrays - [#559](https://github.com/icsharpcode/CodeConverter/issues/559)
1313

1414
### C# -> VB
1515

CodeConverter/Util/TypeExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public static IEnumerable<INamedTypeSymbol> GetAllBaseClassesAndInterfaces(this
6666
/// <param name="symbol">Symbol.</param>
6767
public static string GetFullMetadataName(this ITypeSymbol symbol)
6868
{
69+
if (symbol is IArrayTypeSymbol ats) {
70+
return GetFullMetadataName(ats.ElementType) + "[" + Enumerable.Repeat(',', ats.Rank - 1) + "]";
71+
}
6972
//This is for comaptibility with NR5 reflection name in case of generic types like T1, T2...
7073
var namedTypeSymbol = symbol as INamedTypeSymbol;
7174
return namedTypeSymbol != null ? GetFullMetadataName(namedTypeSymbol) : symbol.MetadataName;

Tests/CSharp/MemberTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ internal partial class TestClass
2424
}");
2525
}
2626

27+
[Fact]
28+
public async Task TestMultiArrayFieldAsync()
29+
{
30+
await TestConversionVisualBasicToCSharpAsync(
31+
@"Class TestClass
32+
Dim Parts(), Taxes(), Deposits()(), Prepaid()(), FromDate, ToDate As String
33+
End Class", @"
34+
internal partial class TestClass
35+
{
36+
private string[] Parts, Taxes;
37+
private string[][] Deposits, Prepaid;
38+
private string FromDate, ToDate;
39+
}");
40+
}
41+
2742
[Fact]
2843
public async Task TestConstantFieldInModuleAsync()
2944
{

0 commit comments

Comments
 (0)