CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

Conversion for FixedStatement not implemented

Open banyanno opened this issue 1 year ago • 3 comments

Input code

In unsafe context

public class CSharpClass
{
    public static void Main(){
        byte[] bytes = [1, 2, 3];
        fixed (byte* bufferPtr = bytes)
        {
            Console.WriteLine($"The address of the first array element: {(long)bufferPtr:X}.");
            Console.WriteLine($"The value of the first array element: {*bufferPtr}.");
        }
    }
}

Erroneous output

Public Class CSharpClass
    Public Shared Sub Main()

        If True Then
            Dim bytes As Byte() = _(1, 2, 3)
                        ''' Cannot convert FixedStatementSyntax, CONVERSION ERROR: Conversion for FixedStatement not implemented, please report this issue in 'fixed (byte* bufferPtr = by...' at character 91
''' 
''' 
''' Input:
'''     fixed (byte* bufferPtr = bytes)
'''     {
'''         Console.WriteLine($"The address of the first array element: {(long)bufferPtr:X}.");
'''         Console.WriteLine($"The value of the first array element: {*bufferPtr}.");
'''     }
''' 
''' 
        End If
    End Sub
End Class

Expected output

Imports System
Imports System.Runtime.InteropServices

Module Program
    Public Shared Sub Main()
        Dim bytes As Byte() = {1, 2, 3}
        
        Dim bufferHandle As GCHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned)
        Try
            Dim bufferPtr As IntPtr = bufferHandle.AddrOfPinnedObject()
            
            Console.WriteLine($"The address of the first array element: {bufferPtr.ToInt64():X}.")
            Console.WriteLine($"The value of the first array element: {Marshal.ReadByte(bufferPtr)}.")
        Finally
            bufferHandle.Free()
        End Try
    End Sub
End Module

Details

  • Product in use: e.g. icsharpcode.github.io/CodeConverter / VS extension / both
  • Version in use: e.g. 5.6.3 or a commit hash (if it's a 3rd party tool using this library, try one of the above)
  • Did you see it working in a previous version, which?
  • Any other relevant information to the issue, or your interest in contributing a fix.

banyanno avatar May 17 '24 10:05 banyanno

CONVERSION ERROR: Conversion for FixedStatement not implemented, please report this issue in 'fixed (byte* bufferPtr = bu...' at character 18915

banyanno avatar May 17 '24 10:05 banyanno

Please fill in the template correctly. It is unlikely that somebody is able to help you with so little information.

Sympatron avatar May 17 '24 12:05 Sympatron

I've added my best guess at an input and expected output. A real example would help, though there are currently no contributors interested in implementing C#->VB features.

GrahamTheCoder avatar Jul 16 '24 23:07 GrahamTheCoder