CodeConverter
CodeConverter copied to clipboard
VB -> C#: Simple boolean eval function breaks on dynamic storage object
VB.Net input code
Public Function IsHybridApp() As Boolean
Return Application.Session("hybrid") IsNot Nothing AndAlso Application.Session("hybrid") = 1
End Function
Erroneous output
public static bool IsHybridApp()
{
return Conversions.ToBoolean((object)(Application.Session.hybrid is object) && Operators.ConditionalCompareObjectEqual(Application.Session.hybrid, 1, false));
}
Expected output
public static bool IsHybridApp()
{
return Application.Session.hybrid != null && Application.Session.hybrid == 1;
}
Details
CC 8.41
Application.Session definition is
//
// Summary:
// Provides a generic storage for session-based objects.
public static dynamic Session { get; }
Lots of dynamic related stuff will likely be solved with the same change, feel free to add more examples of you find them, but this one is definitely good for its simplicity
I think this is slightly improved in the recent release. It's still ugly but I think now runnable. I've added a test case for it