Search code examples
c#vb.netautomatic-properties

A C# to VB.Net conversion utility that handles Automatic properties correctly?


I hope this isn't considered a duplicate since it's more pointed than similar questions (I'm curious about a specific weakness in C# to VB.net conversion utilities).

I've been looking at using a tool like this .net code converter to convert a class library to VB since I'm the only one in my group comfortable with C#. The problem I've run into is that it doesn't generate proper VB for automatic properties. It creates empty get/set routines.

So this:

public string TransactionType { get; private set; }

Becomes this:

Public Property TransactionType() As String
    Get
    End Get
    Private Set(ByVal value As String)
    End Set
End Property

The tools linked here and here have similar issues - some create valid properties, but they don't respect the access level of the set routine.

Side question - If you were going to fix the converter on DeveloperFusion, would you have it return something like this?

Private _TransactionType As String
Public Property TransactionType() As String
    Get
        Return _TransactionType
    End Get
    Private Set(ByVal value As String)
        _TransactionType = value
    End Set
End Property

Solution

  • We've now updated the code generator to support this scenario. If you spot any others that we're not doing very well, please do drop me a line.