-
Notifications
You must be signed in to change notification settings - Fork 190
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
Conversation
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.
There was a problem hiding this 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.
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/ComparerUtilities.cs
Outdated
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptor.cs
Outdated
Show resolved
Hide resolved
...piler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.FormattedDescriptor.cs
Outdated
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.cs
Outdated
Show resolved
Hide resolved
...piler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.FormattedDescriptor.cs
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.ProjectEngineHost/Serialization/ObjectReaders.TagHelperReader.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Serialization/ObjectWriters.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tooling side LGTM
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs
Outdated
Show resolved
Hide resolved
...Compiler/Microsoft.AspNetCore.Razor.Language/src/DocumentationDescriptor.SimpleDescriptor.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Serialization/ObjectWriters.cs
Show resolved
Hide resolved
There was a problem hiding this 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.
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DocumentationObject.cs
Show resolved
Hide resolved
Thanks everyone for great suggestions. Much appreciated! |
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 anobject[]
of arguments if formatting is required. I've ensured that this is a non-breaking change. TheDocumentation
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.