2 overrides of WithExpression
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
2322
public override SyntaxNode
WithExpression
(SyntaxNode declaration, SyntaxNode expression)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
CodeGeneration\VisualBasicSyntaxGenerator.vb (1)
2808
Public Overrides Function
WithExpression
(declaration As SyntaxNode, expression As SyntaxNode) As SyntaxNode
44 references to WithExpression
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (1)
147
node = generator.
WithExpression
(node, newExpressionBody);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (19)
CodeGeneration\SyntaxGeneratorTests.cs (19)
3316
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.FieldDeclaration("f", Generator.IdentifierName("t")), Generator.IdentifierName("x"))).ToString());
3317
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.ParameterDeclaration("p", Generator.IdentifierName("t")), Generator.IdentifierName("x"))).ToString());
3318
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), Generator.IdentifierName("x"))).ToString());
3321
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression("p", [Generator.IdentifierName("x")]), Generator.IdentifierName("y"))).ToString());
3322
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression("p", [Generator.IdentifierName("x")]), Generator.IdentifierName("y"))).ToString());
3325
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression("p", Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString());
3326
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression("p", Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString());
3327
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression(Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString());
3328
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression(Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString());
3331
Assert.Null(Generator.GetExpression(Generator.
WithExpression
(Generator.IdentifierName("e"), Generator.IdentifierName("x"))));
3338
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(method, Generator.IdentifierName("y"))).ToString());
3345
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(local, Generator.IdentifierName("y"))).ToString());
3503
Assert.Equal("500", Generator.GetExpression(Generator.
WithExpression
(x, Generator.LiteralExpression(500))).ToString());
3504
Assert.Equal("500", Generator.GetExpression(Generator.
WithExpression
(y, Generator.LiteralExpression(500))).ToString());
3505
Assert.Equal("500", Generator.GetExpression(Generator.
WithExpression
(z, Generator.LiteralExpression(500))).ToString());
3525
Assert.Null(Generator.GetExpression(Generator.
WithExpression
(x, Generator.LiteralExpression(500))));
3526
Assert.Equal("500", Generator.GetExpression(Generator.
WithExpression
(y, Generator.LiteralExpression(500))).ToString());
3824
var xInitialized = Generator.
WithExpression
(declX, Generator.IdentifierName("e"));
3947
Generator.ReplaceNode(declC, declX, Generator.
WithExpression
(declX, Generator.IdentifierName("e"))),
Microsoft.CodeAnalysis.Features (1)
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (1)
147
node = generator.
WithExpression
(node, newExpressionBody);
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (22)
CodeGeneration\SyntaxGeneratorTests.vb (22)
2899
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.FieldDeclaration("f", Generator.IdentifierName("t")), Generator.IdentifierName("x"))).ToString())
2900
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.ParameterDeclaration("p", Generator.IdentifierName("t")), Generator.IdentifierName("x"))).ToString())
2901
Assert.Equal("x", Generator.GetExpression(Generator.
WithExpression
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), Generator.IdentifierName("x"))).ToString())
2904
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression("p", {Generator.IdentifierName("x")}), Generator.IdentifierName("y"))).ToString())
2905
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression("p", {Generator.IdentifierName("x")}), Generator.IdentifierName("y"))).ToString())
2906
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression({Generator.IdentifierName("x")}), Generator.IdentifierName("y"))).ToString())
2907
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression({Generator.IdentifierName("x")}), Generator.IdentifierName("y"))).ToString())
2908
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression("p", Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString())
2909
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression("p", Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString())
2910
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.ValueReturningLambdaExpression(Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString())
2911
Assert.Equal("y", Generator.GetExpression(Generator.
WithExpression
(Generator.VoidReturningLambdaExpression(Generator.IdentifierName("x")), Generator.IdentifierName("y"))).ToString())
2914
Generator.
WithExpression
(Generator.ValueReturningLambdaExpression({Generator.IdentifierName("s")}), Generator.IdentifierName("e")),
2917
Assert.Null(Generator.GetExpression(Generator.
WithExpression
(Generator.IdentifierName("e"), Generator.IdentifierName("x"))))
2924
Generator.
WithExpression
(Generator.ValueReturningLambdaExpression({Generator.IdentifierName("s")}), Generator.IdentifierName("e")),
2929
Generator.
WithExpression
(Generator.VoidReturningLambdaExpression({Generator.IdentifierName("s")}), Generator.IdentifierName("e")),
2934
Generator.
WithExpression
(Generator.ValueReturningLambdaExpression(Generator.IdentifierName("e")), Nothing),
2940
Generator.
WithExpression
(Generator.VoidReturningLambdaExpression(Generator.IdentifierName("e")), Nothing),
2946
Generator.
WithExpression
(Generator.ValueReturningLambdaExpression({Generator.IdentifierName("s")}), Nothing),
2953
Generator.
WithExpression
(Generator.VoidReturningLambdaExpression({Generator.IdentifierName("s")}), Nothing),
2958
Assert.Null(Generator.GetExpression(Generator.
WithExpression
(Generator.IdentifierName("e"), Generator.IdentifierName("x"))))
3515
Dim xInitialized = Generator.
WithExpression
(declX, Generator.IdentifierName("e"))
3607
Generator.ReplaceNode(declC, declX, Generator.
WithExpression
(declX, Generator.IdentifierName("e"))),
Microsoft.CodeAnalysis.Workspaces (1)
Editing\SyntaxEditorExtensions.cs (1)
41
=> editor.ReplaceNode(declaration, (d, g) => g.
WithExpression
(d, expression));