RefactoringEssentials
RefactoringEssentials copied to clipboard
?: Expression bug
I have:
enum From
{
Bottom,
Top,
Left,
Right
}
void UpdateAdvanced(decimal wert, string nudname){
decimal h = 0;
if ((From)DGV.Rows[0].Cells[2].Value != From.Top) {
DGV.Rows[0].Cells[1].Value = h - wert;
}
else {
DGV.Rows[0].Cells[1].Value = wert;
}
}
and this is what I am getting after ?: conversion:
DGV.Rows[0].Cells[1].Value = (From)DGV.Rows[0].Cells[2].Value != From.Top ? (System.Object)h - wert : (object)wert;
I don't know where this "(System.Object)" or "(Object)" came from.
Well seems like ConvertIfStatementToConditionalTernaryExpressionCodeRefactoringProvider generates explicit cast expression if target and ternary operator types are not equal and does not check if impilicit conversion exists. Should be considered as bug.