ekonbenefits / impromptu-interface

Static interface to dynamic implementation (duck casting). Uses the DLR combined with Reflect.Emit.
Apache License 2.0
655 stars 67 forks source link

feature: ActLike convert tuple #38

Closed msalvexx closed 3 years ago

msalvexx commented 3 years ago

It will be nice for legibility if we can use ActLike() method from Tuples, converting this code example from:

var account = new
            {
                Id = "valid_id",
                Name = "valid_name",
                Email = "valid_email@mail.com",
                Password = "valid_password"
            }.ActLike<IAccount>();

To this:

var account = (
                Id: "valid_id",
                Name: "valid_name",
                Email: "valid_email@mail.com",
                Password: "valid_password"
            ).ActLike<IAccount>();

I am not sure if we are able to do this, because C# has some limitations on using Tuples, but it will be nice if we can have this kind of feature :heart_eyes:

jbtule commented 3 years ago

Unfortunately, Tuple names are only known at compile time, so nothing I can do.

msalvexx commented 3 years ago

Sadly, but I was already expecting this answer Thanks for your comment