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

Avoid computing tag helper documentation strings in compiler #8706

Merged
merged 10 commits into from
May 16, 2023

Conversation

DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented May 15, 2023

Fixes #8538

The Razor compiler spends time formatting documentation strings for various tag helper objects, even though it never uses them. Each string is written directly to JSON when tag helpers are serialized. This affects throughput performance when tag helpers are passed from Microsoft.AspNet.Razor.Remote (running in Roslyn OOP) to VS, or when they are written to or read from the project.razor.json file.

This change provides a mechanism for tag helpers to reference a DocumentationDescriptor rather than a string. This descriptor holds onto an ID that refers to the expected string resource and an object[] of arguments if formatting is required. I've ensured that this is a non-breaking change. The Documentation property still exists and can be set on tag helper builders. However, I've gone ahead and updated the compiler to never set that property and to use documentation descriptors instead. The net result is that excess work can be avoided in the compiler and in serialization.

Rather than just storing documentation strings, tag helpers objects
store a "documentation object". This can be a string as before, or it
can a DocumentationDescriptor object that can provide the
documentation text. This has been done in a non-breaking way.
The compiler no longer sets the Documentation property of any tag
helper objects that it creates. Instead, it specifies particular
DocumentationDescriptors. This avoids formatting strings in the
compiler that it doesn't actually use.
@DustinCampbell DustinCampbell requested review from a team as code owners May 15, 2023 19:58
Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looking good. I would like to see failing earlier in a few places when there is unexpected input; many of my comments apply to the 3 different locations where documentationdescriptors can appear.

Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooling side LGTM

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more comment before I sign off.

@DustinCampbell
Copy link
Member Author

Thanks everyone for great suggestions. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delay computing the Documentation property for each object in a TagHelperDescriptor
4 participants