You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Probably an edge case, but it demonstrates that Moq's reflection logic regarding type members and overrides in type hierarchies still comes to wrong conclusions sometimes. It is probable that there are other places in Moq suffering from the same problem.
The test fails because querying mock.Object.Property will yield null instead of the value it was set to.
Additional details:
In order to find the cause for this, it's instructive to also consider the reverse case where only get getter gets overridden. (That case works fine.) The first call to a property's accessor will determine which property gets set up: WithAutoProperty's, or OverridesOnlySetter's / OverridesOnlyGetter's.
The text was updated successfully, but these errors were encountered:
System.NullReferenceException: Object reference not set to an instance of an object.
at Moq.ExpressionExtensions.GetReboundProperty(MemberExpression expression) in C:\Users\stakx\Projects\moq4\src\Moq\ExpressionExtensions.cs:line 312
at Moq.ExpressionExtensions.ToPropertyInfo(LambdaExpression expression) in C:\Users\stakx\Projects\moq4\src\Moq\ExpressionExtensions.cs:line 328
at Moq.Mock.SetupGet(Mock mock, LambdaExpression expression, Condition condition) in C:\Users\stakx\Projects\moq4\src\Moq\Mock.cs:line 496
at Moq.Mock`1.SetupGet[TProperty](Expression`1 expression) in C:\Users\stakx\Projects\moq4\src\Moq\Mock.Generic.cs:line 347
Probably an edge case, but it demonstrates that Moq's reflection logic regarding type members and overrides in type hierarchies still comes to wrong conclusions sometimes. It is probable that there are other places in Moq suffering from the same problem.
Steps to reproduce:
Expected outcome:
The test passes. It should be possible to set and subsequently query that property, just like in C#:
Actual outcome:
The test fails because querying
mock.Object.Property
will yieldnull
instead of the value it was set to.Additional details:
In order to find the cause for this, it's instructive to also consider the reverse case where only get getter gets overridden. (That case works fine.) The first call to a property's accessor will determine which property gets set up:
WithAutoProperty
's, orOverridesOnlySetter
's /OverridesOnlyGetter
's.The text was updated successfully, but these errors were encountered: