.N .NET Landscape

ImpromptuInterface

Source Generators & Metaprogramming
github.com/ekonbenefits/impromptu-interface

Static interface to dynamic implementation (duck casting). Uses the DLR combined with Reflect.Emit.

GitHub stars
679
Forks
65
Open issues
18
NuGet downloads
35,160,774
latest 8.1.0
License
Apache-2.0
Language
C#
Last push
1 month ago
23 Sept 2026
Created
27 Aug 2012

net4.0/netstd2.0 framework to allow you to wrap any object (static or dynamic) with a static interface even though it didn't inherit from it. It does this by emitting cached dynamic binding code inside a proxy.

build Tests Line coverage Branch coverage NuGet

Available on NuGet. One workflow covers net40, netstandard2.0 and net10.0 on Windows, macOS and Linux, plus a browser-wasm leg. From the latest master build: test results and coverage. Every run also carries its own per-platform table in the run summary.

Some of the features of ImpromptuInterface have been moved into another library called Dynamitey, ImpromptuInterface depends on Dynamitey.

ImpromptuInterface.FSharp has been spun off into FSharp.Interop.Dynamic and also depends on Dynamitey.

ImpromptuInterface.MVVM has been spun off into it's own repo ImpromptuInterface.MVVM and only receives maitenance updates.

Quick Usage:

    using ImpromptuInterface;
    using Dynamitey;

    public interface IMyInterface{

       string Prop1 { get;  }

        long Prop2 { get; }

        Guid Prop3 { get; }

        bool Meth1(int x);
   }
   //Anonymous Class
    var anon = new {
             Prop1 = "Test",
             Prop2 = 42L,
             Prop3 = Guid.NewGuid(),
             Meth1 = Return<bool>.Arguments<int>(it => it > 5)
    };

    var myInterface = anon.ActLike<IMyInterface>();

OR

   //Dynamic Expando object
    dynamic expando = new ExpandoObject();
    expando.Prop1 ="Test";
    expando.Prop2 = 42L;
    expando.Prop3 = Guid.NewGuid();
    expando.Meth1 = Return<bool>.Arguments<int>(it => it > 5);
    IMyInterface myInterface = Impromptu.ActLike(expando);