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 nested type matchers #1092

Merged
merged 6 commits into from Nov 1, 2020

Commits on Nov 1, 2020

  1. New helper method SubstituteTypeMatchers

    When testing an argument's type against a "template type" that may in-
    volve type matchers, we can no longer do a simple `IsAssignableFrom`;
    we'd have to create our own type matcher-aware version of it that com-
    pares each constituent part of both sides' types (visited in lockstep).
    
    Implementing our own `IsAssignableFrom` is going to be quite difficult
    because we also have to account for variance. Looking at both ECMA-335
    and .NET Core's source code, that looks rather complex... let's not go
    there.
    
    What we'll do instead is much easier: we still visit both sides' types'
    constituent parts, and whenever we encounter a type matcher in the
    template type, we test it against the corresponding (sub-) type from
    the argument. If it's a match, we substitute the argument type in the
    template type. If all type matchers match, we end up with a rewritten
    template type that no longer uses any matchers; we can then use `Is-
    AssignableFrom` with _that_ template type and the argument type to let
    the framework deal with variance.
    stakx committed Nov 1, 2020
    Configuration menu
    Copy the full SHA
    539f077 View commit details
    Browse the repository at this point in the history
  2. Add (still failing) tests for nested type matchers

    The `Microsoft.Extensions.Logging.Abstractions.ILogger` scenario is one
    that many people have shown interest in, so let's cover that one in
    particular.
    stakx committed Nov 1, 2020
    Configuration menu
    Copy the full SHA
    b3387cc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4c878e7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cc1b2e5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1e8fda9 View commit details
    Browse the repository at this point in the history
  6. Update the changelog

    stakx committed Nov 1, 2020
    Configuration menu
    Copy the full SHA
    16cf746 View commit details
    Browse the repository at this point in the history