As you know, IApplicationBuilder in the Configure method of a startup class in ASP.NET Core requires that the middleware class matches certain semantics (namely, to have the Invoke method that receives HttpContext and returns Task), but I do not understand why it was not done as an interface? After all, nothing prevents me from writing something like:
public class FakeMiddleware { } then register it:
app.UseMiddleware<FakeMiddleware>(); and IApplicationBuilder eats it as pretty (and how else, the UseMiddleware method does not indicate what to take) and get the error already in runtime. Of course, the problem is not worth a damn, and in case of an error it will be noticeable right away, just why did it be so ugly if there is a quite elegant solution with the interface?