dotnet / upgrade-assistant

A tool to assist developers in upgrading .NET Framework applications to .NET 6 and beyond
MIT License
1.11k stars 163 forks source link

Convert asp MVC partials to ViewComponets or AnchorTags #991

Open papyr opened 2 years ago

papyr commented 2 years ago

Hello we need help to modernize and upgrade from partials to view components

sunandabalu commented 2 years ago

@mjrousos could you provide some insights here?

mjrousos commented 2 years ago

This is similar to #276 (maybe a duplicate?). I think at the very least there should be an analyzer that detects usage of MVC Partials and points users at ViewComponent documentation so that they can learn about the more modern alternative.

I don't think we want to automate changing from partial views to view components for two reasons, though:

  1. I suspect it may be difficult to get the code fix provider right to automate that change well (this might be worth playing around with, though, if others disagree).
  2. Partial views are still supported and in simple cases aren't very different from ViewComponents. So, while it's a best practice to use ViewComponents most of the time, in upgrade scenarios specifically it may not be necessary to use them immediately and changing introduces risk. ViewComponents have a lot of nice features that partial views don't but if the user is upgrading an app that previously used partials than they don't need those additional features.

@papyr - would a new feature that notices the use of partials in the input app and alerts the user with a warning and links to ViewComponent docs meet the need you see here or did you envision something else with this proposal?

cc @KSchlobohm since I know he had a similar request in the past and may want to weigh in on what a solution looks like.

papyr commented 2 years ago

Hello @mjrousos thanks for the suggestion.

The structure for the two are very similar so, but it sometimes pops up as an issue in the upgrade assistant.

Many of the core workers, are dynamic components with data, like widgets, portlets (cards/charts) are coded as these components.

Compared to Java and Ruby there is such little support for this, So, for the dev community, I was hoping to get an automated or GUI driven migration (with the option to supply the models). The T4 templates are quite standard, so it should be easy to port the code.

Its just that the main meat after the controllers and razor views is the ViewComponentsand it would be a lot of help to have something like this for developers as .NET evolves!

papyr commented 7 months ago

The upgrade process is still very broken and the prompts are not clear. Sometimes the tooling is out of sync with the frameworks installed.

This has to be a better User/Developer experience It has provide better upgrade results