Closed paul1956 closed 3 years ago
I thought I had not put that other bug :-D
@elGuille-info Another good catch, I missed the simple case when I tried to handle Tuple deconstruction. This is fixed in 5.0.1.17. Fixing the unneeded tempVar assignment is very difficult given the way the logic works and I am afraid other things will break.
No problem, as you say, it is better to leave that comment and that assignment, than to break it elsewhere ;-)
Only as something strange.
public void AlgoMas()
{
// falla
Resto = (Efectivo - Tarjeta).ToString("#,##0.00");
Resto = (Efectivo * Tarjeta).ToString("#,##0.00");
// ok
Resto = (Efectivo + Tarjeta).ToString("#,##0.00");
}
Adding there are no issue.
It's in the code the AddExpression check. I really don't know why, but... as a point ;-)
If TypeOf node.Parent Is CSS.MemberAccessExpressionSyntax OrElse TypeOf node.Parent Is CSS.ElementAccessExpressionSyntax Then
If node.Expression.IsKind(CS.SyntaxKind.AddExpression) Then
Return Factory.ParenthesizedExpression(openParenToken.WithConvertedTriviaFrom(node.OpenParenToken), expr, CloseParenT
End If
Guillermo
@elGuille-info don't understand the issue. Do you have a full example what is broken and what you expect?
public void AlgoMas()
{
// falla
Resto = (Efectivo - Tarjeta).ToString("#,##0.00");
Resto = (Efectivo * Tarjeta).ToString("#,##0.00");
// ok
Resto = (Efectivo + Tarjeta).ToString("#,##0.00");
}
is special cased due to concatenation but I can look to see if I can reuse that logic elsewhere. Below works but I agree it could be better.
Public Sub AlgoMas()
' TODO: Check, VB does not directly support MemberAccess off a Conditional If Expression
Dim tempVar = Efectivo - Tarjeta
Resto = tempVar.ToString("#,##0.00")
' TODO: Check, VB does not directly support MemberAccess off a Conditional If Expression
Dim tempVar1 = Efectivo * Tarjeta
Resto = tempVar1.ToString("#,##0.00")
' ok
Resto = (Efectivo + Tarjeta).ToString("#,##0.00")
End Sub
That the "temp" variable it is not created only when the "add" is used. But the names of the variables works fine.
You found where it needed to be fixed, I does special case the (). I have fixed -/ in 5.0.1.18. I might be able to delete the check for other operators but for now I would like to leave that in. Thanks again.
Fail to assign the right local variable:
Converts to:
But it uses different variables (declared and used). And I can assign the value directly despite what is stated in the comment:
Hope its helps.
Guillermo