Skip to content

Add Locale to ITurnContext #4657

@vihorban

Description

@vihorban

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:

  1. Bring Locale property to ITurnContext interface. It will allow avoiding that cast.
  2. Make an extension to ITurnContext to get Locale. Locale duplicates logic with TurnState accessing.

Thanks

Metadata

Metadata

Assignees

Labels

Area: SDKGeneral SDK issues that don't clearly map to other areas (e.g.: helper methods)Bot ServicesRequired for internal Azure reporting. Do not delete. Do not change color.P1Painful if we don't fix, won't block releasingcustomer-replied-toIndicates that the team has replied to the issue reported by the customer. Do not delete.customer-reportedIssue is created by anyone that is not a collaborator in the repository.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions