File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/Analyzers/CSharp/Analyzers/UseExpressionBodyForLambda Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff 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 ) ,
You can’t perform that action at this time.
0 commit comments