Rework required attributes#11971
Merged
DustinCampbell merged 7 commits intodotnet:mainfrom Jun 24, 2025
Merged
Conversation
This is a fairly mechanical change to clean up the NameComparisonMode and ValueComparisonMode enums nested in RequiredAttributeDescriptor. - Un-nest NameComparisonMode from RequiredAttributeDescriptor - Rename NameComparisonMode to RequiredAttributeNameComparison - Un-nest ValueComparisonMode from RequiredAttributeDescriptor - Rename ValueComparisonMode to RequiredAttributeValueComparison - Rename RequiredAttributeDescriptorBuilder.NameComparisonMode property to NameComparison (matches RequiredAttributeDescriptor.NameComparison) - Rename RequiredAttributeDescriptorBuilder.ValueComparisonMode property to ValueComparison (matches RequiredAttributeDescriptor.ValueComparison ) - Rename TestRequiredAttributeDescriptorBuilderExtensions.NameComparisonMode extension method to NameComparison - Rename TestRequiredAttributeDescriptorBuilderExtensions.ValueComparisonMode extension method to ValueComparison
- Enable nullability - Remove unnecessary argument null checks - Add optional parameter to Name() extension method taking a RequiredAttributeNameComparison. - Update callers of Name() to pass optional parameter and remove calls to NameComparison() - Add optional parameter to Value() extension method taking a RequiredAttributeValueComparison. - Update callers of Value() to pass optional parameter and remove calls to ValueComparison()
- Store CaseSensitive in flag - Remove "Common.DirectiveAttribute" from Metadata and store in flag.
The RequiredAttributeDescriptor.DisplayName property can be computed , so we can stop serializing/deserializing the display name.
RequiredAttributeDescriptor no longer needs a Metadata property.
ToddGrun
reviewed
Jun 23, 2025
...zor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/RequiredAttributeFormatter.cs
Outdated
Show resolved
Hide resolved
333fred
approved these changes
Jun 23, 2025
This was referenced Jun 26, 2025
Closed
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
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@a10383a.
This change makes a few updates
RequiredAttributeDescriptor:RequiredAttributeDescriptor.NameComparisonModeandRequiredAttributeDescriptor.ValueComparisonModeenums toRequiredAttributeNameComparisonandRequiredAttributeValueComparison, respectively.Metadataproperty. There's only one bit of data that was ever stored in theMetadataproperty:IsDirectiveAttribute. This has been moved to a property onRequiredAttributeDescriptoritself. Interestingly, the compiler doesn't actually useIsDirectiveAttribute. However, it might sometime, so I've left it.DisplayNameproperty. This always has exactly the same format for anyRequiredAttributeDescriptor.CI Build: https://dev.azure.com/dnceng/internal/_build/results?buildId=2736049&view=results
Test Insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/645854
Toolset Run: https://dev.azure.com/dnceng/internal/_build/results?buildId=2736052&view=results