Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement the Razor compiler using source generators & support incrementality #26902

Closed
5 of 9 tasks
Tracked by #5510 ...
pranavkm opened this issue Oct 14, 2020 · 3 comments
Closed
5 of 9 tasks
Tracked by #5510 ...
Assignees
Labels
affected-all This issue impacts all the customers area-razor.compiler This issue is related to the Razor compiler (now external) Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Epic Groups multiple user stories. Can be grouped under a theme. feature-source-generators Priority:0 Work that we can't release without severity-blocking This label is used by an internal tool Theme: inner-loop
Milestone

Comments

@pranavkm
Copy link
Contributor

pranavkm commented Oct 14, 2020

Summary

The Razor compiler today represents a significant portion of time experienced by developers in inner-loop scenarios. We should investigate reimplementing it to be based on source generators to avoid the cost of an extra discrete step and removal of another process associated with building.

Today, the Razor compilation process is non-incremental, meaning even the smallest change to any Razor file results in a complete build of all Razor assets in a project. We should investigate the potential for adding further incrementality to Razor compilation so that unnecessary compilation time is not spent between edits.

Notes

The hypothesis is that an additional compile step can be eliminated along with state management if we are able to use source generators. We might also benefit of not producing janky types in design time builds.

Tasks

@pranavkm pranavkm added the area-razor.compiler This issue is related to the Razor compiler (now external) label Oct 14, 2020
@pranavkm pranavkm added this to the 6.0.0-alpha1 milestone Oct 15, 2020
@pranavkm pranavkm self-assigned this Oct 15, 2020
@mkArtakMSFT mkArtakMSFT added Theme: inner-loop enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Oct 27, 2020
@DamianEdwards DamianEdwards added Epic Groups multiple user stories. Can be grouped under a theme. Priority:0 Work that we can't release without labels Nov 2, 2020
@mkArtakMSFT mkArtakMSFT added affected-all This issue impacts all the customers severity-blocking This label is used by an internal tool labels Nov 12, 2020 — with ASP.NET Core Issue Ranking
@DamianEdwards DamianEdwards changed the title Investigate the use of source generators to avoid 2-phase compiles of .razor files Reimplement the Razor compiler using source generators & support incrementality Nov 13, 2020
@stefanloerwald
Copy link

stefanloerwald commented Dec 16, 2020

Speaking as someone who implemented a few source generators for Blazor, I absolutely love that this is one of the things potentially coming in net6.0!

However, please make sure that SGs should also support some sort of sequencing by that time. Otherwise all current SGs which rely on evaluating any of the generated code (the .g.cs files, e.g. for analyzing parameters) would break.

Thanks!

(See also: dotnet/roslyn#48358)

@pranavkm
Copy link
Contributor Author

@captainsafia let's use the smaller line items to track further work. We'll consider this issue resolved for preview4.

@stefanloerwald we made the Roslyn folks aware of your requirement. In addition, there are some ordering requirements for some of the in-box source generators e.g. System.Text.Json's source generator needs to run after the Razor one, so we have vested interest in seeing it addressed.

@captainsafia
Copy link
Member

@pranavkm Agreed -- I removed the working label for that very reason. Up, up, and away.

@mkArtakMSFT mkArtakMSFT added the Done This issue has been fixed label Mar 30, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2021
@danroth27 danroth27 modified the milestones: 6.0-preview4, 6.0-preview3 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-all This issue impacts all the customers area-razor.compiler This issue is related to the Razor compiler (now external) Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Epic Groups multiple user stories. Can be grouped under a theme. feature-source-generators Priority:0 Work that we can't release without severity-blocking This label is used by an internal tool Theme: inner-loop
Projects
None yet
Development

No branches or pull requests

6 participants