diff --git a/src/Bicep.Core.IntegrationTests/ExtensionRegistryTests.cs b/src/Bicep.Core.IntegrationTests/ExtensionRegistryTests.cs index 5bac3c1b630..8e5e060fbba 100644 --- a/src/Bicep.Core.IntegrationTests/ExtensionRegistryTests.cs +++ b/src/Bicep.Core.IntegrationTests/ExtensionRegistryTests.cs @@ -646,7 +646,7 @@ public async Task Fallback_not_provided_in_json() result.Should().NotGenerateATemplate(); result.Should().HaveDiagnostics(new[]{ - ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), + ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), }); } diff --git a/src/Bicep.Core.IntegrationTests/NestedResourceTests.cs b/src/Bicep.Core.IntegrationTests/NestedResourceTests.cs index 1c08c0063b0..6653153f0fc 100644 --- a/src/Bicep.Core.IntegrationTests/NestedResourceTests.cs +++ b/src/Bicep.Core.IntegrationTests/NestedResourceTests.cs @@ -284,7 +284,7 @@ public void NestedResources_error_in_base_type() var diagnostics = Services.BuildCompilation(program).GetEntrypointSemanticModel().GetAllDiagnostics(); diagnostics.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[] { - ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), + ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), ("BCP157", DiagnosticLevel.Error, "The resource type cannot be determined due to an error in the containing resource."), }); } diff --git a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs index 379bb52c343..15314d97ff9 100644 --- a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs +++ b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs @@ -1113,7 +1113,7 @@ public void Test_Issue1985() result.Should().NotGenerateATemplate(); result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[] { - ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), + ("BCP029", DiagnosticLevel.Error, "The resource type is not valid. Specify a valid resource type of format \"@\"."), ("BCP062", DiagnosticLevel.Error, "The referenced declaration with name \"aksDefaultPoolSubnet\" is not valid."), ("BCP062", DiagnosticLevel.Error, "The referenced declaration with name \"aksDefaultPoolSubnet\" is not valid."), ("BCP057", DiagnosticLevel.Error, "The name \"aksServicePrincipalObjectId\" does not exist in the current context."), diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.diagnostics.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.diagnostics.bicep index ecd13436c1c..9d4815e4ef5 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.diagnostics.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.diagnostics.bicep @@ -1,6 +1,6 @@ type invalid1 = resource //@[016:024) [BCP231 (Error)] Using resource-typed parameters and outputs requires enabling EXPERIMENTAL feature "ResourceTypedParamsAndOutputs". (bicep https://aka.ms/bicep/core-diagnostics#BCP231) |resource| -//@[024:024) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || +//@[024:024) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || type invalid2 = resource<> //@[024:026) [BCP071 (Error)] Expected 1 argument, but got 0. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<>| @@ -10,15 +10,15 @@ type invalid3 = resource<'abc', 'def'> type invalid4 = resource //@[025:030) [BCP070 (Error)] Argument of type "{ bar: Astronomer.Astro/organizations }" is not assignable to parameter of type "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP070) |hello| type invalid5 = resource<'Microsoft.Storage/storageAccounts'> -//@[025:060) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts'| +//@[025:060) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts'| type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> -//@[025:061) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@'| +//@[025:061) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@'| type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> -//@[025:066) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@hello'| +//@[025:066) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@hello'| type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> //@[025:089) [BCP208 (Error)] The specified namespace "notARealNamespace" is not recognized. Specify a resource reference using one of the following namespaces: "az", "sys". (bicep https://aka.ms/bicep/core-diagnostics#BCP208) |'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'| type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> -//@[025:072) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |':Microsoft.Storage/storageAccounts@2022-09-01'| +//@[025:072) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |':Microsoft.Storage/storageAccounts@2022-09-01'| type invalid10 = resource<'abc' 'def'> //@[025:038) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<'abc' 'def'>| //@[032:032) [BCP236 (Error)] Expected a new line or comma character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP236) || diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResources_CRLF/main.diagnostics.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResources_CRLF/main.diagnostics.bicep index 600854981bf..c8d4a46de99 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResources_CRLF/main.diagnostics.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResources_CRLF/main.diagnostics.bicep @@ -6,40 +6,40 @@ bad // incomplete #completionTest(9) -> empty resource //@[009:009) [BCP017 (Error)] Expected a resource identifier at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP017) || -//@[009:009) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || +//@[009:009) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || resource foo //@[009:012) [BCP028 (Error)] Identifier "foo" is declared multiple times. Remove or rename the duplicates. (bicep https://aka.ms/bicep/core-diagnostics#BCP028) |foo| -//@[012:012) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || -//@[012:012) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || +//@[012:012) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || +//@[012:012) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || resource fo/o -//@[011:012) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) |/| -//@[011:013) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |/o| +//@[011:012) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) |/| +//@[011:013) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |/o| //@[013:013) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || resource foo 'ddd' //@[009:012) [BCP028 (Error)] Identifier "foo" is declared multiple times. Remove or rename the duplicates. (bicep https://aka.ms/bicep/core-diagnostics#BCP028) |foo| -//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| +//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| //@[018:018) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(23) -> resourceTypes resource trailingSpace -//@[024:024) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || -//@[024:024) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || +//@[024:024) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || +//@[024:024) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || // #completionTest(19,20) -> resourceObject resource foo 'ddd'= //@[009:012) [BCP028 (Error)] Identifier "foo" is declared multiple times. Remove or rename the duplicates. (bicep https://aka.ms/bicep/core-diagnostics#BCP028) |foo| -//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| +//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| //@[020:020) [BCP118 (Error)] Expected the "{" character, the "[" character, or the "if" keyword at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP118) || // wrong resource type resource foo 'ddd'={ //@[009:012) [BCP028 (Error)] Identifier "foo" is declared multiple times. Remove or rename the duplicates. (bicep https://aka.ms/bicep/core-diagnostics#BCP028) |foo| -//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| +//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| } resource foo 'ddd'=if (1 + 1 == 2) { //@[009:012) [BCP028 (Error)] Identifier "foo" is declared multiple times. Remove or rename the duplicates. (bicep https://aka.ms/bicep/core-diagnostics#BCP028) |foo| -//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| +//@[013:018) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'ddd'| } // using string interpolation for the resource type @@ -1060,18 +1060,18 @@ resource incorrectPropertiesKey2 'Microsoft.Resources/deploymentScripts@2020-10- // #completionTest(21) -> resourceTypes resource missingType -//@[021:021) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || -//@[021:021) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || +//@[021:021) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) || +//@[021:021) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) || // #completionTest(37,38,39,40,41,42,43,44) -> resourceTypes resource startedTypingTypeWithQuotes 'virma' -//@[037:044) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'virma'| +//@[037:044) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'virma'| //@[044:044) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(40,41,42,43,44,45) -> resourceTypes resource startedTypingTypeWithoutQuotes virma -//@[040:045) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) |virma| -//@[040:045) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |virma| +//@[040:045) [BCP068 (Error)] Expected a resource type string. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP068) |virma| +//@[040:045) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |virma| //@[045:045) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || resource dashesInPropertyNames 'Microsoft.ContainerService/managedClusters@2020-09-01' = { @@ -2050,37 +2050,37 @@ resource tenantLevelResourceBlocked 'Microsoft.Management/managementGroups@2020- // #completionTest(15,36,37) -> resourceTypes resource comp1 'Microsoft.Resources/' -//@[015:037) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/'| +//@[015:037) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/'| //@[037:037) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(15,16,17) -> resourceTypes resource comp2 '' -//@[015:017) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |''| +//@[015:017) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |''| //@[017:017) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(38) -> resourceTypes resource comp3 'Microsoft.Resources/t' -//@[015:038) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/t'| +//@[015:038) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/t'| //@[038:038) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(40) -> resourceTypes resource comp4 'Microsoft.Resources/t/v' -//@[015:040) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/t/v'| +//@[015:040) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/t/v'| //@[040:040) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(49) -> resourceTypes resource comp5 'Microsoft.Storage/storageAccounts' -//@[015:050) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts'| +//@[015:050) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts'| //@[050:050) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(50) -> storageAccountsResourceTypes resource comp6 'Microsoft.Storage/storageAccounts@' -//@[015:051) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@'| +//@[015:051) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Storage/storageAccounts@'| //@[051:051) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(52) -> templateSpecsResourceTypes resource comp7 'Microsoft.Resources/templateSpecs@20' -//@[015:053) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/templateSpecs@20'| +//@[015:053) [BCP029 (Error)] The resource type is not valid. Specify a valid resource type of format "@". (bicep https://aka.ms/bicep/core-diagnostics#BCP029) |'Microsoft.Resources/templateSpecs@20'| //@[053:053) [BCP018 (Error)] Expected the "=" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) || // #completionTest(60,61) -> virtualNetworksResourceTypes diff --git a/src/Bicep.Core.UnitTests/Diagnostics/LinterRuleTests/UseRecentApiVersionRuleTests.cs b/src/Bicep.Core.UnitTests/Diagnostics/LinterRuleTests/UseRecentApiVersionRuleTests.cs index 97d76b6c7ba..d852ad53bab 100644 --- a/src/Bicep.Core.UnitTests/Diagnostics/LinterRuleTests/UseRecentApiVersionRuleTests.cs +++ b/src/Bicep.Core.UnitTests/Diagnostics/LinterRuleTests/UseRecentApiVersionRuleTests.cs @@ -1189,7 +1189,7 @@ public void ArmTtk_ApiVersionIsNotAnExpression_Error() ResourceScope.ResourceGroup, FakeResourceTypes.ResourceScopeTypes, "2422-07-04", - ["[2] The resource type is not valid. Specify a valid resource type of format \"@\"."]); + ["[2] The resource type is not valid. Specify a valid resource type of format \"@\"."]); } [TestMethod] @@ -1315,7 +1315,7 @@ public void ArmTtk_NotAString_Error() FakeResourceTypes.ResourceScopeTypes, "2422-07-04", [ - "[2] The resource type is not valid. Specify a valid resource type of format \"@\"." + "[2] The resource type is not valid. Specify a valid resource type of format \"@\"." ]); } diff --git a/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs b/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs index 740d86bfe91..df7aa812bbe 100644 --- a/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs +++ b/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs @@ -191,7 +191,7 @@ public Diagnostic IdentifierMultipleDeclarations(string identifier) => CoreError public Diagnostic InvalidResourceType() => CoreError( "BCP029", - "The resource type is not valid. Specify a valid resource type of format \"@\"."); + "The resource type is not valid. Specify a valid resource type of format \"@\"."); public Diagnostic InvalidOutputType(IEnumerable validTypes) => CoreError( "BCP030", @@ -409,7 +409,7 @@ public Diagnostic ObjectRequiredForMethodAccess(TypeSymbol wrongType) => CoreErr public Diagnostic ExpectedResourceTypeString() => CoreError( "BCP068", - "Expected a resource type string. Specify a valid resource type of format \"@\"."); + "Expected a resource type string. Specify a valid resource type of format \"@\"."); public Diagnostic FunctionNotSupportedOperatorAvailable(string function, string @operator) => CoreError( "BCP069", diff --git a/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs b/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs index a1522230379..a7fe370712c 100644 --- a/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs +++ b/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs @@ -1937,7 +1937,7 @@ static IEnumerable GetResourceDerivedTypesTypeProperties() new TypeTemplate(LanguageConstants.TypeNameResource, [ new TypeParameter("ResourceTypeIdentifier", - "A string of the format '@' that identifies the kind of resource whose body type definition is to be used.", + "A string of the format `@` that identifies the kind of resource whose body type definition is to be used.", LanguageConstants.StringResourceIdentifier), ], (binder, syntax, argumentTypes) => diff --git a/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs b/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs index 3751f92b8ca..359a8efdf50 100644 --- a/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs +++ b/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs @@ -4869,7 +4869,7 @@ public async Task Resource_utility_type_offered_as_completion_if_enabled() var updated = file.ApplyCompletion(completions, "resource"); updated.Should().HaveSourceText(""" - type acct = resource<|> + type acct = resource<'|'> """); } diff --git a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs index 28f87e911ee..11df714cf2a 100644 --- a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs +++ b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using Azure.Deployments.Core.Comparers; using Bicep.Core; +using Bicep.Core.Analyzers.Linter.Common; using Bicep.Core.Diagnostics; using Bicep.Core.Emit; using Bicep.Core.Extensions; @@ -1750,9 +1751,11 @@ private static CompletionItem CreateTypeCompletion(string typeName, AmbientTypeS .WithDetail(type.Description ?? type.Name) .WithSortText(GetSortText(typeName, priority)); - if (type.Type is TypeTemplate) + if (type.Type is TypeTemplate typeTemplate) { - builder = builder.WithSnippetEdit(replacementRange, $"{typeName}<$0>") + var needsQuotes = typeTemplate.Parameters.Length > 0 && typeTemplate.Parameters[0].Type?.IsString() == true; + var quote = needsQuotes ? "'" : string.Empty; + builder = builder.WithSnippetEdit(replacementRange, $"{typeName}<{quote}$0{quote}>") // parameterized types always require at least one argument, so automatically request signature help .WithCommand(new Command { Name = EditorCommands.SignatureHelp, Title = "signature help" }); } diff --git a/src/vs-bicep/Bicep.VSLanguageServerClient.IntegrationTests/ValidationTests.cs b/src/vs-bicep/Bicep.VSLanguageServerClient.IntegrationTests/ValidationTests.cs index b49f22fbcff..6410e3a2f95 100644 --- a/src/vs-bicep/Bicep.VSLanguageServerClient.IntegrationTests/ValidationTests.cs +++ b/src/vs-bicep/Bicep.VSLanguageServerClient.IntegrationTests/ValidationTests.cs @@ -39,7 +39,7 @@ public void Verify_Diagnostics() d.LineNumber == 3 && d.Column == 9)); Assert.IsTrue(diagnostics.Any( - d => d.Description.Contains(@"The resource type is not valid. Specify a valid resource type of format ""@"".") && + d => d.Description.Contains(@"The resource type is not valid. Specify a valid resource type of format ""@"".") && d.ErrorLevel == ErrorListErrorLevel.Error && d.LineNumber == 3 && d.Column == 9));