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

C# -> VB: Simple assignment expression inside a constructor expression body converts to using CSharpImpl.__Assign. #1105

Open
RussellSmith2 opened this issue May 28, 2024 · 0 comments
Labels
C# -> VB Specific to C# -> VB conversion enhancement

Comments

@RussellSmith2
Copy link
Contributor

Input code

internal class NameGenerator
{
    private readonly Func<string, string> _getValidIdentifier;
	
    private NameGenerator(Func<string, string> getValidIdentifier) => _getValidIdentifier = getValidIdentifier;
}

Erroneous output

Friend Class NameGenerator
    Private ReadOnly _getValidIdentifier As Func(Of String, String)

    Private Sub New(getValidIdentifier As Func(Of String, String))
        CSharpImpl.__Assign(_getValidIdentifier, getValidIdentifier)
    End Sub

    Private Class CSharpImpl
        <Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
        Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
            target = value
            Return value
        End Function
    End Class
End Class

Expected output

Friend Class NameGenerator
    Private ReadOnly _getValidIdentifier As Func(Of String, String)

    Private Sub New(getValidIdentifier As Func(Of String, String))
      _getValidIdentifier = getValidIdentifier
    End Sub
End Class

Details

@RussellSmith2 RussellSmith2 added the C# -> VB Specific to C# -> VB conversion label May 28, 2024
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 enhancement
Projects
None yet
Development

No branches or pull requests

2 participants