Skip to content

default interface methods #601

Description

@eshadboltadr

Is your feature request related to a problem? Please describe.
I have an interface with a default interface method which is a property with a getter body defined in the interface definition.

I construct a concrete class derived from the interface and I pass it to the handlebars template as the context parameter (data parameter is null). The type of the context parameter is System.Object.

Handlebars doesn't seem to evaluate the default interface method, but it does for properties defined in the derived class.

Describe the solution you'd like
Can a new option be added to the handlebars environment configuration, so that default interface methods are included?

Describe alternatives you've considered
I don't want to write an explicit implementation of each property in each derived class because it wouldn't be DRY.

Is your feature request supported by Handlebarsjs? Please provide details.
N/A

Additional context

Template:

{{DateTimeStr}}{{OtherStr}}

C#:

publicinterfaceIBaseData{DateTimeDateTimeUtc{get;}}publicinterfaceIData:IBaseData{stringDateTimeStr=>DateTimeUtc.ToLocalTime().ToString("g");}publicclassData:IData{publicDateTimeDateTimeUtc{get;set;}publicstringOtherStr=>DateTimeUtc.ToLocalTime().ToString("g");}stringoutput=template(newData{DateTimeUtc=DateTime.UtcNow})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions