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#: wrong modifier for optional out parameter #882

Closed
KunzeAndreas opened this issue Apr 24, 2022 · 0 comments · Fixed by #883
Closed

VB -> C#: wrong modifier for optional out parameter #882

KunzeAndreas opened this issue Apr 24, 2022 · 0 comments · Fixed by #883
Assignees
Labels
compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion

Comments

@KunzeAndreas
Copy link

KunzeAndreas commented Apr 24, 2022

VB.Net input code

Private Shared Sub OutParameterModifier()
    Dim a As Integer
    Dim b As Integer
    WithOutParam(a:=a, b:=b)
    Assert.That(a = 42)
    Assert.That(b = 23)

    WithOutParam(a:=a)
    Assert.That(a = 42)
End Sub

Private Shared Sub WithOutParam(<Out> ByRef a As Integer, <Out> Optional ByRef b As Integer = Nothing)
    a = 42
    b = 23
End Sub

Erroneous output

 private static void OutParameterModifier()
  {
      int a;
      int b;
      WithOutParam(a: out a, b: out b);
      Assert.That(a == 42);
      Assert.That(b == 23);

      int argb = 0;
      VbConverterTests.WithOutParam(a: out a, b: ref argb);
      Assert.That(a == 42);
  }

  private static void WithOutParam(out int a, [Optional, DefaultParameterValue(default(int))] out int b)
  {
      a = 42;
      b = 23;
  }

Expected output

 VbConverterTests.WithOutParam(a: out a, b: out argb);

Details

  • Product in use: VS extension
  • Version in use: 8.5.0.0
  • Did you see it working in a previous version, which? no
@KunzeAndreas KunzeAndreas added the VB -> C# Specific to VB -> C# conversion label Apr 24, 2022
@Yozer Yozer added the compilation error A bug where the converted output won't compile label Apr 26, 2022
@Yozer Yozer self-assigned this Apr 26, 2022
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

Successfully merging a pull request may close this issue.

2 participants