Skip to content

Commit 44a449d

Browse files
Fix and simplify
1 parent 2986360 commit 44a449d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

CodeConverter/CSharp/MethodBodyExecutableStatementVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public override async Task<SyntaxList<StatementSyntax>> VisitSelectBlock(VBSynta
671671
vbEquality.VbCoerceToNonNullString(vbExpr, csSwitchExpr, switchExprTypeInfo, true, s.Value, originalExpressionSyntax, caseTypeInfo, false).rhs != originalExpressionSyntax);
672672

673673
// CSharp requires an explicit cast from the base type (e.g. int) in most cases switching on an enum
674-
var csExpressionToUse = wrapForStringComparison || switchExprTypeInfo.ConvertedType?.IsEnumType() == false || caseTypeInfo.Type?.IsEnumType() == true ? originalExpressionSyntax : correctTypeExpressionSyntax.Expr;
674+
var csExpressionToUse = switchExprTypeInfo.ConvertedType?.IsEnumType() == true ^ caseTypeInfo.Type?.IsEnumType() == true ? correctTypeExpressionSyntax.Expr : originalExpressionSyntax;
675675

676676
var caseSwitchLabelSyntax = !wrapForStringComparison && correctTypeExpressionSyntax.IsConst && notAlreadyUsed
677677
? (SwitchLabelSyntax)SyntaxFactory.CaseSwitchLabel(csExpressionToUse)

0 commit comments

Comments
 (0)