- Notifications
You must be signed in to change notification settings - Fork 492
Description
Hello team,
We are using Adaptive Dialogs library(version 4.8) for our solution. Due to the business needs, we use our own implementation of the ITurnContext. During updated to the latest version(currently 4.10.3) we faced the issue, that we cannot overcome by ourselves.
There is a method GetLocale in DialogContext.cs
that returns ((TurnContext)dialogContext.Context).Locale
The explicit cast breaks all the abstraction around ITurnContext and violates Dependency Inversion.
You had a discussion regarding the soft/explicit cast in the following PR by @cosmicshuai and @gabog
That explicit cast does not allow us to update the library to the latest version because we receive InvalidCastException. Soft cast also is not a good option, because in our case we will lose information about Locale. But Soft cast does not bring any runtime errors.
Locale property should be a part of the ITurnContext interface. Basically Locale property is a facade over TurnState.
I can suggest the following option to improve the codebase:
- Bring Locale property to ITurnContext interface. It will allow avoiding that cast.
- Make an extension to ITurnContext to get Locale. Locale duplicates logic with TurnState accessing.
Thanks