-
Notifications
You must be signed in to change notification settings - Fork 217
Rework bound attribute parameters #11954
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
Merged
DustinCampbell
merged 12 commits into
dotnet:main
from
DustinCampbell:bound-attribute-parameters
Jun 23, 2025
Merged
Rework bound attribute parameters #11954
DustinCampbell
merged 12 commits into
dotnet:main
from
DustinCampbell:bound-attribute-parameters
Jun 23, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davidwengier
approved these changes
Jun 17, 2025
chsienki
approved these changes
Jun 17, 2025
....Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TypeNameObjectFormatter.cs
Outdated
Show resolved
Hide resolved
Every single BoundAttributeParameterDescriptor has a property name, so it's unnecessarily inefficient to store it in metadata. Instead, add a PropertyName property and use that.
Expose the BoundAttributeParamterFlags.
Store BindAttributeGetSet metadata in a flag.
With PropertyName and Flags added, BoundAttributeParameter no longer needs a Metadata property.
The BoundAttributeParamaterDescriptorBuilder.DisplayName property is never actually set. So, make BoundAttributeParmeterDescriptor.DisplayName computed and stop serializing/deserializing the display name.
TypeNameObject is similar to DocumentationObject. It wraps either an int that indexes to a well-known type, or a string. This change includes a new message pack formatter for TypeNameObject.
Be sure to consider the format of TypeNameObject when skimming.
321d08f to
90a9a43
Compare
Member
Author
|
Pinging @dotnet/razor-compiler for a second review. |
ToddGrun
reviewed
Jun 20, 2025
src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/TypeNameObject.cs
Show resolved
Hide resolved
ToddGrun
reviewed
Jun 20, 2025
....Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TypeNameObjectFormatter.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Jun 20, 2025
....Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TypeNameObjectFormatter.cs
Outdated
Show resolved
Hide resolved
333fred
reviewed
Jun 20, 2025
Member
333fred
left a comment
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.
Mostly LGTM. Just a couple of small comments.
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/TypeNameKind.cs
Outdated
Show resolved
Hide resolved
...iler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/BoundAttributeParameterDescriptor.cs
Outdated
Show resolved
Hide resolved
- Make `TypeNameKind` enum private to `TypeNameObjectFormatter`. - Reduce the size of serialized `TypeNameKind` from an integer to a byte.
…atter - Make `ArgKind` enum private to `DocumentationObjectFormatter`. - Reduce the size of serialized `ArgKind` from an integer to a byte. - Make `DocumentationKind` enum private to `DocumentationObjectFormatter`. - Reduce the size of serialized `DocumentationKind` from an integer to a byte. - Minor clean up.
Uses a byte instead of an int to index known type names. We'll need to revisit this if the number of known types grows beyond 256. To make serialization a bit easier, I've added methods for reading/writing bytes to `JsonDataReader` and `JsonDataWriter`.
The following properties are now defined as read-only auto-properties: - `BoundAttributeParameterDescriptor.DocumentationObject` - `BoundAttributeParameterDescriptor.TypeNameObject`
333fred
approved these changes
Jun 20, 2025
ToddGrun
approved these changes
Jun 21, 2025
Contributor
ToddGrun
left a comment
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.
![]()
This was referenced Jun 25, 2025
This was referenced Jun 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
This affects the Razor SDK. When the compiler flows to the .NET VMR, this commit will be needed: dotnet/dotnet@cb7d5b4.
This change makes a few updates
BoundAttributeParameterDescriptor:Metadataproperty. There were only two bits of metadata stored in theMetadataproperty and both have become properties onBoundAttributeParameterDescriptoritself.TypeNameObjectthat is similar toDocumentationObject. This helps reduce the amount of data that needs to be serialized and deserialized.DisplayNameproperty. This always has exactly the same format forBoundAttributeParameterDescriptors.