Skip to content

Commit 9a936b9

Browse files
committed
More precise check for anonymous types
...since not all compiler-generated types are anonymous types.
1 parent 69c0223 commit 9a936b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Moq/Linq/MockSetupsBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private sealed class ReplaceMockObjectWithParameter : ExpressionVisitor
151151

152152
protected override Expression VisitMember(MemberExpression node)
153153
{
154-
if (node.Expression is ParameterExpression pe && pe.Type.IsDefined(typeof(CompilerGeneratedAttribute)))
154+
if (node.Expression is ParameterExpression pe && pe.Type.IsDefined(typeof(CompilerGeneratedAttribute)) && pe.Type.Name.Contains("f__AnonymousType"))
155155
{
156156
// In LINQ query expressions with more than one `from` clause such as:
157157
//

0 commit comments

Comments
 (0)