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#: Casting Object to Nullable<> shouldn't use Conversions.To() #904

Closed
Yozer opened this issue Jun 17, 2022 · 0 comments · Fixed by #905
Closed

VB -> C#: Casting Object to Nullable<> shouldn't use Conversions.To() #904

Yozer opened this issue Jun 17, 2022 · 0 comments · Fixed by #905
Assignees
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion

Comments

@Yozer
Copy link
Member

Yozer commented Jun 17, 2022

VB.Net input code

Private Function Test(input as Object) As Integer?
        Return CType(input, Integer?)
End Function
Private Function Test(input as Object) As Integer
        Return CType(input, Integer)
End Function

Erroneous output

private int? Test(object input) => Conversions.ToInteger(input);
private int Test(object input) => Conversions.ToInteger(input);

Expected output

private int? Test(object input) => (int?)input;
private int Test(object input) => Conversions.ToInteger(input);

Sharplab.io

Details

  • Product in use: e.g. codeconverter.icsharpcode.net / VS extension / both
  • Version in use: e.g. 5.6.3 or a commit hash (if it's a 3rd party tool using this library, try one of the above): latest
  • Did you see it working in a previous version, which?
  • Any other relevant information to the issue, or your interest in contributing a fix.
@Yozer Yozer added output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion labels Jun 17, 2022
@Yozer Yozer self-assigned this Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant