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

VB -> C#: converter is adding "new" keyword to definition #504

Closed
DanPFW opened this issue Jan 16, 2020 · 1 comment
Closed

VB -> C#: converter is adding "new" keyword to definition #504

DanPFW opened this issue Jan 16, 2020 · 1 comment
Assignees
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@DanPFW
Copy link

DanPFW commented Jan 16, 2020

Input code

		Protected Overloads Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
			_sortDirection = hidSortDirection.Value
			_sortExpression = hidSortExpression.Value

			Using ds As New DataSet
				Try
					ds.Tables.Add(DirectCast(dsCompletePlayer.Select(DataSourceSelectArguments.Empty), DataView).ToTable())
					lvCompletePlayer.DataSource = ds
					lvCompletePlayer.DataBind()

				Catch ex As Exception

				End Try
			End Using
		End Sub

Erroneous output

If relevant, the incorrectly converted output, or an exception with stack trace.

Expected output

protected new void Page_Load(object sender, EventArgs e)
{
    _sortDirection = hidSortDirection.Value;
    _sortExpression = hidSortExpression.Value;

    using (var ds = new DataSet())
    {
        try
        {
            ds.Tables.Add(((DataView)dsCompletePlayer.Select(DataSourceSelectArguments.Empty)).ToTable());
            lvCompletePlayer.DataSource = ds;
            lvCompletePlayer.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
}

Details

  • converter is adding "new" to page_load definition.
@DanPFW DanPFW added the VB -> C# Specific to VB -> C# conversion label Jan 16, 2020
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Jan 17, 2020

Thanks, this is the root issue and an important test case for the cause of #463

My current understanding is:

  • The converter currently thinks the Overloads keyword converts to new.
  • C# only needs the new keyword when the signatures clash with something in the base type.
  • VB needs Overloads in some others cases, and allows it optionally in yet more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants