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#: double > [decimal expression] doesn't include needed Conversions.ToDouble call around expression #617

Closed
jamesmanning opened this issue Aug 22, 2020 · 0 comments · Fixed by #621
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@jamesmanning
Copy link

Input code

Public Class Class1
    Public Sub Foo()
        Dim SomeDecimal As Decimal = 12.3
        Dim ACalc As Double = 32.1
        If ACalc > 60 / SomeDecimal Then
            Console.WriteLine("passed")
        End If
    End Sub
End Class

Erroneous output

    public class Class1
    {
        public void Foo()
        {
            decimal SomeDecimal = 12.3M;
            double ACalc = 32.1;
            if (ACalc > 60 / SomeDecimal)
            {
                Console.WriteLine("passed");
            }
        }
    }

Expected output

If the "60 / SomeDecimal" is extracted to a local var of type Decimal, the Conversions.ToDouble call around that local var happens, so AFAICT we can/should do the same around the expression that's of type decimal

    public class Class1
    {
        public void Foo()
        {
            decimal SomeDecimal = 12.3M;
            double ACalc = 32.1;
            if (ACalc > Conversions.ToDouble(60 / SomeDecimal))
            {
                Console.WriteLine("passed");
            }
        }
    }

Details

  • Product in use: codeconv command line built from current master (commit 04d3409 "Update README.md" from 1:45 pm Eastern today)
    Specifically, CodeConverter\CommandLine\CodeConv.NetFramework\bin\Debug\ICSharpCode.CodeConverter.CodeConv.NetFramework.exe
@jamesmanning jamesmanning added the VB -> C# Specific to VB -> C# conversion label Aug 22, 2020
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

Successfully merging a pull request may close this issue.

1 participant