Skip to content

v1.2.0

Choose a tag to compare

@github-actions github-actions released this 17 Sep 19:06

Added

  • Delegates, lambdas and method groups satisfy an interface with a single method (a functional interface), both as [DuckTyped] arguments and through Duck.As.

  • A [DuckTyped] method converts to a delegate over the duck type (Func<Person, string> f = Ops.Describe;, items.Select(Ops.Describe)) through a generated overload.

  • static abstract members and operators via duck-typed constraints (where T : IAddable<T>), including BCL generic math interfaces such as IAdditionOperators<T, T, T>. The generated adapter is its own type argument, so these calls don't box.

  • Samples: IfItQuacks.Sample.Delegates and IfItQuacks.Sample.GenericMath.

  • Documentation: a Benchmarks page with measured numbers (BenchmarkDotNet, MemoryDiagnoser) for duck-typed calls and for Duck.As used as a view instead of a mapper.

  • Samples: IfItQuacks.Sample.Members (events, indexers, ref returns, default interface members) and IfItQuacks.Sample.Signatures (ref/out/params parameters, private methods, methods on a struct, runtime fallback).

Changed

  • Documentation: Known limitations is grouped into fewer sections, each showing the code that doesn't work.

Fixed

  • IFITQUACKS005 no longer mentions ref returns, which are supported now, and its title matches the documentation.
  • Interface properties and indexers with an init setter are adapted correctly. A type whose setter is init-only is reported as a mismatch instead of producing invalid code.
  • [DuckTyped] methods in an interface or in a file-local type are reported with IFITQUACKS004 instead of silently generating code for a different type. readonly and ref struct containing types keep their modifiers.
  • Members inherited from base interfaces are found when the argument is statically typed as an interface.
  • A member of the argument's type that hides the inherited member the interface was matched against no longer breaks the generated adapter.
  • Type argument inference skips static and generic candidate members and honours ref returns, matching the rules used for structural matching.