Commit 1b5ac8e
Fix CS0206 when converting ReDim Preserve on a property
When `ReDim Preserve` is used on a property in VB.NET, the C# converter was generating `Array.Resize(ref Property, ...)` which causes CS0206 because properties cannot be passed as `ref` or `out`.
This change updates `MethodBodyExecutableStatementVisitor.cs` to detect when the target of `ReDim Preserve` is a property or member access. In such cases, it generates a temporary variable, assigns the property value to it, resizes the temporary variable using `ref`, and then assigns the temporary variable back to the property.
Example:
VB.NET:
```vb
Public Property NumArray1 As Integer()
...
ReDim Preserve NumArray1(4)
```
Converted C#:
```csharp
var argNumArray1 = NumArray1;
Array.Resize(ref argNumArray1, 5);
NumArray1 = argNumArray1;
```
This ensures valid C# code is generated.
Co-authored-by: GrahamTheCoder <2490482+GrahamTheCoder@users.noreply.github.com>1 parent 18f8528 commit 1b5ac8e
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
0 commit comments