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

Add support for default interface members in inheritance-based proxy types #661

Merged

Commits on Sep 10, 2023

  1. DefaultInterfaceMembersTestCase: use strings

    ... instead of `MethodBase`s to identify which methods get invoked. This
    should make tests easier to read & understand.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    dd250a6 View commit details
    Browse the repository at this point in the history
  2. Add more tests for default interface method impls

    Two of these tests are failing:
    
     * Class proxies cannot intercept interface methods with a default
       implementation if the proxied class type does not override it.
    
     * Interface proxies cannot proceed to default implementations.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    5e7cfc4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    501be75 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    65475c5 View commit details
    Browse the repository at this point in the history
  5. Fix interception of inherited default impls in class proxies

    A class implementing an interface with default method implementations
    will not necessarily override those methods; in such cases, the methods
    are currently "invisible" to DynamicProxy and thus won't get proxied.
    
    This can be solved by an extra pass over all interfaces to collect such
    methods, as is done in this commit.
    
    Ideally we wouldn't have to iterate over all interfaces more than once,
    so we should next make an effort to limit the runtime impact of this
    extra pass.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    ce4be78 View commit details
    Browse the repository at this point in the history
  6. Reduce impact of extra collection pass

    Assuming that default interface methods are relatively rare, if we keep
    track of which interfaces contain any of them at all, we can then limit
    our extra pass during class proxy generation to just those interfaces
    and exclude the rest (i.e. hopefully the majority).
    
    Additionally, our collector may skip some of the more expensive checks
    by bailing out for methods it isn't actually interested in.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    9e7a15e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c542f13 View commit details
    Browse the repository at this point in the history
  8. Fix tests for properties with default impls

    ... by properly forwarding the "standalone" flag in the newly added
    collector.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    840748a View commit details
    Browse the repository at this point in the history
  9. Add more tests re: methods with default impls

    Those essentially target "mixed" scenarios where default implementations
    show up next to "regular" methods. This is to better ensure that the new
    code paths will not interfere with pre-existing logic.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    a7b6a7c View commit details
    Browse the repository at this point in the history
  10. Add test for generic method with default impl

    The code changes we made do not suggest that pre-existing logic dealing
    with generics might somehow no longer work, however we did add a bit of
    new code for generics which we should target with at least one test.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    0bb493c View commit details
    Browse the repository at this point in the history
  11. Add tests for static interface methods

    This includes a test for `static abstract` methods that remains ignored
    for now, since we haven't implemented support for this C# 11 language
    feature, nor do we target any runtimes that support it. (The test is
    being added as a future reminder, once we start targeting .NET 7+.)
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    fe40634 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    27828bd View commit details
    Browse the repository at this point in the history
  13. Group tests using #regions

    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    09d4c15 View commit details
    Browse the repository at this point in the history
  14. Add tests for protected methods with default impls

    A few of these tests fail due to `Debug.Assert` failures in `Interface-
    MembersWithDefaultImplementationCollector`.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    982f5ff View commit details
    Browse the repository at this point in the history
  15. Exclude non-overridable methods from collection

    `sealed` methods do not show up in interface mappings, so make sure
    `InterfaceMembersWithDefaultImplementationCollector` can deal with them
    anyway in case of interfaces that contain both `sealed` methods as well
    as overridable ones with a default implementation.
    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    e41315c View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    ae9139f View commit details
    Browse the repository at this point in the history
  17. Update changelog

    stakx committed Sep 10, 2023
    Configuration menu
    Copy the full SHA
    51112db View commit details
    Browse the repository at this point in the history