@@ -3134,17 +3134,6 @@ private static StatementSyntax AsStatement(SyntaxNode node)
31343134 public override SyntaxNode ExpressionStatement ( SyntaxNode expression )
31353135 => SyntaxFactory . ExpressionStatement ( ( ExpressionSyntax ) expression ) ;
31363136
3137- internal override SyntaxNode MemberAccessExpressionWorker ( SyntaxNode ? expression , SyntaxNode simpleName )
3138- {
3139- // can only be null in VB
3140- Contract . ThrowIfNull ( expression ) ;
3141-
3142- return SyntaxFactory . MemberAccessExpression (
3143- SyntaxKind . SimpleMemberAccessExpression ,
3144- ParenthesizeLeft ( ( ExpressionSyntax ) expression ) ,
3145- ( SimpleNameSyntax ) simpleName ) ;
3146- }
3147-
31483137 public override SyntaxNode ConditionalAccessExpression ( SyntaxNode expression , SyntaxNode whenNotNull )
31493138 => SyntaxGeneratorInternal . ConditionalAccessExpression ( expression , whenNotNull ) ;
31503139
@@ -3155,27 +3144,6 @@ public override SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> argu
31553144 => SyntaxFactory . ElementBindingExpression (
31563145 SyntaxFactory . BracketedArgumentList ( [ .. arguments . Cast < ArgumentSyntax > ( ) ] ) ) ;
31573146
3158- /// <summary>
3159- /// Parenthesize the left hand size of a member access, invocation or element access expression
3160- /// </summary>
3161- private static ExpressionSyntax ParenthesizeLeft ( ExpressionSyntax expression )
3162- {
3163- if ( expression is TypeSyntax ||
3164- expression . Kind ( )
3165- is SyntaxKind . ThisExpression
3166- or SyntaxKind . BaseExpression
3167- or SyntaxKind . ParenthesizedExpression
3168- or SyntaxKind . SimpleMemberAccessExpression
3169- or SyntaxKind . InvocationExpression
3170- or SyntaxKind . ElementAccessExpression
3171- or SyntaxKind . MemberBindingExpression )
3172- {
3173- return expression ;
3174- }
3175-
3176- return ( ExpressionSyntax ) Parenthesize ( expression ) ;
3177- }
3178-
31793147 private static SeparatedSyntaxList < ExpressionSyntax > AsExpressionList ( IEnumerable < SyntaxNode > expressions )
31803148 => [ .. expressions . OfType < ExpressionSyntax > ( ) ] ;
31813149
@@ -3212,52 +3180,14 @@ private static ArgumentSyntax AsArgument(SyntaxNode argOrExpression)
32123180 => argOrExpression as ArgumentSyntax ?? SyntaxFactory . Argument ( ( ExpressionSyntax ) argOrExpression ) ;
32133181
32143182 public override SyntaxNode InvocationExpression ( SyntaxNode expression , IEnumerable < SyntaxNode > arguments )
3215- => SyntaxFactory . InvocationExpression ( ParenthesizeLeft ( ( ExpressionSyntax ) expression ) , CreateArgumentList ( arguments ) ) ;
3183+ => SyntaxFactory . InvocationExpression ( CSharpSyntaxGeneratorInternal . ParenthesizeLeft ( ( ExpressionSyntax ) expression ) , CreateArgumentList ( arguments ) ) ;
32163184
32173185 public override SyntaxNode ElementAccessExpression ( SyntaxNode expression , IEnumerable < SyntaxNode > arguments )
3218- => SyntaxFactory . ElementAccessExpression ( ParenthesizeLeft ( ( ExpressionSyntax ) expression ) , SyntaxFactory . BracketedArgumentList ( CreateArguments ( arguments ) ) ) ;
3186+ => SyntaxFactory . ElementAccessExpression ( CSharpSyntaxGeneratorInternal . ParenthesizeLeft ( ( ExpressionSyntax ) expression ) , SyntaxFactory . BracketedArgumentList ( CreateArguments ( arguments ) ) ) ;
32193187
32203188 internal override SyntaxToken NumericLiteralToken ( string text , ulong value )
32213189 => SyntaxFactory . Literal ( text , value ) ;
32223190
3223- public override SyntaxNode DefaultExpression ( SyntaxNode type )
3224- => SyntaxFactory . DefaultExpression ( ( TypeSyntax ) type ) . WithAdditionalAnnotations ( Simplifier . Annotation ) ;
3225-
3226- public override SyntaxNode DefaultExpression ( ITypeSymbol type )
3227- {
3228- // If it's just a reference type, then "null" is the default expression for it. Note:
3229- // this counts for actual reference type, or a type parameter with a 'class' constraint.
3230- // Also, if it's a nullable type, then we can use "null".
3231- if ( type . IsReferenceType ||
3232- type is IPointerTypeSymbol ||
3233- type . IsNullable ( ) )
3234- {
3235- return SyntaxFactory . LiteralExpression ( SyntaxKind . NullLiteralExpression ) ;
3236- }
3237-
3238- switch ( type . SpecialType )
3239- {
3240- case SpecialType . System_Boolean :
3241- return SyntaxFactory . LiteralExpression ( SyntaxKind . FalseLiteralExpression ) ;
3242- case SpecialType . System_SByte :
3243- case SpecialType . System_Byte :
3244- case SpecialType . System_Int16 :
3245- case SpecialType . System_UInt16 :
3246- case SpecialType . System_Int32 :
3247- case SpecialType . System_UInt32 :
3248- case SpecialType . System_Int64 :
3249- case SpecialType . System_UInt64 :
3250- case SpecialType . System_Decimal :
3251- case SpecialType . System_Single :
3252- case SpecialType . System_Double :
3253- return SyntaxFactory . LiteralExpression (
3254- SyntaxKind . NumericLiteralExpression , SyntaxFactory . Literal ( "0" , 0 ) ) ;
3255- }
3256-
3257- // Default to a "default(<typename>)" expression.
3258- return DefaultExpression ( type . GenerateTypeSyntax ( ) ) ;
3259- }
3260-
32613191 private static SyntaxNode Parenthesize ( SyntaxNode expression , bool includeElasticTrivia = true , bool addSimplifierAnnotation = true )
32623192 => CSharpSyntaxGeneratorInternal . Parenthesize ( expression , includeElasticTrivia , addSimplifierAnnotation ) ;
32633193
@@ -3270,17 +3200,11 @@ public override SyntaxNode TypeOfExpression(SyntaxNode type)
32703200 public override SyntaxNode TryCastExpression ( SyntaxNode expression , SyntaxNode type )
32713201 => SyntaxFactory . BinaryExpression ( SyntaxKind . AsExpression , ( ExpressionSyntax ) Parenthesize ( expression ) , ( TypeSyntax ) type ) ;
32723202
3273- public override SyntaxNode CastExpression ( SyntaxNode type , SyntaxNode expression )
3274- => SyntaxFactory . CastExpression ( ( TypeSyntax ) type , ( ExpressionSyntax ) Parenthesize ( expression ) ) . WithAdditionalAnnotations ( Simplifier . Annotation ) ;
3275-
3276- public override SyntaxNode ConvertExpression ( SyntaxNode type , SyntaxNode expression )
3277- => SyntaxFactory . CastExpression ( ( TypeSyntax ) type , ( ExpressionSyntax ) Parenthesize ( expression ) ) . WithAdditionalAnnotations ( Simplifier . Annotation ) ;
3278-
32793203 public override SyntaxNode AssignmentStatement ( SyntaxNode left , SyntaxNode right )
32803204 => SyntaxFactory . AssignmentExpression ( SyntaxKind . SimpleAssignmentExpression , ( ExpressionSyntax ) left , ( ExpressionSyntax ) Parenthesize ( right ) ) ;
32813205
32823206 private static SyntaxNode CreateBinaryExpression ( SyntaxKind syntaxKind , SyntaxNode left , SyntaxNode right )
3283- => SyntaxFactory . BinaryExpression ( syntaxKind , ( ExpressionSyntax ) Parenthesize ( left ) , ( ExpressionSyntax ) Parenthesize ( right ) ) ;
3207+ => CSharpSyntaxGeneratorInternal . CreateBinaryExpression ( syntaxKind , left , right ) ;
32843208
32853209 public override SyntaxNode ValueEqualsExpression ( SyntaxNode left , SyntaxNode right )
32863210 => CreateBinaryExpression ( SyntaxKind . EqualsExpression , left , right ) ;
@@ -3327,9 +3251,6 @@ public override SyntaxNode ModuloExpression(SyntaxNode left, SyntaxNode right)
33273251 public override SyntaxNode BitwiseAndExpression ( SyntaxNode left , SyntaxNode right )
33283252 => CreateBinaryExpression ( SyntaxKind . BitwiseAndExpression , left , right ) ;
33293253
3330- public override SyntaxNode BitwiseOrExpression ( SyntaxNode left , SyntaxNode right )
3331- => CreateBinaryExpression ( SyntaxKind . BitwiseOrExpression , left , right ) ;
3332-
33333254 public override SyntaxNode BitwiseNotExpression ( SyntaxNode operand )
33343255 => SyntaxFactory . PrefixUnaryExpression ( SyntaxKind . BitwiseNotExpression , ( ExpressionSyntax ) Parenthesize ( operand ) ) ;
33353256
@@ -3355,13 +3276,10 @@ public override SyntaxNode BaseExpression()
33553276 => SyntaxFactory . BaseExpression ( ) ;
33563277
33573278 public override SyntaxNode TypedConstantExpression ( TypedConstant value )
3358- => ExpressionGenerator . GenerateExpression ( this , value ) ;
3279+ => ExpressionGenerator . GenerateExpression ( value ) ;
33593280
33603281 private protected override SyntaxNode GenerateExpression ( ITypeSymbol ? type , object ? value , bool canUseFieldReference )
3361- => ExpressionGenerator . GenerateExpression ( this , type , value , canUseFieldReference ) ;
3362-
3363- public override SyntaxNode IdentifierName ( string identifier )
3364- => identifier . ToIdentifierName ( ) ;
3282+ => ExpressionGenerator . GenerateExpression ( type , value , canUseFieldReference ) ;
33653283
33663284 public override SyntaxNode GenericName ( string identifier , IEnumerable < SyntaxNode > typeArguments )
33673285 => GenericName ( identifier . ToIdentifierToken ( ) , typeArguments ) ;
@@ -3411,17 +3329,6 @@ internal override SyntaxNode GlobalAliasedName(SyntaxNode name)
34113329 public override SyntaxNode NameExpression ( INamespaceOrTypeSymbol namespaceOrTypeSymbol )
34123330 => namespaceOrTypeSymbol . GenerateNameSyntax ( ) ;
34133331
3414- private protected override SyntaxNode TypeExpression ( ITypeSymbol typeSymbol , RefKind refKind )
3415- {
3416- var type = typeSymbol . GenerateTypeSyntax ( ) ;
3417- return refKind switch
3418- {
3419- RefKind . Ref => SyntaxFactory . RefType ( type ) ,
3420- RefKind . RefReadOnly => SyntaxFactory . RefType ( RefKeyword , ReadOnlyKeyword , type ) ,
3421- _ => type ,
3422- } ;
3423- }
3424-
34253332 public override SyntaxNode TypeExpression ( SpecialType specialType )
34263333 => SyntaxFactory . PredefinedType ( specialType switch
34273334 {
0 commit comments