-
Notifications
You must be signed in to change notification settings - Fork 222
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
C# -> VB: Declaration patterns don't convert #222
Comments
The VB variable declaration gets generated twice when a Declaration Pattern is inside a Local Declaration Statement. Input codepublic async Task<IEnumerable<ExpressionSyntax>> ConvertArrayBounds(ArgumentListSyntax argumentListSyntax)
{
return await argumentListSyntax.Arguments.SelectAsync(a => {
VBSyntax.ExpressionSyntax upperBoundExpression = a is SimpleArgumentSyntax sas ? sas.Expression
: a is RangeArgumentSyntax ras ? ras.UpperBound
: throw new ArgumentOutOfRangeException(nameof(a), a, null);
return IncreaseArrayUpperBoundExpression(upperBoundExpression);
});
} Erroneous outputPublic Async Function ConvertArrayBounds(ByVal argumentListSyntax As ArgumentListSyntax) As Task(Of IEnumerable(Of ExpressionSyntax))
Dim sas As SimpleArgumentSyntax = Nothing, ras As RangeArgumentSyntax = Nothing
Return Await argumentListSyntax.Arguments.SelectAsync(Function(a)
Dim sas As SimpleArgumentSyntax = Nothing, ras As RangeArgumentSyntax = Nothing
Dim upperBoundExpression As VBSyntax.ExpressionSyntax = If(CSharpImpl.__Assign(sas, TryCast(a, SimpleArgumentSyntax)) IsNot Nothing, sas.Expression, If(CSharpImpl.__Assign(ras, TryCast(a, RangeArgumentSyntax)) IsNot Nothing, ras.UpperBound, CSharpImpl.__Throw(Of)(New ArgumentOutOfRangeException(NameOf(a), a, Nothing))))
Return IncreaseArrayUpperBoundExpression(upperBoundExpression)
End Function)
End Function Expected outputPublic Async Function ConvertArrayBounds(ByVal argumentListSyntax As ArgumentListSyntax) As Task(Of IEnumerable(Of ExpressionSyntax))
Return Await argumentListSyntax.Arguments.SelectAsync(Function(a)
Dim sas As SimpleArgumentSyntax = Nothing, ras As RangeArgumentSyntax = Nothing
Dim upperBoundExpression As VBSyntax.ExpressionSyntax = If(CSharpImpl.__Assign(sas, TryCast(a, SimpleArgumentSyntax)) IsNot Nothing, sas.Expression, If(CSharpImpl.__Assign(ras, TryCast(a, RangeArgumentSyntax)) IsNot Nothing, ras.UpperBound, CSharpImpl.__Throw(Of)(New ArgumentOutOfRangeException(NameOf(a), a, Nothing))))
Return IncreaseArrayUpperBoundExpression(upperBoundExpression)
End Function)
End Function Details
|
It looks like all future VB development will "focus on stability", so VB probably isn't getting the improved select case feature. Therefore I think we'll have to transform to an if-else chain as you mentioned. So probably best to fix the double-declaration bug, then write the code to generally transform select to a switch, and activate it when a declaration pattern appears in the case expression. |
Input code
Erroneous output
Details
Product in use: web converter
Version in use: 6.2.0.0
Right now it looks like this should convert to if else statements, though it looks like this feature may get added to VB.net in the future.
The text was updated successfully, but these errors were encountered: