-
Notifications
You must be signed in to change notification settings - Fork 786
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
base: main
Are you sure you want to change the base?
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.
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
@description
decorator from being used on metadata declarations and removes it from language server completion suggestions for metadata. The@description
decorator has no effect on the generated ARM template when used on metadata, making it misleading and incorrect.Issues Fixed
@description
on metadata now produces BCP269 error@description
when 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
AnyDecoratorExceptMetadata
flag inFunctionFlags.cs
MetadataDecorator
Updated @description decorator in
SystemNamespaceType.cs
FunctionFlags.AnyDecorator
toFunctionFlags.AnyDecoratorExceptMetadata
How It Works
@description
is used on metadata, the validation system checks for theMetadataDecorator
flag. Since@description
now usesAnyDecoratorExceptMetadata
, it fails validation and produces BCP269 error.MetadataDecorator
flag, automatically excluding@description
.Testing
InvalidMetadata_CRLF
to 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:
@description
on metadata → BCP269 error@description
on parameters/outputs → works correctly@description
for metadataFixes #10714.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.