Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Setup recognition logic for sealed methods #497

Merged
merged 3 commits into from
Oct 22, 2017

Commits on Oct 22, 2017

  1. Add failing regression test

    `Setup` is expected to throw an exception if an attempt is made to
    set up a property that cannot be mocked. The 4 tests added in this
    commit demonstrate that Moq fails to recognize virtual, but sealed
    properties as uninterceptable.
    stakx committed Oct 22, 2017
    Configuration menu
    Copy the full SHA
    a341b46 View commit details
    Browse the repository at this point in the history
  2. Fix recognition of virtual sealed methods

    It turns out that the C# compiler puts the wrong `PropertyInfo` in an
    `Expression` for properties in derived classes. Apparently, it always
    puts in the `PropertyInfo` corresponding to the property's base dec-
    laration instead of the `PropertyInfo` of the accessed type.
    
    This commit adds a clause to the `expression.ToPropertyInfo` extension
    method to counteract this peculiar compiler behavior.
    stakx committed Oct 22, 2017
    1 Configuration menu
    Copy the full SHA
    f996915 View commit details
    Browse the repository at this point in the history
  3. Update the changelog

    stakx committed Oct 22, 2017
    Configuration menu
    Copy the full SHA
    7a2190c View commit details
    Browse the repository at this point in the history