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#: Improve date literal conversion #213

Closed
GrahamTheCoder opened this issue Nov 19, 2018 · 0 comments
Closed

VB -> C#: Improve date literal conversion #213

GrahamTheCoder opened this issue Nov 19, 2018 · 0 comments
Labels
compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion

Comments

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Nov 19, 2018

In #159 I said

This will need to deal with inlining a const field as well as just constant literals.

I didn't actually implement this part so it will now leave you with a compile time error. Something like:

Input:

Public Class Test
    Const x As Date = #1990-1-1#
    Private Sub Y(ByVal opt As Date = x)
    End Sub
End Class

Erroneous output:

using System;

public class Test
{
    DateTime x = DateTime.Parse("1990-01-01");
    private void Y(DateTime opt = x)
    {
    }
}

Expected output:

using System;

public class Test
{
    private static DateTime x = DateTime.Parse("1990-01-01");
    private void Y([Optional, DateTimeConstant(123456789L/*1990-01-01*/)] DateTime opt)
    {
    }
}

Proposed work:

  • Inline the tick count when a const field is used as an optional parameter
  • Add a comment for what date it represents in the existing case and this case
  • Make const date fields into static fields
@GrahamTheCoder GrahamTheCoder added the VB -> C# Specific to VB -> C# conversion label Nov 19, 2018
@GrahamTheCoder GrahamTheCoder changed the title VB -> C~ VB -> C#: Improve date literal conversion Nov 19, 2018
@GrahamTheCoder GrahamTheCoder added the compilation error A bug where the converted output won't compile label Nov 19, 2018
@GrahamTheCoder GrahamTheCoder modified the milestone: When more users request Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

1 participant