TelegramBots / Telegram.Bot.Framework

Simple framework for building Telegram bots
MIT License
97 stars 43 forks source link

Bug in the UseWhen rejoining branch #18

Closed poulad closed 5 years ago

poulad commented 5 years ago

The UseWhen method doesn't wire up the next delegate properly.

Expected

In the example pipeline below, the C middleware should be the next delegate passed to the B middleware. Therefore, C should be invoked only if next is invoked in the B.

new BotBuilder()
  .Use<A>()
  .UseWhen(predicate, branch =>
    branch.Use<B>()
  )
  .Use<C>()

Actual

But the C middleware is always invoked regardless of calling the next delegate in B.