Skip to content

Commit 21549d2

Browse files
Add description to module name property for improved IntelliSense (#19310)
## Summary This PR adds a human-readable description to the `name` property on module/test declarations so that IntelliSense (hover info, completions) surfaces helpful guidance about the deployment name constraints. ## Changes In `src/Bicep.Core/LanguageConstants.cs`: - Added a `nameDescription` string ("The deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods.") and passed it to the `NamedTypeProperty` constructor for the module name property in both `CreateModuleType` and the test/extension common properties. This ensures that when users hover over or complete the `name` property in a module or test block, they see the allowed pattern and length constraints directly in the editor. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/19310) Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
1 parent 53b6d28 commit 21549d2

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/Bicep.Core.Samples/Files/baselines/InvalidModules_LF/Completions/moduleATopLevelProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"detail": "name",
4242
"documentation": {
4343
"kind": "markdown",
44-
"value": "Type: `string` \n"
44+
"value": "Type: `string` \nThe deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods. \n"
4545
},
4646
"deprecated": false,
4747
"preselect": false,

src/Bicep.Core.Samples/Files/baselines/InvalidModules_LF/Completions/moduleATopLevelPropertyAccess.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"detail": "name",
2727
"documentation": {
2828
"kind": "markdown",
29-
"value": "Type: `string` \n"
29+
"value": "Type: `string` \nThe deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods. \n"
3030
},
3131
"deprecated": false,
3232
"preselect": false,

src/Bicep.Core.Samples/Files/baselines/InvalidModules_LF/Completions/moduleAWithConditionTopLevelProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"detail": "name",
4242
"documentation": {
4343
"kind": "markdown",
44-
"value": "Type: `string` \n"
44+
"value": "Type: `string` \nThe deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods. \n"
4545
},
4646
"deprecated": false,
4747
"preselect": false,

src/Bicep.Core.Samples/Files/baselines/InvalidModules_LF/Completions/moduleAWithConditionTopLevelPropertyAccess.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"detail": "name",
2727
"documentation": {
2828
"kind": "markdown",
29-
"value": "Type: `string` \n"
29+
"value": "Type: `string` \nThe deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods. \n"
3030
},
3131
"deprecated": false,
3232
"preselect": false,

src/Bicep.Core/LanguageConstants.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ public static TypeSymbol CreateModuleType(IFeatureProvider features, IEnumerable
377377
var nameRequirednessFlags = TypePropertyFlags.None;
378378
// Taken from the official REST specs for Microsoft.Resources/deployments
379379
var nameType = TypeFactory.CreateStringType(minLength: 1, maxLength: 64, pattern: @"^[-\w._()]+$");
380+
var nameDescription = "The deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods.";
380381

381382
List<NamedTypeProperty> moduleProperties =
382383
[
383-
new(ModuleNamePropertyName, nameType, nameRequirednessFlags | TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.ReadableAtDeployTime | TypePropertyFlags.LoopVariant),
384+
new(ModuleNamePropertyName, nameType, nameRequirednessFlags | TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.ReadableAtDeployTime | TypePropertyFlags.LoopVariant, nameDescription),
384385
new(ResourceScopePropertyName, CreateResourceScopeReference(moduleScope), scopePropertyFlags),
385386
new(ModuleParamsPropertyName, paramsType, paramsRequiredFlag | TypePropertyFlags.WriteOnly),
386387
new(ModuleOutputsPropertyName, outputsType, TypePropertyFlags.ReadOnly),
@@ -407,9 +408,11 @@ public static TypeSymbol CreateUsingConfigType()
407408
var optionalPropFlags = TypePropertyFlags.WriteOnly | TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.ReadableAtDeployTime | TypePropertyFlags.DisallowAny;
408409
var requiredPropFlags = optionalPropFlags | TypePropertyFlags.Required;
409410

411+
var nameDescription = "The deployment name. Must be 1-64 characters, and can contain alphanumerics, underscores, parentheses, hyphens, and periods.";
412+
410413
NamedTypeProperty[] commonProps = [
411414
// Taken from the official REST specs for Microsoft.Resources/deployments
412-
new(ModuleNamePropertyName, TypeFactory.CreateStringType(minLength: 1, maxLength: 64, pattern: @"^[-\w._()]+$"), optionalPropFlags),
415+
new(ModuleNamePropertyName, TypeFactory.CreateStringType(minLength: 1, maxLength: 64, pattern: @"^[-\w._()]+$"), optionalPropFlags, nameDescription),
413416
// TODO model this properly as a scope, rather than a string
414417
new(ResourceScopePropertyName, LanguageConstants.String, requiredPropFlags),
415418
];

0 commit comments

Comments
 (0)