Skip to content

Commit

Permalink
Exclude name of the closure class
Browse files Browse the repository at this point in the history
  • Loading branch information
bfriesen committed Feb 2, 2021
1 parent 8a2d2ed commit 5ae449c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Moq/StringBuilderExtensions.AppendExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;

using Moq.Properties;
Expand Down Expand Up @@ -259,7 +261,15 @@ private static StringBuilder AppendExpression(this StringBuilder builder, Member
{
if (expression.Expression != null)
{
builder.AppendExpression(expression.Expression);
if (expression.Expression is ConstantExpression ce
&& ce.Type.IsDefined(typeof(CompilerGeneratedAttribute)))
{
return builder.Append(expression.Member.Name);
}
else
{
builder.AppendExpression(expression.Expression);
}
}
else
{
Expand Down

0 comments on commit 5ae449c

Please sign in to comment.