@@ -766,20 +766,26 @@ private CasePatternSwitchLabelSyntax WrapInCasePatternSwitchLabelSyntax(VBSyntax
766766 patternMatch = ValidSyntaxFactory . VarPattern ( varName ) ;
767767 ExpressionSyntax csLeft = SyntaxFactory . IdentifierName ( varName ) , csRight = expression ;
768768 var caseTypeInfo = _semanticModel . GetTypeInfo ( vbCase ) ;
769- var vbEquality = CommonConversions . VisualBasicEqualityComparison ;
770- if ( vbEquality . GetObjectEqualityType ( typeInfo , caseTypeInfo ) == VisualBasicEqualityComparison . RequiredType . Object ) {
771- expression = vbEquality . GetFullExpressionForVbObjectComparison ( csLeft , csRight ) ;
772- } else {
769+ expression = EqualsAdjustedForStringComparison ( node , vbCase , typeInfo , csLeft , csRight , caseTypeInfo ) ;
770+ }
771+
772+ var colonToken = SyntaxFactory . Token ( SyntaxKind . ColonToken ) ;
773+ return SyntaxFactory . CasePatternSwitchLabel ( patternMatch , SyntaxFactory . WhenClause ( expression ) , colonToken ) ;
774+ }
775+
776+ private ExpressionSyntax EqualsAdjustedForStringComparison ( VBSyntax . SelectBlockSyntax node , VBSyntax . ExpressionSyntax vbCase , TypeInfo lhsTypeInfo , ExpressionSyntax csLeft , ExpressionSyntax csRight , TypeInfo rhsTypeInfo )
777+ {
778+ var vbEquality = CommonConversions . VisualBasicEqualityComparison ;
779+ switch ( vbEquality . GetObjectEqualityType ( lhsTypeInfo , rhsTypeInfo ) ) {
780+ case VisualBasicEqualityComparison . RequiredType . Object :
781+ return vbEquality . GetFullExpressionForVbObjectComparison ( csLeft , csRight ) ;
782+ case VisualBasicEqualityComparison . RequiredType . StringOnly :
773783 // We know lhs isn't null, because we always coalesce it in the switch expression
774784 ( csLeft , csRight ) = vbEquality
775- . AdjustForVbStringComparison ( node . SelectStatement . Expression , csLeft , typeInfo , true , vbCase , csRight , caseTypeInfo , false ) ;
776- expression = SyntaxFactory . BinaryExpression ( SyntaxKind . EqualsExpression , csLeft , csRight ) ;
777- }
785+ . AdjustForVbStringComparison ( node . SelectStatement . Expression , csLeft , lhsTypeInfo , true , vbCase , csRight , rhsTypeInfo , false ) ;
786+ break ;
778787 }
779-
780- var casePatternSwitchLabelSyntax = SyntaxFactory . CasePatternSwitchLabel ( patternMatch ,
781- SyntaxFactory . WhenClause ( expression ) , SyntaxFactory . Token ( SyntaxKind . ColonToken ) ) ;
782- return casePatternSwitchLabelSyntax ;
788+ return SyntaxFactory . BinaryExpression ( SyntaxKind . EqualsExpression , csLeft , csRight ) ;
783789 }
784790
785791 public override async Task < SyntaxList < StatementSyntax > > VisitWithBlock ( VBSyntax . WithBlockSyntax node )
0 commit comments