dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
506 stars 196 forks source link

Clean up JSON serialization and use it in compiler benchmarks #11229

Closed DustinCampbell closed 1 day ago

DustinCampbell commented 4 days ago

The Razor compiler was carrying an old copy of TagHelperDescriptorJsonConverter, though it was only used in benchmarks. Since it doesn't make sense to have two JSON formats for tag helpers, this change updates Microsoft.AspNetCore.Razor.Serialization.JSON so that it can be referenced by the compiler benchmarks and removes TagHelperDescriptorJsonConverter. With this done, it will be easier to slim down the TagHelperDescriptor API, which I'm planning to do to speed tag helpers up a bit. (Although, that'll still require updates to https://github.com/dotnet/sdk/tree/main/src/RazorSdk/Tool.)

I recommend reviewing commit-by-commit.

DustinCampbell commented 3 days ago

It's not entirely clear to me why we need such a broad opt-out for tag helper caching, when there is also a boolean parameter to control it

The reason is that the boolean parameter controls a code path that uses types that aren't available to the compiler, namely TagHelperCache. In fact, the vast majority of code that includes the JSON serialization does not use the flag. The only place that the caching is actually used is in JSON serialization is MS.VS.LanguageServices.Razor, specifically for Live Share. It didn't seem helpful to include this functionality for everything given the narrow scenario that it's actually used.

DustinCampbell commented 3 days ago

cc @chsienki, @jjonescz, @333fred and @jaredpar for compiler reviews