-
Notifications
You must be signed in to change notification settings - Fork 809
Fix: Prevent @description decorator on metadata declarations #17520
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
Conversation
Co-authored-by: anthony-c-martin <[email protected]>
Co-authored-by: anthony-c-martin <[email protected]>
Co-authored-by: anthony-c-martin <[email protected]>
src/Bicep.Core.Samples/Files/baselines/InvalidMetadata_CRLF/main.diagnostics.bicep
Show resolved
Hide resolved
src/Bicep.Core.Samples/Files/baselines/InvalidMetadata_CRLF/main.symbols.bicep
Show resolved
Hide resolved
|
Test this change out locally with the following install scripts (Action run 16058989084) VSCode
Azure CLI
|
Co-authored-by: anthony-c-martin <[email protected]>
Co-authored-by: anthony-c-martin <[email protected]>
…cise Co-authored-by: anthony-c-martin <[email protected]>
| /// <summary> | ||
| /// The function can be used as a decorator anywhere except metadata. | ||
| /// </summary> | ||
| AnyDecoratorExceptMetadata = ParameterDecorator | VariableDecorator | FunctionDecorator | ResourceDecorator | ModuleDecorator | OutputDecorator | ExtensionDecorator | TypeDecorator, |
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.
Remove the MetadataDecorator flag entirely, and clean up references to it. It was only added pre-emptively, and isn't actually used anywhere.
anthony-c-martin
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.
See comment
Summary
This PR prevents the
@descriptiondecorator from being used on metadata declarations and removes it from language server completion suggestions for metadata. The@descriptiondecorator has no effect on the generated ARM template when used on metadata, making it misleading and incorrect.Issues Fixed
@descriptionon metadata now produces BCP269 error@descriptionwhen typing decorators for metadataBefore
✅ Compiles without error (but @description has no effect on generated template)
💡 Language server suggests @description for metadata
After
❌ BCP269 Error: Function "description" cannot be used as a metadata decorator
💡 Language server does not suggest @description for metadata
Implementation
Core Changes
Added
AnyDecoratorExceptMetadataflag inFunctionFlags.csMetadataDecoratorUpdated @description decorator in
SystemNamespaceType.csFunctionFlags.AnyDecoratortoFunctionFlags.AnyDecoratorExceptMetadataHow It Works
@descriptionis used on metadata, the validation system checks for theMetadataDecoratorflag. Since@descriptionnow usesAnyDecoratorExceptMetadata, it fails validation and produces BCP269 error.MetadataDecoratorflag, automatically excluding@description.Testing
InvalidMetadata_CRLFto expect BCP269 errorDescriptionDecorator_OnMetadata_ShouldProduceError(): Verifies error occursDescriptionDecorator_OnValidTargets_ShouldWork(): Ensures @description still works on parameters/outputsVerification
The fix leverages existing validation infrastructure and is minimal/surgical:
@descriptionon metadata → BCP269 error@descriptionon parameters/outputs → works correctly@descriptionfor metadataFixes #10714.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.