Skip to content

VB -> C#: Many Compiler Errors after Conversion #1205

@wfrx

Description

@wfrx

We have a giant solution of more than 1031 projects, 713 of which are VB.NET.
We want to convert all our code to C#, so we've tried converting a few projects with the DotNet Tool, but the result is barely usable.
It is of course to be expected that it doesn't work flawlessly and manual adjustments will be necessary afterwards, but most of the errors we encounter are in very basic parts of the code. It seems strange that these conversions would not be supported out of the box.

We are currently looking at different approaches to work around or fix these issues, but I would like to know if the problems we're encountering are to be expected or if they are due to the way our code/solution is structured. Because again, to me they seem mostly like basic VB.NET syntax that should be easily converted into the C# equivalent.

Using the online Converter: https://icsharpcode.github.io/CodeConverter/, it seems that these Problems do not occur.

The following problems make up most of the issues I have encountered so far:

VB.Net input code

'0. Missing Imports/using
Imports Company.Namespace
'1. Method without Parentheses
MyClass.MyMethod
'2. Wrong Case in VB
MyClass.myProperty
'3. Array Indexed Access
MyArray(key)
'4. Generic Types and Nullable Types
IEnumerable(Of Object)
List(Of Integer?)
'5 Optional Method Parameters
Public Sub MyMethod(para1 As Integer, <Out> ByRef Optional myPara As MyType = Nothing)

Erroneous output

//0. Missing Imports/using

//1. Method without Parentheses
MyClass.MyMethod;
//2. Wrong Case in VB
MyClass.myProperty;
//3. Array Indexed Access
MyArray(key);
//4. Generic Types and Nullable Types
IEnumerable;
List<int>;
//5. Optional Method Parameters
public void MyMethod(int para1, [Optional] [Out] ref MyType myPara)

Expected output

//0. Missing Imports/using
using Company.Namespace;
//1. Method without Parentheses
MyClass.MyMethod();
// 2. Wrong Case in VB
MyClass.MyProperty;
//3. Array Indexed Access
MyArray[key];
//4. Generic Types and Nullable Types
IEnumerable<object>;
List<int?>;
//5. Optional Method Parameters
public void MyMethod(int para1, out MyType myPara = null)

Details

  • Product in use: dotnet tool ICSharpCode.CodeConverter.CodeConv
  • Version in use: 9.2.7.792

Metadata

Metadata

Assignees

No one assigned

    Labels

    VB -> C#Specific to VB -> C# conversion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions