Skip to content

Commit

Permalink
More precise check for anonymous types
Browse files Browse the repository at this point in the history
...since not all compiler-generated types are anonymous types.
  • Loading branch information
stakx committed Oct 14, 2020
1 parent 69c0223 commit 9a936b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Moq/Linq/MockSetupsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private sealed class ReplaceMockObjectWithParameter : ExpressionVisitor

protected override Expression VisitMember(MemberExpression node)
{
if (node.Expression is ParameterExpression pe && pe.Type.IsDefined(typeof(CompilerGeneratedAttribute)))
if (node.Expression is ParameterExpression pe && pe.Type.IsDefined(typeof(CompilerGeneratedAttribute)) && pe.Type.Name.Contains("f__AnonymousType"))
{
// In LINQ query expressions with more than one `from` clause such as:
//
Expand Down

0 comments on commit 9a936b9

Please sign in to comment.