Skip to content

Conversation

@DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Jun 16, 2025

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:

  • Remove the Metadata property. There were only two bits of metadata stored in the Metadata property and both have become properties on BoundAttributeParameterDescriptor itself.
  • Introduce TypeNameObject that is similar to DocumentationObject. This helps reduce the amount of data that needs to be serialized and deserialized.
  • Don't serialize the DisplayName property. This always has exactly the same format for BoundAttributeParameterDescriptors.

@DustinCampbell DustinCampbell requested review from a team as code owners June 16, 2025 22:44
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.
@DustinCampbell DustinCampbell force-pushed the bound-attribute-parameters branch from 321d08f to 90a9a43 Compare June 18, 2025 09:52
@DustinCampbell DustinCampbell changed the base branch from dev/dustinca/tag-helper-parents to main June 18, 2025 09:52
@DustinCampbell
Copy link
Member Author

Pinging @dotnet/razor-compiler for a second review.

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.

Mostly LGTM. Just a couple of small comments.

- 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`
Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@DustinCampbell DustinCampbell merged commit 00adc9e into dotnet:main Jun 23, 2025
11 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 23, 2025
@DustinCampbell DustinCampbell deleted the bound-attribute-parameters branch June 23, 2025 19:18
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.

6 participants