I have a view
ViewUserControl<SearchViewData>
where
SearchViewData: CommonViewData
In this view I thus have a reference to Html.
This is of the type HtmlHelper<SearchViewData>
I create a custom HtmlHelper class called CommonHtmlHelper where I want to this (note the HtmlHelper parameter's type):
public static SelectList TranslatedApplicationSelectList(this HtmlHelper<CommonViewData> htmlHelper, string selectedCode)
Since SearchViewData inherits from CommonViewData and my Html is of type HtmlHelper<SearchViewData> it thus is also HtmlHelper<CommonViewData>.
Yet when I try to access the TranslatedApplicationSelectList method it in my views I get an error saying that HtmlHelper<SearchViewData> is not assignable to HtmlHelper<CommonViewData>.
Is this a flaw in my OO logic? Is this a limitation of how C# handles inheritance in generics (I think Skeet once explained me this, but I can't find the post anymore)?
and most of all, how do I fix it?