Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion for FixedStatement not implemented #1101

Open
banyanno opened this issue May 17, 2024 · 3 comments
Open

Conversion for FixedStatement not implemented #1101

banyanno opened this issue May 17, 2024 · 3 comments
Labels
C# -> VB Specific to C# -> VB conversion

Comments

@banyanno
Copy link

banyanno commented May 17, 2024

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 banyanno added the C# -> VB Specific to C# -> VB conversion label May 17, 2024
@banyanno
Copy link
Author

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

@Sympatron
Copy link

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

@GrahamTheCoder GrahamTheCoder changed the title CONVERSION ERROR: Conversion for FixedStatement not implemented, please report this issue in 'fixed (byte* bufferPtr = bu...' at character 18915 CONVERSION ERROR: Conversion for FixedStatement not implemented, please report this issue in 'fixed (byte* bufferPtr = bu...' at character 23017C# -> VB: _Add a short description_ Conversion for FixedStatement not implemented Jul 16, 2024
@GrahamTheCoder
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# -> VB Specific to C# -> VB conversion
Projects
None yet
Development

No branches or pull requests

3 participants