@@ -171,9 +171,15 @@ private async Task<ExpressionSyntax> ConvertToDecimalComparisonOperatorAsync(VBS
171171 return null ;
172172 }
173173
174- private async Task < ExpressionSyntax > ConvertToStringComparisonOperatorAsync ( VBSyntax . BinaryExpressionSyntax node )
174+ private async Task < ExpressionSyntax > ConvertToStringComparisonOperatorAsync ( VBSyntax . BinaryExpressionSyntax node , SyntaxKind expressionKind )
175175 {
176- return null ;
176+ var ( lhs , rhs ) = await AcceptSidesAsync ( node ) ;
177+ lhs = VisualBasicEqualityComparison . VbCoerceToString ( lhs , _semanticModel . GetTypeInfo ( node . Left ) ) ;
178+ rhs = VisualBasicEqualityComparison . VbCoerceToString ( rhs , _semanticModel . GetTypeInfo ( node . Right ) ) ;
179+ var member = new KnownMethod ( _compilerServices , _operators , "CompareString" ) ;
180+ var optionaCompareTextBoolLiteralExpression = _visualBasicEqualityComparison . OptionCompareTextCaseInsensitiveBoolExpression ;
181+ var comparedLhs = member . Invoke ( _visualBasicEqualityComparison . ExtraUsingDirectives , lhs , rhs , optionaCompareTextBoolLiteralExpression ) ;
182+ return SyntaxFactory . BinaryExpression ( expressionKind , comparedLhs , LiteralConversions . GetLiteralExpression ( 0 ) ) ;
177183 }
178184
179185 private async Task < ExpressionSyntax > ConvertToMethodAsync ( VBSyntax . BinaryExpressionSyntax node , KnownMethod member )
@@ -196,7 +202,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
196202 {
197203 var opKind = node . Kind ( ) ;
198204 var nodeType = _semanticModel . GetTypeInfo ( node ) . Type ;
199- var leftType = _semanticModel . GetTypeInfo ( node . Left ) . Type ;
205+ var leftType = _semanticModel . GetTypeInfo ( node . Left ) . ConvertedType ;
200206 switch ( opKind ) {
201207 case BinaryOperatorKind . IsExpression :
202208 case BinaryOperatorKind . IsNotExpression : {
@@ -234,7 +240,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
234240 if ( leftType . IsObjectType ( ) ) {
235241 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectEqual" ) ) ;
236242 } else if ( leftType . IsStringType ( ) ) {
237- return await ConvertToStringComparisonOperatorAsync ( node ) ;
243+ return null ; //Handled elsewhere
238244 } else if ( leftType . IsDecimalType ( ) ) {
239245 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
240246 } else if ( leftType . IsDateTimeType ( ) ) {
@@ -254,7 +260,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
254260 if ( leftType . IsObjectType ( ) ) {
255261 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectNotEqual" ) ) ;
256262 } else if ( leftType . IsStringType ( ) ) {
257- return await ConvertToStringComparisonOperatorAsync ( node ) ;
263+ return null ; //Handled elsewhere
258264 } else if ( leftType . IsDecimalType ( ) ) {
259265 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
260266 } else if ( leftType . IsDateTimeType ( ) ) {
@@ -274,7 +280,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
274280 if ( leftType . IsObjectType ( ) ) {
275281 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectLessEqual" ) ) ;
276282 } else if ( leftType . IsStringType ( ) ) {
277- return await ConvertToStringComparisonOperatorAsync ( node ) ;
283+ return await ConvertToStringComparisonOperatorAsync ( node , SyntaxKind . LessThanOrEqualExpression ) ;
278284 } else if ( leftType . IsDecimalType ( ) ) {
279285 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
280286 } else if ( leftType . IsDateTimeType ( ) ) {
@@ -294,7 +300,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
294300 if ( leftType . IsObjectType ( ) ) {
295301 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectGreaterEqual" ) ) ;
296302 } else if ( leftType . IsStringType ( ) ) {
297- return await ConvertToStringComparisonOperatorAsync ( node ) ;
303+ return await ConvertToStringComparisonOperatorAsync ( node , SyntaxKind . GreaterThanOrEqualExpression ) ;
298304 } else if ( leftType . IsDecimalType ( ) ) {
299305 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
300306 } else if ( leftType . IsDateTimeType ( ) ) {
@@ -314,7 +320,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
314320 if ( leftType . IsObjectType ( ) ) {
315321 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectLess" ) ) ;
316322 } else if ( leftType . IsStringType ( ) ) {
317- return await ConvertToStringComparisonOperatorAsync ( node ) ;
323+ return await ConvertToStringComparisonOperatorAsync ( node , SyntaxKind . LessThanExpression ) ;
318324 } else if ( leftType . IsDecimalType ( ) ) {
319325 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
320326 } else if ( leftType . IsDateTimeType ( ) ) {
@@ -334,7 +340,7 @@ public async Task<ExpressionSyntax> ConvertRewrittenBinaryOperatorOrNullAsync(VB
334340 if ( leftType . IsObjectType ( ) ) {
335341 return await ConvertToObjectComparisonOperatorAsync ( node , ( _compilerServices , _operators , "ConditionalCompareObjectGreater" ) ) ;
336342 } else if ( leftType . IsStringType ( ) ) {
337- return await ConvertToStringComparisonOperatorAsync ( node ) ;
343+ return await ConvertToStringComparisonOperatorAsync ( node , SyntaxKind . GreaterThanExpression ) ;
338344 } else if ( leftType . IsDecimalType ( ) ) {
339345 return await ConvertToDecimalComparisonOperatorAsync ( node ) ;
340346 } else if ( leftType . IsDateTimeType ( ) ) {
0 commit comments