Skip to content

Commit c110e95

Browse files
committed
Including return statements in multi-line, curly-braced code blocks by default
1 parent 4b4e58d commit c110e95

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

ReadableExpressions.UnitTests/WhenTranslatingAssignments.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ public void ShouldAssignTheResultOfATryCatch()
267267
{
268268
try
269269
{
270-
Console.Read();
270+
return Console.Read();
271271
}
272272
catch (IOException)
273273
{
274-
default(int);
274+
return default(int);
275275
}
276276
}";
277277

ReadableExpressions/Extensions/InternalExpressionExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static bool IsReturnable(this Expression expression)
3232
case ExpressionType.Conditional:
3333
case ExpressionType.Convert:
3434
case ExpressionType.ConvertChecked:
35+
case ExpressionType.Default:
3536
case ExpressionType.Invoke:
3637
case ExpressionType.MemberAccess:
3738
case ExpressionType.Parameter:

ReadableExpressions/Translators/Formatting/CodeBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public string WithParentheses()
105105
}";
106106
}
107107

108-
var codeBlock = Indented().GetCodeBlock();
108+
var codeBlock = WithReturn().Indented().GetCodeBlock();
109109

110110
if (codeBlock.StartsWithNewLine())
111111
{

ReadableExpressions/Translators/TryCatchExpressionTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private string GetCatchBlock(CatchBlock catchBlock, TranslationContext context)
4646
";
4747
}
4848

49-
private string GetExceptionClause(CatchBlock catchBlock, TranslationContext context)
49+
private static string GetExceptionClause(CatchBlock catchBlock, TranslationContext context)
5050
{
5151
var exceptionTypeName = catchBlock.Test.GetFriendlyName();
5252

0 commit comments

Comments
 (0)