File tree Expand file tree Collapse file tree
ICSharpCode.CodeConverter/CSharp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1047,14 +1047,16 @@ private async Task<CSharpSyntaxNode> ConvertCastExpression(VBSyntax.CastExpressi
10471047 {
10481048 var expressionSyntax = ( ExpressionSyntax ) await node . Expression . AcceptAsync ( TriviaConvertingVisitor ) ;
10491049
1050- if ( convertMethodOrNull != null ) {
1051- expressionSyntax = Invoke ( convertMethodOrNull , expressionSyntax ) ;
1052- }
1050+ if ( ! ( _semanticModel . GetOperation ( node ) is IConversionOperation co ) || ! co . Conversion . IsIdentity ) {
1051+ if ( convertMethodOrNull != null ) {
1052+ expressionSyntax = Invoke ( convertMethodOrNull , expressionSyntax ) ;
1053+ }
10531054
1054- if ( castToOrNull != null ) {
1055- expressionSyntax = await Cast ( expressionSyntax , castToOrNull ) ;
1056- if ( node . Parent is VBasic . Syntax . MemberAccessExpressionSyntax ) {
1057- expressionSyntax = SyntaxFactory . ParenthesizedExpression ( expressionSyntax ) ;
1055+ if ( castToOrNull != null ) {
1056+ expressionSyntax = await Cast ( expressionSyntax , castToOrNull ) ;
1057+ if ( node . Parent is VBasic . Syntax . MemberAccessExpressionSyntax ) {
1058+ expressionSyntax = SyntaxFactory . ParenthesizedExpression ( expressionSyntax ) ;
1059+ }
10581060 }
10591061 }
10601062
You can’t perform that action at this time.
0 commit comments