HtmlHelper extension dynamics

I am used to the extension methods provided by intellisense after entering the type 'this'. But when I try to do this using HtmlHelper, extension methods are not displayed, even if the 'using' statement is present. Why is this? To clarify, I am doing this test from a regular .cs file, not a .cshtml file. There is no good reason, I just play with the MVC namespace and language to "see how it sticks." I still don’t know why intellisense does not take all 4000 extensions (I exagerate, but there are many of them).

Speaking of thousands of extensions, why are these supporting procedures provided as extension methods? If typical static classes were used, the selection of the shaving signature would probably be:

@EditorExtensions.EditorFor<T>(...)

Seems doable, and the "Wireframe Design Guide" states that extensions should be used rarely and preferably:

  • only for interface types.
  • only for types that cannot be redeployed

It does not seem that any of the “criteria” of the extension method is applied. This is why I would expect regular static classes, with static methods to populate this roll. What was the reason?

Update: Sample Helper Assistant Code (for further discussion)

public static class MyHelper
{
    public static MvcHtmlString Go(HtmlHelper foo){
        foo.Raw("Hello");
        return new MvcHtmlString("<p>What up Doc</p>");
    }
}
+3
source share
1 answer

Not sure why IntelliSense doesn't show extension methods HtmlHelperfor you. Are you sure you are using System.Web.Mvc.Html?

, , , , , .. , .

+2

Source: https://habr.com/ru/post/1743787/


All Articles