Add StringSyntax format attributes to methods and parameters #62179
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.
This PR adds
StringSyntaxAttribute
annotations to various methods and parameters throughout the codebase.These attributes help provide better tooling support in IDEs by annotating string parameters that are expected to have specific formats. The annotations enable better syntax highlighting, autocompletion, and validation when working with specific string formats.
The PR adds annotations for the following format types that were missing from previous work:
EnumFormat
- Applied to string parameters that expect enum format specifiersGuidFormat
- Applied to string parameters that expect GUID format specifiersNumericFormat
- Applied to string parameters that expect numeric format specifiersTimeSpanFormat
- Applied to string parameters that expect TimeSpan format specifiersChanges made:
[StringSyntax(StringSyntaxAttribute.EnumFormat)]
to enum format parameters in ModelExplorerExtensions and TemplateBuilder[StringSyntax(StringSyntaxAttribute.NumericFormat)]
to numeric format parameters in IHtmlGeneratorusing System.Diagnostics.CodeAnalysis
where neededFixes #44535.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.