Found a bad translation

  • 13 years ago

    Great Tool, I wub UYes

    Found An incorrect translation.


        public class PropertyOrderPair : IComparable
            private int _order;
            private string _name;
            public string Name
                    return _name;

            public PropertyOrderPair(string name, int order)
                _order = order;
                _name = name;

            public int CompareTo(object obj)
                // Sort the pair objects by ordering by order value
                // Equal values get the same rank
                int otherOrder = ((PropertyOrderPair)obj)._order;
                if (otherOrder == _order)
                    // If order not specified, sort by name
                    string otherName = ((PropertyOrderPair)obj)._name;
                    return string.Compare(_name,otherName);
                else if (otherOrder > _order)
                    return -1;
                return 1;

     VB translation:

    1.     Public Class PropertyOrderPair
    2.         Implements IComparable
    3.         Private _order As Integer
    4.         Private _name As String
    5.         Public ReadOnly Property Name() As String
    6.             Get
    7.                 Return _name
    8.             End Get
    9.         End Property
    11.         Public Sub New(ByVal name As String, ByVal order As Integer)
    12.             _order = order
    13.             _name = name
    14.         End Sub
    16.         Public Function CompareTo(ByVal obj As Object) As Integer
    17.             '
    18.             ' Sort the pair objects by ordering by order value
    19.             ' Equal values get the same rank
    20.             '
    21.             Dim otherOrder As Integer = DirectCast(obj, PropertyOrderPair)._order
    22.             If otherOrder = _order Then
    23.                 '
    24.                 ' If order not specified, sort by name
    25.                 '
    26.                 Dim otherName As String = DirectCast(obj, PropertyOrderPair)._name
    27.                 Return String.Compare(_name, otherName)
    28. ElseIf otherOrder > _order Then
    29.                 Return -1
    30.             End If
    31.             Return 1
    32.         End Function
    33.     End Class

    What it should be:

    Line 19 should be:

    Public Overloads Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo


  • 13 years ago

    Hi! Thanks for the bug report. Unfortunately there's no way the code converter is ever going to be able to support that in general. At the moment it statically analyses the code by turning it into what is known as an abstract syntax tree... and it has no way of knowing from the C# code which methods are in fact implementations of that interface and whcih are not (as it has no definition of that interface...). That said, even if you gave it the definition of the interface, it's not smart enough to work that out yet!

    Ah well... 

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An idiot with a computer is a faster, better idiot” - Rich Julius