Open khalidabuhakmeh opened 3 years ago
@toupswork No one on the LDM think this is beneficial enough to to in the near term. That may change if the landscape of the ecosystem changes. But currently this isn't rising to that level for any of us, or our partner teams.
Bummer. Ok thank you for taking the time to reply.
Anonymous Interface Objects
Summary
Give C# developers the ability to instantiate anonymous objects that implement a specific interface without first implementing a concrete type.
Motivation
In scenarios where developers need to stub a type for unit tests, it becomes increasingly tedious to create classes that are essentially throw away. They add to the complexity of the project and ultimately increase the noise/signal ratio.
Detailed design
We can also implement multiple interfaces on an anonymous type.
Method implementations can be implemented using lambda methods.
Drawbacks
Alternatives
Create stub types for every new scenario you need an interface.
Use Kotlin. Here is a working example where the
khalid
instance is an anonymous object that happens to implement theIGreeting
interface.Unresolved questions
Design meetings