Skip to content

Commit 4f00526

Browse files
update docs
1 parent ede93fe commit 4f00526

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Analyzers/CSharp/Analyzers/UseExpressionBodyForLambda/UseExpressionBodyForLambdaHelpers.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ internal static bool TryConvertToExpressionBody(
142142
if (semicolonToken.TrailingTrivia.Any(t => t.IsDirective))
143143
return false;
144144

145-
// Changing from a block to an expression body can cahnge semantics. Specifically in the case where the block
146-
// did not return (i.e. being assigned to an action).
145+
// Changing from a block to an expression body can change semantics. Consider:
146+
//
147+
// X(() => { A = 1; });
148+
//
149+
// void X(Action action);
150+
// void X(Func<int> func);
151+
//
152+
// Changing this to `X(() => A = 1);` would change from calling the 'Action' overload to the 'Func<int>'
153+
// overload. Do a final semantic check to make sure the code meaning stays the same.
147154
var speculationAnalyzer = new SpeculationAnalyzer(
148155
declaration,
149156
declaration.WithBody(expression),

0 commit comments

Comments
 (0)