Incorrect decompilation of VB.NET properties with parameters. #339

Closed
Viorel opened this Issue May 16, 2012 · 0 comments

Comments

Projects
None yet
2 participants

Viorel commented May 16, 2012

VB.NET allows properties with parameters. The next ‘Field’ is a property that takes one ‘index’ parameter:

Public Class Class1

    Public ReadOnly Property Field( index As Integer ) As String
        Get
            Return "MyTest" + index
        End Get
    End Property

End Class

The decompiled code looks incorrect in both of VB and C# languages.

In case of VB the decompiled code of the property is:

Public ReadOnly Property Field() As String
    Get
        Return"MyTest" + Conversions.ToString(index)
    End Get
End Property

You can see that ‘index’ does not appear as a parameter, which is incorrect.

In case of C#:

public string Field
{
    get
    {
        return "MyTest" + Conversions.ToString(index);
    }
}

Here the property was decompiled as a simple one that is allowed in C# and ‘index’ is undefined. Not sure how it should be decompiled correctly in C#.

The issue also occurs when the property has a setter.

But the decompiled code seems to look good if the property is declared ‘Default’, i.e. becomes “indexer”.

Observed in ILSpy version 2.0.0.1595.
See also Issue #108.

@siegfriedpammer siegfriedpammer modified the milestone: vNext Apr 25, 2016

@siegfriedpammer siegfriedpammer modified the milestone: vNext, 2.4 Jun 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment