Skip to content

Commit 651d5aa

Browse files
Fix
1 parent 09f90e3 commit 651d5aa

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,9 +3188,6 @@ public override SyntaxNode ElementAccessExpression(SyntaxNode expression, IEnume
31883188
internal override SyntaxToken NumericLiteralToken(string text, ulong value)
31893189
=> SyntaxFactory.Literal(text, value);
31903190

3191-
public override SyntaxNode DefaultExpression(SyntaxNode type)
3192-
=> SyntaxFactory.DefaultExpression((TypeSyntax)type).WithAdditionalAnnotations(Simplifier.Annotation);
3193-
31943191
private static SyntaxNode Parenthesize(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
31953192
=> CSharpSyntaxGeneratorInternal.Parenthesize(expression, includeElasticTrivia, addSimplifierAnnotation);
31963193

src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,8 @@ internal SyntaxNode InterpolationFormatClause(string format)
17751775
/// An expression that represents the default value of a type.
17761776
/// This is typically a null value for reference types or a zero-filled value for value types.
17771777
/// </summary>
1778-
public abstract SyntaxNode DefaultExpression(SyntaxNode type);
1778+
public SyntaxNode DefaultExpression(SyntaxNode type)
1779+
=> this.SyntaxGeneratorInternal.DefaultExpression(type);
17791780

17801781
public SyntaxNode DefaultExpression(ITypeSymbol type)
17811782
=> this.SyntaxGeneratorInternal.DefaultExpression(type);

src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pa
245245
public override SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression)
246246
=> SyntaxFactory.CastExpression((TypeSyntax)type, (ExpressionSyntax)Parenthesize(expression)).WithAdditionalAnnotations(Simplifier.Annotation);
247247

248+
public override SyntaxNode DefaultExpression(SyntaxNode type)
249+
=> SyntaxFactory.DefaultExpression((TypeSyntax)type).WithAdditionalAnnotations(Simplifier.Annotation);
250+
248251
public override SyntaxNode DefaultExpression(ITypeSymbol type)
249252
{
250253
// If it's just a reference type, then "null" is the default expression for it. Note:
@@ -277,7 +280,7 @@ type is IPointerTypeSymbol ||
277280
}
278281

279282
// Default to a "default(<typename>)" expression.
280-
return SyntaxFactory.DefaultExpression(type.GenerateTypeSyntax());
283+
return DefaultExpression(type.GenerateTypeSyntax());
281284
}
282285

283286
public override SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind)

src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ internal static bool ParameterIsScoped(IParameterSymbol symbol)
129129
#endregion
130130

131131
public abstract SyntaxNode DefaultExpression(ITypeSymbol type);
132+
public abstract SyntaxNode DefaultExpression(SyntaxNode type);
133+
132134
public abstract SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression);
133135

134136
public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
@@ -149,8 +151,8 @@ public SyntaxNode MemberAccessExpression(SyntaxNode? expression, SyntaxNode memb
149151

150152
public abstract SyntaxNode MemberAccessExpressionWorker(SyntaxNode? expression, SyntaxNode memberName);
151153
public abstract SyntaxNode IdentifierName(string identifier);
152-
public abstract SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression);
153154

155+
public abstract SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression);
154156
public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
155157
=> ConvertExpression(TypeExpression(type), expression);
156158
}

src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
529529
Return SyntaxFactory.NothingLiteralExpression(SyntaxFactory.Token(SyntaxKind.NothingKeyword))
530530
End Function
531531

532+
Public Overrides Function DefaultExpression(type As SyntaxNode) As SyntaxNode
533+
Return SyntaxFactory.NothingLiteralExpression(SyntaxFactory.Token(SyntaxKind.NothingKeyword))
534+
End Function
535+
532536
Public Overrides Function IdentifierName(identifier As String) As SyntaxNode
533537
Return identifier.ToIdentifierName()
534538
End Function

src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
151151
Return SyntaxFactory.Literal(text, value)
152152
End Function
153153

154-
Public Overrides Function DefaultExpression(type As SyntaxNode) As SyntaxNode
155-
Return SyntaxFactory.NothingLiteralExpression(SyntaxFactory.Token(SyntaxKind.NothingKeyword))
156-
End Function
157-
158154
Public Overloads Overrides Function ElementAccessExpression(expression As SyntaxNode, arguments As IEnumerable(Of SyntaxNode)) As SyntaxNode
159155
Return SyntaxFactory.InvocationExpression(VisualBasicSyntaxGeneratorInternal.ParenthesizeLeft(expression), CreateArgumentList(arguments))
160156
End Function

0 commit comments

Comments
 (0)