From f0470b85e309327a7ebde970efee5bd6060dc467 Mon Sep 17 00:00:00 2001 From: Jonny Eskew Date: Tue, 10 Dec 2024 17:32:54 -0500 Subject: [PATCH] Add `resourceInput<>` and `resourceOutput<>` utility types (#15825) Resolves #15183 This PR adds two new utility types (`resourceInput<>` and `resourceOutput<>`) and deprecates the existing `resource<>` utility types. These three utility types are all closely related but differ in which property flags they surface: - `resource<>` has the flags that were originally defined in the RP types artifact. This is generally not what people want. - `resourceInput<>` strips out all `WriteOnly` flags. This means that template authors can access properties on a `resourceInput<>`-typed parameter that would have previously raised a BCP077 diagnostic. - `resourceOutput<>` strips out all `ReadOnly` flags. Additionally, this PR allows the assignment of one `ReadOnly` property to another `ReadOnly` property without raising any BCP073 diagnostics. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15825) --- docs/experimental-features.md | 2 +- ...serDefinedDiscriminatedObjectUnionTests.cs | 30 +- .../UserDefinedTypeTests.cs | 237 +++++- .../InvalidResourceDerivedTypes_LF/main.bicep | 48 +- .../main.diagnostics.bicep | 91 ++- .../main.formatted.bicep | 48 +- .../main.symbols.bicep | 84 +-- .../main.syntax.bicep | 612 ++++++++-------- .../main.tokens.bicep | 324 ++++----- .../ResourceDerivedTypes_LF/main.bicep | 26 +- .../main.diagnostics.bicep | 26 +- .../main.formatted.bicep | 26 +- .../ResourceDerivedTypes_LF/main.ir.bicep | 126 ++-- .../ResourceDerivedTypes_LF/main.json | 54 +- .../main.sourcemap.bicep | 78 +- .../main.symbolicnames.json | 54 +- .../main.symbols.bicep | 44 +- .../ResourceDerivedTypes_LF/main.syntax.bicep | 686 +++++++++--------- .../ResourceDerivedTypes_LF/main.tokens.bicep | 398 +++++----- .../Diagnostics/ErrorBuilderTests.cs | 9 + .../Parsing/ParserTests.cs | 8 +- .../ResourceDerivedTypeResolverTests.cs | 132 +++- .../Utils/CompilationResultExtensions.cs | 9 +- .../Diagnostics/DiagnosticBuilder.cs | 22 + src/Bicep.Core/Emit/TemplateWriter.cs | 56 +- src/Bicep.Core/Intermediate/Expression.cs | 13 +- src/Bicep.Core/LanguageConstants.cs | 11 + src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs | 8 +- src/Bicep.Core/Semantics/AmbientTypeSymbol.cs | 5 +- .../Semantics/Namespaces/NamespaceResolver.cs | 4 +- .../Namespaces/SystemNamespaceType.cs | 78 +- .../TypeSystem/ArmTemplateTypeLoader.cs | 27 +- .../TypeSystem/DeclaredTypeManager.cs | 39 +- .../TypeSystem/ResourceDerivedTypeResolver.cs | 7 +- .../TypeSystem/ResourceDerivedTypeVariant.cs | 11 + .../TypeSystem/TypeAssignmentVisitor.cs | 19 +- src/Bicep.Core/TypeSystem/TypeHelper.cs | 10 + src/Bicep.Core/TypeSystem/TypeValidator.cs | 10 +- .../Types/IUnresolvedResourceDerivedType.cs | 2 + ...esolvedResourceDerivedPartialObjectType.cs | 12 +- .../Types/UnresolvedResourceDerivedType.cs | 10 +- .../CompletionTests.cs | 51 +- .../ExpressionAndTypeExtractorTests.cs | 10 +- .../SignatureHelpTests.cs | 6 +- .../TypeStringifierTests.cs | 18 +- .../Completions/BicepCompletionProvider.cs | 1 + .../Refactor/TypeStringifier.cs | 2 +- 47 files changed, 2085 insertions(+), 1499 deletions(-) create mode 100644 src/Bicep.Core/TypeSystem/ResourceDerivedTypeVariant.cs diff --git a/docs/experimental-features.md b/docs/experimental-features.md index c1f4e62208a..d4921b3f5d6 100644 --- a/docs/experimental-features.md +++ b/docs/experimental-features.md @@ -27,7 +27,7 @@ Enables local deployment capability. See [Bicep Local Providers](https://github. Enabling this feature makes the `name` property in the body of `module` declarations optional. When a `module` omits the `name` property with the feature enabled, the Bicep compiler will automatically generate an expression for the name of the resulting nested deployment in the JSON. If you specify the `name` property, the compiler will use the specified expression in the resulting JSON. For more information, see [Added optional module names as an experimental feature](https://github.com/Azure/bicep/pull/12600). ### `resourceDerivedTypes` -If enabled, templates can reuse resource types wherever a type is expected. For example, to declare a parameter `foo` that should be usable as the name of an Azure Storage account, the following syntax would be used: `param foo resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name`. **NB:** Because resource types may be inaccurate in some cases, no constraints other than the ARM type primitive will be enforced on resource derived types within the ARM deployment engine. Resource-derived types will be checked by Bicep at compile time, but violations will be emitted as warnings rather than errors. +If enabled, templates can reuse resource types wherever a type is expected. For example, to declare a parameter `foo` that should be usable as the name of an Azure Storage account, the following syntax would be used: `param foo resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name`. **NB:** Because resource types may be inaccurate in some cases, no constraints other than the ARM type primitive will be enforced on resource derived types within the ARM deployment engine. Resource-derived types will be checked by Bicep at compile time, but violations will be emitted as warnings rather than errors. ### `resourceTypedParamsAndOutputs` Enables the type for a parameter or output to be of type resource to make it easier to pass resource references between modules. This feature is only partially implemented. See [Simplifying resource referencing](https://github.com/azure/bicep/issues/2245). diff --git a/src/Bicep.Core.IntegrationTests/UserDefinedDiscriminatedObjectUnionTests.cs b/src/Bicep.Core.IntegrationTests/UserDefinedDiscriminatedObjectUnionTests.cs index fcd06ec0e70..98e44bd5052 100644 --- a/src/Bicep.Core.IntegrationTests/UserDefinedDiscriminatedObjectUnionTests.cs +++ b/src/Bicep.Core.IntegrationTests/UserDefinedDiscriminatedObjectUnionTests.cs @@ -704,7 +704,7 @@ public void User_defined_discriminated_objects_can_amend_resource_derived_discri new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), """ @discriminator('computeType') - type taggedUnion = resource<'Microsoft.MachineLearningServices/workspaces/computes@2020-04-01'>.properties + type taggedUnion = resourceInput<'Microsoft.MachineLearningServices/workspaces/computes@2020-04-01'>.properties | { computeType: 'foo', bar: string } """); @@ -716,43 +716,57 @@ public void User_defined_discriminated_objects_can_amend_resource_derived_discri "DataFactory": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/DataFactory" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/DataFactory" + } } }, "Databricks": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/Databricks" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/Databricks" + } } }, "VirtualMachine": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/VirtualMachine" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/VirtualMachine" + } } }, "AmlCompute": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/AmlCompute" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/AmlCompute" + } } }, "AKS": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/AKS" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/AKS" + } } }, "HDInsight": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/HDInsight" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/HDInsight" + } } }, "DataLakeAnalytics": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/DataLakeAnalytics" + "__bicep_resource_derived_type!": { + "source": "Microsoft.MachineLearningServices/workspaces/computes@2020-04-01#properties/properties/discriminator/mapping/DataLakeAnalytics" + } } }, "foo": { diff --git a/src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs b/src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs index d77608a9dee..9cae140dc9d 100644 --- a/src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs +++ b/src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs @@ -876,6 +876,28 @@ public void Parsing_incomplete_tuple_type_expressions_halts() [TestMethod] public void Resource_derived_type_should_compile_successfully() + { + var result = CompilationHelper.Compile(new UnitTests.ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + type myType = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + """); + + result.Template.Should().HaveValueAtPath("definitions", JToken.Parse($$""" + { + "myType": { + "type": "string", + "metadata": { + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } + } + } + } + """)); + } + + [TestMethod] + public void Legacy_resource_derived_type_should_compile_successfully() { var result = CompilationHelper.Compile(new UnitTests.ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), """ @@ -894,13 +916,38 @@ public void Resource_derived_type_should_compile_successfully() """)); } + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void Legacy_resource_derived_type_should_propmt_a_deprecation_warning_with_proposed_code_fixes(bool fullyQualified) + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + $"type myType = {(fullyQualified ? "sys." : "")}resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name"); + + result.Should().HaveDiagnostics(new[] + { + ("BCP409", DiagnosticLevel.Warning, "The 'resource<>' parameterized type has been deprecated. Please specify whether you want this type to correspond to the resource input or the resource output."), + }); + + var quickFix = result.Diagnostics.Single().Should().BeAssignableTo().Subject; + quickFix.Fixes.Should().HaveCount(2); + quickFix.Fixes.Where(f => f.IsPreferred).Should().HaveCount(1); + + result.ApplyCodeFix(quickFix.Fixes.Where(f => f.IsPreferred).Single()) + .Should().Be($"type myType = {(fullyQualified ? "sys." : "")}resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name"); + + result.ApplyCodeFix(quickFix.Fixes.Where(f => !f.IsPreferred).Single()) + .Should().Be($"type myType = {(fullyQualified ? "sys." : "")}resourceOutput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name"); + } + [TestMethod] public void Resource_derived_type_should_compile_successfully_with_namespace_qualified_syntax() { var result = CompilationHelper.Compile(new UnitTests.ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), """ var resource = 'foo' - type myType = sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + type myType = sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name """); result.Template.Should().HaveValueAtPath("definitions", JToken.Parse($$""" @@ -908,7 +955,9 @@ public void Resource_derived_type_should_compile_successfully_with_namespace_qua "myType": { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } } } @@ -1207,7 +1256,7 @@ public void Type_property_access_can_be_used_on_resource_derived_types() var result = CompilationHelper.Compile( new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("main.bicep", """ - type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name """)); result.Should().NotHaveAnyCompilationBlockingDiagnostics(); @@ -1215,7 +1264,9 @@ public void Type_property_access_can_be_used_on_resource_derived_types() { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } } """)); @@ -1229,7 +1280,7 @@ public void Type_property_access_resolves_refs_and_traverses_imports() @export() type myObject = { quux: int - saSku: resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.sku + saSku: resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.sku } """), ("main.bicep", """ @@ -1259,7 +1310,9 @@ public void Type_property_access_resolves_refs_and_traverses_imports() { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" + } } } """)); @@ -1379,7 +1432,7 @@ public void Type_additional_properties_access_can_be_used_on_resource_derived_ty var result = CompilationHelper.Compile( new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("main.bicep", """ - type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* + type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* """)); result.Should().NotHaveAnyCompilationBlockingDiagnostics(); @@ -1387,7 +1440,9 @@ public void Type_additional_properties_access_can_be_used_on_resource_derived_ty { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + } } } """)); @@ -1399,7 +1454,7 @@ public void Type_additional_properties_access_resolves_refs_and_traverses_import var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("types.bicep", """ type tagsDict = { - *: resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags + *: resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags } @export() @@ -1435,7 +1490,9 @@ public void Type_additional_properties_access_resolves_refs_and_traverses_import { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + } } } """)); @@ -1485,7 +1542,7 @@ public void Type_element_access_can_be_used_on_resource_derived_types() var result = CompilationHelper.Compile( new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("main.bicep", """ - type storageAccountName = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] + type storageAccountName = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] """)); result.Should().NotHaveAnyCompilationBlockingDiagnostics(); @@ -1493,7 +1550,9 @@ public void Type_element_access_can_be_used_on_resource_derived_types() { "type": "object", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + } } } """)); @@ -1505,7 +1564,7 @@ public void Type_element_access_resolves_refs_and_traverses_imports() var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("types.bicep", """ @export() - type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] + type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] @export() type strings = string[] @@ -1513,7 +1572,7 @@ public void Type_element_access_resolves_refs_and_traverses_imports() ("main.bicep", """ import * as types from 'types.bicep' - type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] + type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] type test = types.strings[] @@ -1534,7 +1593,9 @@ public void Type_element_access_resolves_refs_and_traverses_imports() { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items/properties/permissions/properties/keys/items" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items/properties/permissions/properties/keys/items" + } } } """)); @@ -1542,7 +1603,9 @@ public void Type_element_access_resolves_refs_and_traverses_imports() { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items/properties/permissions/properties/keys/items" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items/properties/permissions/properties/keys/items" + } } } """)); @@ -1553,7 +1616,7 @@ public void Using_a_complete_resource_body_as_a_type_should_not_throw_exception( { var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("main.bicep", """ - param subnets resource<'Microsoft.Network/virtualNetworks/subnets@2023-09-01'>[] + param subnets resourceInput<'Microsoft.Network/virtualNetworks/subnets@2023-09-01'>[] """)); result.Template.Should().BeNull(); @@ -1581,7 +1644,9 @@ public void Resource_derived_type_nullability_should_be_preserved_when_loading_f "foo": { "type": "string", "metadata": { - "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" + "{{LanguageConstants.MetadataResourceDerivedTypePropertyName}}": { + "{{LanguageConstants.MetadataResourceDerivedTypePointerPropertyName}}": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" + } }, "nullable": true } @@ -1599,7 +1664,7 @@ public void Issue_14869() var result = CompilationHelper.Compile( new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), ("main.bicep", """ - param container resource<'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-05-15'>.properties.resource.indexingPolicy + param container resourceInput<'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-05-15'>.properties.resource.indexingPolicy resource sa 'Microsoft.Storage/storageAccounts@2023-05-01' = { location: resourceGroup().location @@ -1624,4 +1689,138 @@ param container resource<'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/con ("BCP037", DiagnosticLevel.Warning, """The property "spatialIndexes" is not allowed on objects of type "AzureFilesIdentityBasedAuthentication". Permissible properties include "activeDirectoryProperties", "defaultSharePermission", "directoryServiceOptions". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues."""), }); } + + [TestMethod] + public void Parameterized_types_should_require_parameterization() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """type t = resourceInput"""); + + result.Should().HaveDiagnostics([ + ("BCP384", DiagnosticLevel.Error, """The "resourceInput" type requires 1 argument(s)."""), + ]); + } + + [TestMethod] + public void Resource_input_type_should_raise_no_diagnostic_when_resource_writeOnly_property_accessed() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + param orderProperties resourceInput<'Microsoft.Capacity/reservationOrders@2022-11-01'>.properties + + output orderScopeType string = orderProperties.appliedScopeType + """); + + result.Should().NotHaveAnyDiagnostics(); + } + + [TestMethod] + public void Legacy_resource_type_should_raise_diagnostic_when_resource_writeOnly_property_accessed() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + param orderProperties resource<'Microsoft.Capacity/reservationOrders@2022-11-01'>.properties + + output orderScopeType string = orderProperties.appliedScopeType + """); + + result.Should().HaveDiagnostics(new[] + { + ("BCP409", DiagnosticLevel.Warning, "The 'resource<>' parameterized type has been deprecated. Please specify whether you want this type to correspond to the resource input or the resource output."), + ("BCP077", DiagnosticLevel.Warning, """The property "appliedScopeType" on type "PurchaseRequestPropertiesOrReservationOrderProperties" is write-only. Write-only properties cannot be accessed."""), + }); + } + + [TestMethod] + public void Assignment_to_readOnly_property_diagnostic_should_be_raised_when_resource_output_is_assigned_to_resource_input() + { + var result = CompilationHelper.Compile(""" + param siteProperties object + + resource appService1 'Microsoft.Web/sites@2022-09-01' = { + name: 'name' + location: resourceGroup().location + properties: siteProperties + } + + resource appService2 'Microsoft.Web/sites@2022-09-01' = { + name: 'name2' + location: resourceGroup().location + properties: appService1.properties + } + """); + + result.Diagnostics.Should().NotBeNullOrEmpty(); + result.Diagnostics.Should().ContainDiagnostic( + "BCP073", + DiagnosticLevel.Warning, + """The property "availabilityState" is read-only. Expressions cannot be assigned to read-only properties. If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues.""" + ); + } + + [TestMethod] + public void Assignment_to_readOnly_property_diagnostic_should_not_be_raised_when_resourceInput_typed_param_is_assigned_to_resource_input() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + param siteProperties resourceInput<'Microsoft.Web/sites@2022-09-01'>.properties + + resource appService 'Microsoft.Web/sites@2022-09-01' = { + name: 'name' + location: resourceGroup().location + properties: siteProperties + } + """); + + result.Should().NotHaveAnyDiagnostics(); + } + + [TestMethod] + public void Assignment_to_readOnly_property_diagnostic_should_not_be_raised_when_resource_output_is_assigned_to_resourceOutput_typed_target() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + param siteProperties resourceInput<'Microsoft.Web/sites@2022-09-01'>.properties + + resource appService 'Microsoft.Web/sites@2022-09-01' = { + name: 'name' + location: resourceGroup().location + properties: siteProperties + } + + output siteProperties resourceOutput<'Microsoft.Web/sites@2022-09-01'>.properties = appService.properties + """); + + result.Should().NotHaveAnyDiagnostics(); + } + + [TestMethod] + public void Assignment_to_readOnly_property_diagnostic_should_be_raised_when_resource_output_is_assigned_to_resourceInput_typed_target() + { + var result = CompilationHelper.Compile( + new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)), + """ + param siteProperties resourceInput<'Microsoft.Web/sites@2022-09-01'>.properties + + resource appService 'Microsoft.Web/sites@2022-09-01' = { + name: 'name' + location: resourceGroup().location + properties: siteProperties + } + + output siteProperties resourceInput<'Microsoft.Web/sites@2022-09-01'>.properties = appService.properties + """); + + result.Diagnostics.Should().NotBeNullOrEmpty(); + result.Diagnostics.Should().ContainDiagnostic( + "BCP073", + DiagnosticLevel.Warning, + """The property "availabilityState" is read-only. Expressions cannot be assigned to read-only properties.""" + ); + } } diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.bicep index 7fbe0c5c694..99ab0a498fd 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.bicep @@ -1,38 +1,38 @@ -type invalid1 = resource - -type invalid2 = resource<> - -type invalid3 = resource<'abc', 'def'> -type invalid4 = resource -type invalid5 = resource<'Microsoft.Storage/storageAccounts'> -type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> -type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> -type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> -type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> -type invalid10 = resource<'abc' 'def'> -type invalid11 = resource<123> -type invalid12 = resource - -type thisIsWeird = resource + +type invalid3 = resourceInput<'abc', 'def'> +type invalid4 = resourceInput +type invalid5 = resourceInput<'Microsoft.Storage/storageAccounts'> +type invalid6 = resourceInput<'Microsoft.Storage/storageAccounts@'> +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> +type invalid8 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +type invalid9 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> +type invalid10 = resourceInput<'abc' 'def'> +type invalid11 = resourceInput<123> +type invalid12 = resourceInput + +type thisIsWeird = resourceInput > -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> @sealed() -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> type hello = { @discriminator('hi') - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> } -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type module mod 'modules/mod.json' = { name: 'mod' 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 9d4815e4ef5..24ebfd68975 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,65 +1,64 @@ -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) || +type invalid1 = resourceInput +//@[016:029) [BCP384 (Error)] The "resourceInput" type requires 1 argument(s). (bicep https://aka.ms/bicep/core-diagnostics#BCP384) |resourceInput| -type invalid2 = resource<> -//@[024:026) [BCP071 (Error)] Expected 1 argument, but got 0. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<>| +type invalid2 = resourceInput<> +//@[029:031) [BCP071 (Error)] Expected 1 argument, but got 0. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<>| -type invalid3 = resource<'abc', 'def'> -//@[024:038) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<'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'| -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@'| -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'| -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'| -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) || -type invalid11 = resource<123> -//@[026:029) [BCP070 (Error)] Argument of type "123" is not assignable to parameter of type "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP070) |123| -type invalid12 = resource -//@[025:042) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) || -//@[039:039) [BCP236 (Error)] Expected a new line or comma character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP236) || -//@[040:040) [BCP243 (Error)] Parentheses must contain exactly one expression. (bicep https://aka.ms/bicep/core-diagnostics#BCP243) || +type invalid3 = resourceInput<'abc', 'def'> +//@[029:043) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<'abc', 'def'>| +type invalid4 = resourceInput +//@[030:035) [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 = resourceInput<'Microsoft.Storage/storageAccounts'> +//@[030:065) [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 = resourceInput<'Microsoft.Storage/storageAccounts@'> +//@[030: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@'| +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> +//@[030:071) [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 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +//@[030:094) [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 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> +//@[030:077) [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 = resourceInput<'abc' 'def'> +//@[030:043) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) |<'abc' 'def'>| +//@[037:037) [BCP236 (Error)] Expected a new line or comma character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP236) || +type invalid11 = resourceInput<123> +//@[031:034) [BCP070 (Error)] Argument of type "123" is not assignable to parameter of type "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP070) |123| +type invalid12 = resourceInput +//@[030:047) [BCP071 (Error)] Expected 1 argument, but got 2. (bicep https://aka.ms/bicep/core-diagnostics#BCP071) || +//@[044:044) [BCP236 (Error)] Expected a new line or comma character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP236) || +//@[045:045) [BCP243 (Error)] Parentheses must contain exactly one expression. (bicep https://aka.ms/bicep/core-diagnostics#BCP243) || -type thisIsWeird = resource\n>| +type thisIsWeird = resourceInput\n>| */'Astronomer.Astro/organizations@2023-08-01-preview' /// > > -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> -//@[029:080) [BCP032 (Error)] The value must be a compile-time constant. (bicep https://aka.ms/bicep/core-diagnostics#BCP032) |'Microsoft.${'Storage'}/storageAccounts@2022-09-01'| +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +//@[034:085) [BCP032 (Error)] The value must be a compile-time constant. (bicep https://aka.ms/bicep/core-diagnostics#BCP032) |'Microsoft.${'Storage'}/storageAccounts@2022-09-01'| @sealed() //@[000:009) [BCP386 (Error)] The decorator "sealed" may not be used on statements whose declared type is a reference to a resource-derived type. (bicep https://aka.ms/bicep/core-diagnostics#BCP386) |@sealed()| -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> -//@[027:083) [BCP394 (Error)] Resource-derived type expressions must dereference a property within the resource body. Using the entire resource body type is not permitted. (bicep https://aka.ms/bicep/core-diagnostics#BCP394) |resource<'Microsoft.Storage/storageAccounts@2022-09-01'>| +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> +//@[027:088) [BCP394 (Error)] Resource-derived type expressions must dereference a property within the resource body. Using the entire resource body type is not permitted. (bicep https://aka.ms/bicep/core-diagnostics#BCP394) |resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>| type hello = { @discriminator('hi') //@[002:022) [BCP363 (Error)] The "discriminator" decorator can only be applied to object-only union types with unique member types. (bicep https://aka.ms/bicep/core-diagnostics#BCP363) |@discriminator('hi')| - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> -//@[007:068) [BCP394 (Error)] Resource-derived type expressions must dereference a property within the resource body. Using the entire resource body type is not permitted. (bicep https://aka.ms/bicep/core-diagnostics#BCP394) |resource<'Astronomer.Astro/organizations@2023-08-01-preview'>| + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> +//@[007:073) [BCP394 (Error)] Resource-derived type expressions must dereference a property within the resource body. Using the entire resource body type is not permitted. (bicep https://aka.ms/bicep/core-diagnostics#BCP394) |resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'>| } -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom -//@[083:086) [BCP053 (Error)] The type "Microsoft.Storage/storageAccounts" does not contain property "nom". Available properties include "apiVersion", "asserts", "eTag", "extendedLocation", "id", "identity", "kind", "location", "managedBy", "managedByExtended", "name", "plan", "properties", "scale", "sku", "tags", "type", "zones". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |nom| -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId -//@[105:112) [BCP083 (Error)] The type "AccessPolicyEntry" does not contain property "tenatId". Did you mean "tenantId"? (bicep https://aka.ms/bicep/core-diagnostics#BCP083) |tenatId| -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId -//@[086:089) [BCP390 (Error)] The array item type access operator ('[*]') can only be used with typed arrays. (bicep https://aka.ms/bicep/core-diagnostics#BCP390) |[*]| -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype -//@[109:114) [BCP083 (Error)] The type "ConnectionParameter" does not contain property "tyype". Did you mean "type"? (bicep https://aka.ms/bicep/core-diagnostics#BCP083) |tyype| -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type -//@[086:087) [BCP389 (Error)] The type "CustomApiPropertiesDefinition" does not declare an additional properties type. (bicep https://aka.ms/bicep/core-diagnostics#BCP389) |*| +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +//@[088:091) [BCP053 (Error)] The type "Microsoft.Storage/storageAccounts" does not contain property "nom". Available properties include "apiVersion", "asserts", "dependsOn", "eTag", "extendedLocation", "id", "identity", "kind", "location", "managedBy", "managedByExtended", "name", "plan", "properties", "scale", "sku", "tags", "type", "zones". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |nom| +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +//@[110:117) [BCP083 (Error)] The type "AccessPolicyEntry" does not contain property "tenatId". Did you mean "tenantId"? (bicep https://aka.ms/bicep/core-diagnostics#BCP083) |tenatId| +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +//@[091:094) [BCP390 (Error)] The array item type access operator ('[*]') can only be used with typed arrays. (bicep https://aka.ms/bicep/core-diagnostics#BCP390) |[*]| +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +//@[114:119) [BCP083 (Error)] The type "ConnectionParameter" does not contain property "tyype". Did you mean "type"? (bicep https://aka.ms/bicep/core-diagnostics#BCP083) |tyype| +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +//@[091:092) [BCP389 (Error)] The type "CustomApiPropertiesDefinition" does not declare an additional properties type. (bicep https://aka.ms/bicep/core-diagnostics#BCP389) |*| module mod 'modules/mod.json' = { //@[011:029) [BCP392 (Warning)] The supplied resource type identifier "not a valid resource type identifier" was not recognized as a valid resource type name. (bicep https://aka.ms/bicep/core-diagnostics#BCP392) |'modules/mod.json'| diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.formatted.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.formatted.bicep index 4f5b4613770..2d8df0f9165 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.formatted.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.formatted.bicep @@ -1,39 +1,39 @@ -type invalid1 = resource - -type invalid2 = resource<> - -type invalid3 = resource<'abc', 'def'> -type invalid4 = resource -type invalid5 = resource<'Microsoft.Storage/storageAccounts'> -type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> -type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> -type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> -type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> -type invalid10 = resource<'abc' 'def'> -type invalid11 = resource<123> -type invalid12 = resource - -type thisIsWeird = resource< +type invalid1 = resourceInput + +type invalid2 = resourceInput<> + +type invalid3 = resourceInput<'abc', 'def'> +type invalid4 = resourceInput +type invalid5 = resourceInput<'Microsoft.Storage/storageAccounts'> +type invalid6 = resourceInput<'Microsoft.Storage/storageAccounts@'> +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> +type invalid8 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +type invalid9 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> +type invalid10 = resourceInput<'abc' 'def'> +type invalid11 = resourceInput<123> +type invalid12 = resourceInput + +type thisIsWeird = resourceInput< /* */ 'Astronomer.Astro/organizations@2023-08-01-preview' /// > > -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> @sealed() -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> type hello = { @discriminator('hi') - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> } -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type module mod 'modules/mod.json' = { name: 'mod' diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.symbols.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.symbols.bicep index 9520a3f1f05..fc28f172d9d 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.symbols.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.symbols.bicep @@ -1,59 +1,59 @@ -type invalid1 = resource -//@[5:13) TypeAlias invalid1. Type: error. Declaration start char: 0, length: 24 +type invalid1 = resourceInput +//@[5:13) TypeAlias invalid1. Type: error. Declaration start char: 0, length: 29 -type invalid2 = resource<> -//@[5:13) TypeAlias invalid2. Type: error. Declaration start char: 0, length: 26 +type invalid2 = resourceInput<> +//@[5:13) TypeAlias invalid2. Type: error. Declaration start char: 0, length: 31 -type invalid3 = resource<'abc', 'def'> -//@[5:13) TypeAlias invalid3. Type: error. Declaration start char: 0, length: 38 -type invalid4 = resource -//@[5:13) TypeAlias invalid4. Type: error. Declaration start char: 0, length: 31 -type invalid5 = resource<'Microsoft.Storage/storageAccounts'> -//@[5:13) TypeAlias invalid5. Type: error. Declaration start char: 0, length: 61 -type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> -//@[5:13) TypeAlias invalid6. Type: error. Declaration start char: 0, length: 62 -type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> -//@[5:13) TypeAlias invalid7. Type: error. Declaration start char: 0, length: 67 -type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> -//@[5:13) TypeAlias invalid8. Type: error. Declaration start char: 0, length: 90 -type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> -//@[5:13) TypeAlias invalid9. Type: error. Declaration start char: 0, length: 73 -type invalid10 = resource<'abc' 'def'> -//@[5:14) TypeAlias invalid10. Type: error. Declaration start char: 0, length: 38 -type invalid11 = resource<123> -//@[5:14) TypeAlias invalid11. Type: error. Declaration start char: 0, length: 30 -type invalid12 = resource -//@[5:14) TypeAlias invalid12. Type: error. Declaration start char: 0, length: 42 +type invalid3 = resourceInput<'abc', 'def'> +//@[5:13) TypeAlias invalid3. Type: error. Declaration start char: 0, length: 43 +type invalid4 = resourceInput +//@[5:13) TypeAlias invalid4. Type: error. Declaration start char: 0, length: 36 +type invalid5 = resourceInput<'Microsoft.Storage/storageAccounts'> +//@[5:13) TypeAlias invalid5. Type: error. Declaration start char: 0, length: 66 +type invalid6 = resourceInput<'Microsoft.Storage/storageAccounts@'> +//@[5:13) TypeAlias invalid6. Type: error. Declaration start char: 0, length: 67 +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> +//@[5:13) TypeAlias invalid7. Type: error. Declaration start char: 0, length: 72 +type invalid8 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +//@[5:13) TypeAlias invalid8. Type: error. Declaration start char: 0, length: 95 +type invalid9 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> +//@[5:13) TypeAlias invalid9. Type: error. Declaration start char: 0, length: 78 +type invalid10 = resourceInput<'abc' 'def'> +//@[5:14) TypeAlias invalid10. Type: error. Declaration start char: 0, length: 43 +type invalid11 = resourceInput<123> +//@[5:14) TypeAlias invalid11. Type: error. Declaration start char: 0, length: 35 +type invalid12 = resourceInput +//@[5:14) TypeAlias invalid12. Type: error. Declaration start char: 0, length: 47 -type thisIsWeird = resource. Declaration start char: 0, length: 93 +type thisIsWeird = resourceInput. Declaration start char: 0, length: 98 */'Astronomer.Astro/organizations@2023-08-01-preview' /// > > -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> -//@[5:17) TypeAlias interpolated. Type: error. Declaration start char: 0, length: 81 +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +//@[5:17) TypeAlias interpolated. Type: error. Declaration start char: 0, length: 86 @sealed() -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> -//@[5:24) TypeAlias shouldNotBeSealable. Type: Type. Declaration start char: 0, length: 93 +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> +//@[5:24) TypeAlias shouldNotBeSealable. Type: Type. Declaration start char: 0, length: 98 type hello = { -//@[5:10) TypeAlias hello. Type: Type<{ bar: Astronomer.Astro/organizations }>. Declaration start char: 0, length: 108 +//@[5:10) TypeAlias hello. Type: Type<{ bar: Astronomer.Astro/organizations }>. Declaration start char: 0, length: 113 @discriminator('hi') - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> } -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom -//@[5:23) TypeAlias typoInPropertyName. Type: error. Declaration start char: 0, length: 86 -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId -//@[5:24) TypeAlias typoInPropertyName2. Type: error. Declaration start char: 0, length: 112 -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId -//@[5:24) TypeAlias typoInPropertyName3. Type: error. Declaration start char: 0, length: 113 -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype -//@[5:24) TypeAlias typoInPropertyName4. Type: error. Declaration start char: 0, length: 114 -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type -//@[5:24) TypeAlias typoInPropertyName5. Type: error. Declaration start char: 0, length: 113 +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +//@[5:23) TypeAlias typoInPropertyName. Type: error. Declaration start char: 0, length: 91 +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +//@[5:24) TypeAlias typoInPropertyName2. Type: error. Declaration start char: 0, length: 117 +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +//@[5:24) TypeAlias typoInPropertyName3. Type: error. Declaration start char: 0, length: 118 +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +//@[5:24) TypeAlias typoInPropertyName4. Type: error. Declaration start char: 0, length: 119 +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +//@[5:24) TypeAlias typoInPropertyName5. Type: error. Declaration start char: 0, length: 118 module mod 'modules/mod.json' = { //@[7:10) Module mod. Type: module. Declaration start char: 0, length: 77 diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.syntax.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.syntax.bicep index 1e04c5900e5..7a3fb6ce5a8 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.syntax.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.syntax.bicep @@ -1,205 +1,205 @@ -type invalid1 = resource -//@[000:1602) ProgramSyntax -//@[000:0024) ├─TypeDeclarationSyntax +type invalid1 = resourceInput +//@[000:1707) ProgramSyntax +//@[000:0029) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid1| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0024) | └─ResourceTypeSyntax -//@[016:0024) | ├─Token(Identifier) |resource| -//@[024:0024) | └─SkippedTriviaSyntax -//@[024:0026) ├─Token(NewLine) |\n\n| +//@[016:0029) | └─TypeVariableAccessSyntax +//@[016:0029) | └─IdentifierSyntax +//@[016:0029) | └─Token(Identifier) |resourceInput| +//@[029:0031) ├─Token(NewLine) |\n\n| -type invalid2 = resource<> -//@[000:0026) ├─TypeDeclarationSyntax +type invalid2 = resourceInput<> +//@[000:0031) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid2| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0026) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0026) | └─Token(RightChevron) |>| -//@[026:0028) ├─Token(NewLine) |\n\n| +//@[016:0031) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0031) | └─Token(RightChevron) |>| +//@[031:0033) ├─Token(NewLine) |\n\n| -type invalid3 = resource<'abc', 'def'> -//@[000:0038) ├─TypeDeclarationSyntax +type invalid3 = resourceInput<'abc', 'def'> +//@[000:0043) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid3| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0038) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0030) | ├─ParameterizedTypeArgumentSyntax -//@[025:0030) | | └─StringTypeLiteralSyntax -//@[025:0030) | | └─Token(StringComplete) |'abc'| -//@[030:0031) | ├─Token(Comma) |,| -//@[032:0037) | ├─ParameterizedTypeArgumentSyntax -//@[032:0037) | | └─StringTypeLiteralSyntax -//@[032:0037) | | └─Token(StringComplete) |'def'| -//@[037:0038) | └─Token(RightChevron) |>| -//@[038:0039) ├─Token(NewLine) |\n| -type invalid4 = resource -//@[000:0031) ├─TypeDeclarationSyntax +//@[016:0043) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0035) | ├─ParameterizedTypeArgumentSyntax +//@[030:0035) | | └─StringTypeLiteralSyntax +//@[030:0035) | | └─Token(StringComplete) |'abc'| +//@[035:0036) | ├─Token(Comma) |,| +//@[037:0042) | ├─ParameterizedTypeArgumentSyntax +//@[037:0042) | | └─StringTypeLiteralSyntax +//@[037:0042) | | └─Token(StringComplete) |'def'| +//@[042:0043) | └─Token(RightChevron) |>| +//@[043:0044) ├─Token(NewLine) |\n| +type invalid4 = resourceInput +//@[000:0036) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid4| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0031) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0030) | ├─ParameterizedTypeArgumentSyntax -//@[025:0030) | | └─TypeVariableAccessSyntax -//@[025:0030) | | └─IdentifierSyntax -//@[025:0030) | | └─Token(Identifier) |hello| -//@[030:0031) | └─Token(RightChevron) |>| -//@[031:0032) ├─Token(NewLine) |\n| -type invalid5 = resource<'Microsoft.Storage/storageAccounts'> -//@[000:0061) ├─TypeDeclarationSyntax +//@[016:0036) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0035) | ├─ParameterizedTypeArgumentSyntax +//@[030:0035) | | └─TypeVariableAccessSyntax +//@[030:0035) | | └─IdentifierSyntax +//@[030:0035) | | └─Token(Identifier) |hello| +//@[035:0036) | └─Token(RightChevron) |>| +//@[036:0037) ├─Token(NewLine) |\n| +type invalid5 = resourceInput<'Microsoft.Storage/storageAccounts'> +//@[000:0066) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid5| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0061) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0060) | ├─ParameterizedTypeArgumentSyntax -//@[025:0060) | | └─StringTypeLiteralSyntax -//@[025:0060) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts'| -//@[060:0061) | └─Token(RightChevron) |>| -//@[061:0062) ├─Token(NewLine) |\n| -type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> -//@[000:0062) ├─TypeDeclarationSyntax +//@[016:0066) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0065) | ├─ParameterizedTypeArgumentSyntax +//@[030:0065) | | └─StringTypeLiteralSyntax +//@[030:0065) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts'| +//@[065:0066) | └─Token(RightChevron) |>| +//@[066:0067) ├─Token(NewLine) |\n| +type invalid6 = resourceInput<'Microsoft.Storage/storageAccounts@'> +//@[000:0067) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid6| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0062) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0061) | ├─ParameterizedTypeArgumentSyntax -//@[025:0061) | | └─StringTypeLiteralSyntax -//@[025:0061) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@'| -//@[061:0062) | └─Token(RightChevron) |>| -//@[062:0063) ├─Token(NewLine) |\n| -type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> -//@[000:0067) ├─TypeDeclarationSyntax +//@[016:0067) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0066) | ├─ParameterizedTypeArgumentSyntax +//@[030:0066) | | └─StringTypeLiteralSyntax +//@[030:0066) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@'| +//@[066:0067) | └─Token(RightChevron) |>| +//@[067:0068) ├─Token(NewLine) |\n| +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> +//@[000:0072) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid7| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0067) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0066) | ├─ParameterizedTypeArgumentSyntax -//@[025:0066) | | └─StringTypeLiteralSyntax -//@[025:0066) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@hello'| -//@[066:0067) | └─Token(RightChevron) |>| -//@[067:0068) ├─Token(NewLine) |\n| -type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> -//@[000:0090) ├─TypeDeclarationSyntax +//@[016:0072) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0071) | ├─ParameterizedTypeArgumentSyntax +//@[030:0071) | | └─StringTypeLiteralSyntax +//@[030:0071) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@hello'| +//@[071:0072) | └─Token(RightChevron) |>| +//@[072:0073) ├─Token(NewLine) |\n| +type invalid8 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +//@[000:0095) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid8| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0090) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0089) | ├─ParameterizedTypeArgumentSyntax -//@[025:0089) | | └─StringTypeLiteralSyntax -//@[025:0089) | | └─Token(StringComplete) |'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'| -//@[089:0090) | └─Token(RightChevron) |>| -//@[090:0091) ├─Token(NewLine) |\n| -type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> -//@[000:0073) ├─TypeDeclarationSyntax +//@[016:0095) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0094) | ├─ParameterizedTypeArgumentSyntax +//@[030:0094) | | └─StringTypeLiteralSyntax +//@[030:0094) | | └─Token(StringComplete) |'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'| +//@[094:0095) | └─Token(RightChevron) |>| +//@[095:0096) ├─Token(NewLine) |\n| +type invalid9 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> +//@[000:0078) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0013) | ├─IdentifierSyntax //@[005:0013) | | └─Token(Identifier) |invalid9| //@[014:0015) | ├─Token(Assignment) |=| -//@[016:0073) | └─ParameterizedTypeInstantiationSyntax -//@[016:0024) | ├─IdentifierSyntax -//@[016:0024) | | └─Token(Identifier) |resource| -//@[024:0025) | ├─Token(LeftChevron) |<| -//@[025:0072) | ├─ParameterizedTypeArgumentSyntax -//@[025:0072) | | └─StringTypeLiteralSyntax -//@[025:0072) | | └─Token(StringComplete) |':Microsoft.Storage/storageAccounts@2022-09-01'| -//@[072:0073) | └─Token(RightChevron) |>| -//@[073:0074) ├─Token(NewLine) |\n| -type invalid10 = resource<'abc' 'def'> -//@[000:0038) ├─TypeDeclarationSyntax +//@[016:0078) | └─ParameterizedTypeInstantiationSyntax +//@[016:0029) | ├─IdentifierSyntax +//@[016:0029) | | └─Token(Identifier) |resourceInput| +//@[029:0030) | ├─Token(LeftChevron) |<| +//@[030:0077) | ├─ParameterizedTypeArgumentSyntax +//@[030:0077) | | └─StringTypeLiteralSyntax +//@[030:0077) | | └─Token(StringComplete) |':Microsoft.Storage/storageAccounts@2022-09-01'| +//@[077:0078) | └─Token(RightChevron) |>| +//@[078:0079) ├─Token(NewLine) |\n| +type invalid10 = resourceInput<'abc' 'def'> +//@[000:0043) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0014) | ├─IdentifierSyntax //@[005:0014) | | └─Token(Identifier) |invalid10| //@[015:0016) | ├─Token(Assignment) |=| -//@[017:0038) | └─ParameterizedTypeInstantiationSyntax -//@[017:0025) | ├─IdentifierSyntax -//@[017:0025) | | └─Token(Identifier) |resource| -//@[025:0026) | ├─Token(LeftChevron) |<| -//@[026:0031) | ├─ParameterizedTypeArgumentSyntax -//@[026:0031) | | └─StringTypeLiteralSyntax -//@[026:0031) | | └─Token(StringComplete) |'abc'| -//@[032:0032) | ├─SkippedTriviaSyntax -//@[032:0037) | ├─ParameterizedTypeArgumentSyntax -//@[032:0037) | | └─StringTypeLiteralSyntax -//@[032:0037) | | └─Token(StringComplete) |'def'| -//@[037:0038) | └─Token(RightChevron) |>| -//@[038:0039) ├─Token(NewLine) |\n| -type invalid11 = resource<123> -//@[000:0030) ├─TypeDeclarationSyntax +//@[017:0043) | └─ParameterizedTypeInstantiationSyntax +//@[017:0030) | ├─IdentifierSyntax +//@[017:0030) | | └─Token(Identifier) |resourceInput| +//@[030:0031) | ├─Token(LeftChevron) |<| +//@[031:0036) | ├─ParameterizedTypeArgumentSyntax +//@[031:0036) | | └─StringTypeLiteralSyntax +//@[031:0036) | | └─Token(StringComplete) |'abc'| +//@[037:0037) | ├─SkippedTriviaSyntax +//@[037:0042) | ├─ParameterizedTypeArgumentSyntax +//@[037:0042) | | └─StringTypeLiteralSyntax +//@[037:0042) | | └─Token(StringComplete) |'def'| +//@[042:0043) | └─Token(RightChevron) |>| +//@[043:0044) ├─Token(NewLine) |\n| +type invalid11 = resourceInput<123> +//@[000:0035) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0014) | ├─IdentifierSyntax //@[005:0014) | | └─Token(Identifier) |invalid11| //@[015:0016) | ├─Token(Assignment) |=| -//@[017:0030) | └─ParameterizedTypeInstantiationSyntax -//@[017:0025) | ├─IdentifierSyntax -//@[017:0025) | | └─Token(Identifier) |resource| -//@[025:0026) | ├─Token(LeftChevron) |<| -//@[026:0029) | ├─ParameterizedTypeArgumentSyntax -//@[026:0029) | | └─IntegerTypeLiteralSyntax -//@[026:0029) | | └─Token(Integer) |123| -//@[029:0030) | └─Token(RightChevron) |>| -//@[030:0031) ├─Token(NewLine) |\n| -type invalid12 = resource -//@[000:0042) ├─TypeDeclarationSyntax +//@[017:0035) | └─ParameterizedTypeInstantiationSyntax +//@[017:0030) | ├─IdentifierSyntax +//@[017:0030) | | └─Token(Identifier) |resourceInput| +//@[030:0031) | ├─Token(LeftChevron) |<| +//@[031:0034) | ├─ParameterizedTypeArgumentSyntax +//@[031:0034) | | └─IntegerTypeLiteralSyntax +//@[031:0034) | | └─Token(Integer) |123| +//@[034:0035) | └─Token(RightChevron) |>| +//@[035:0036) ├─Token(NewLine) |\n| +type invalid12 = resourceInput +//@[000:0047) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0014) | ├─IdentifierSyntax //@[005:0014) | | └─Token(Identifier) |invalid12| //@[015:0016) | ├─Token(Assignment) |=| -//@[017:0042) | └─ParameterizedTypeInstantiationSyntax -//@[017:0025) | ├─IdentifierSyntax -//@[017:0025) | | └─Token(Identifier) |resource| -//@[025:0026) | ├─Token(LeftChevron) |<| -//@[026:0039) | ├─ParameterizedTypeArgumentSyntax -//@[026:0039) | | └─TypeVariableAccessSyntax -//@[026:0039) | | └─IdentifierSyntax -//@[026:0039) | | └─Token(Identifier) |resourceGroup| -//@[039:0039) | ├─SkippedTriviaSyntax -//@[039:0041) | ├─ParameterizedTypeArgumentSyntax -//@[039:0041) | | └─ParenthesizedTypeSyntax -//@[039:0040) | | ├─Token(LeftParen) |(| -//@[040:0040) | | ├─SkippedTriviaSyntax -//@[040:0041) | | └─Token(RightParen) |)| -//@[041:0042) | └─Token(RightChevron) |>| -//@[042:0044) ├─Token(NewLine) |\n\n| +//@[017:0047) | └─ParameterizedTypeInstantiationSyntax +//@[017:0030) | ├─IdentifierSyntax +//@[017:0030) | | └─Token(Identifier) |resourceInput| +//@[030:0031) | ├─Token(LeftChevron) |<| +//@[031:0044) | ├─ParameterizedTypeArgumentSyntax +//@[031:0044) | | └─TypeVariableAccessSyntax +//@[031:0044) | | └─IdentifierSyntax +//@[031:0044) | | └─Token(Identifier) |resourceGroup| +//@[044:0044) | ├─SkippedTriviaSyntax +//@[044:0046) | ├─ParameterizedTypeArgumentSyntax +//@[044:0046) | | └─ParenthesizedTypeSyntax +//@[044:0045) | | ├─Token(LeftParen) |(| +//@[045:0045) | | ├─SkippedTriviaSyntax +//@[045:0046) | | └─Token(RightParen) |)| +//@[046:0047) | └─Token(RightChevron) |>| +//@[047:0049) ├─Token(NewLine) |\n\n| -type thisIsWeird = resource| //@[001:0003) ├─Token(NewLine) |\n\n| -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> -//@[000:0081) ├─TypeDeclarationSyntax +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +//@[000:0086) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0017) | ├─IdentifierSyntax //@[005:0017) | | └─Token(Identifier) |interpolated| //@[018:0019) | ├─Token(Assignment) |=| -//@[020:0081) | └─ParameterizedTypeInstantiationSyntax -//@[020:0028) | ├─IdentifierSyntax -//@[020:0028) | | └─Token(Identifier) |resource| -//@[028:0029) | ├─Token(LeftChevron) |<| -//@[029:0080) | ├─ParameterizedTypeArgumentSyntax -//@[029:0080) | | └─StringTypeLiteralSyntax -//@[029:0042) | | ├─Token(StringLeftPiece) |'Microsoft.${| -//@[042:0051) | | ├─StringSyntax -//@[042:0051) | | | └─Token(StringComplete) |'Storage'| -//@[051:0080) | | └─Token(StringRightPiece) |}/storageAccounts@2022-09-01'| -//@[080:0081) | └─Token(RightChevron) |>| -//@[081:0083) ├─Token(NewLine) |\n\n| +//@[020:0086) | └─ParameterizedTypeInstantiationSyntax +//@[020:0033) | ├─IdentifierSyntax +//@[020:0033) | | └─Token(Identifier) |resourceInput| +//@[033:0034) | ├─Token(LeftChevron) |<| +//@[034:0085) | ├─ParameterizedTypeArgumentSyntax +//@[034:0085) | | └─StringTypeLiteralSyntax +//@[034:0047) | | ├─Token(StringLeftPiece) |'Microsoft.${| +//@[047:0056) | | ├─StringSyntax +//@[047:0056) | | | └─Token(StringComplete) |'Storage'| +//@[056:0085) | | └─Token(StringRightPiece) |}/storageAccounts@2022-09-01'| +//@[085:0086) | └─Token(RightChevron) |>| +//@[086:0088) ├─Token(NewLine) |\n\n| @sealed() -//@[000:0093) ├─TypeDeclarationSyntax +//@[000:0098) ├─TypeDeclarationSyntax //@[000:0009) | ├─DecoratorSyntax //@[000:0001) | | ├─Token(At) |@| //@[001:0009) | | └─FunctionCallSyntax @@ -240,32 +240,32 @@ type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01' //@[007:0008) | | ├─Token(LeftParen) |(| //@[008:0009) | | └─Token(RightParen) |)| //@[009:0010) | ├─Token(NewLine) |\n| -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> //@[000:0004) | ├─Token(Identifier) |type| //@[005:0024) | ├─IdentifierSyntax //@[005:0024) | | └─Token(Identifier) |shouldNotBeSealable| //@[025:0026) | ├─Token(Assignment) |=| -//@[027:0083) | └─ParameterizedTypeInstantiationSyntax -//@[027:0035) | ├─IdentifierSyntax -//@[027:0035) | | └─Token(Identifier) |resource| -//@[035:0036) | ├─Token(LeftChevron) |<| -//@[036:0082) | ├─ParameterizedTypeArgumentSyntax -//@[036:0082) | | └─StringTypeLiteralSyntax -//@[036:0082) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2022-09-01'| -//@[082:0083) | └─Token(RightChevron) |>| -//@[083:0085) ├─Token(NewLine) |\n\n| +//@[027:0088) | └─ParameterizedTypeInstantiationSyntax +//@[027:0040) | ├─IdentifierSyntax +//@[027:0040) | | └─Token(Identifier) |resourceInput| +//@[040:0041) | ├─Token(LeftChevron) |<| +//@[041:0087) | ├─ParameterizedTypeArgumentSyntax +//@[041:0087) | | └─StringTypeLiteralSyntax +//@[041:0087) | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2022-09-01'| +//@[087:0088) | └─Token(RightChevron) |>| +//@[088:0090) ├─Token(NewLine) |\n\n| type hello = { -//@[000:0108) ├─TypeDeclarationSyntax +//@[000:0113) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0010) | ├─IdentifierSyntax //@[005:0010) | | └─Token(Identifier) |hello| //@[011:0012) | ├─Token(Assignment) |=| -//@[013:0108) | └─ObjectTypeSyntax +//@[013:0113) | └─ObjectTypeSyntax //@[013:0014) | ├─Token(LeftBrace) |{| //@[014:0015) | ├─Token(NewLine) |\n| @discriminator('hi') -//@[002:0091) | ├─ObjectTypePropertySyntax +//@[002:0096) | ├─ObjectTypePropertySyntax //@[002:0022) | | ├─DecoratorSyntax //@[002:0003) | | | ├─Token(At) |@| //@[003:0022) | | | └─FunctionCallSyntax @@ -277,164 +277,164 @@ type hello = { //@[017:0021) | | | | └─Token(StringComplete) |'hi'| //@[021:0022) | | | └─Token(RightParen) |)| //@[022:0023) | | ├─Token(NewLine) |\n| - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> //@[002:0005) | | ├─IdentifierSyntax //@[002:0005) | | | └─Token(Identifier) |bar| //@[005:0006) | | ├─Token(Colon) |:| -//@[007:0068) | | └─ParameterizedTypeInstantiationSyntax -//@[007:0015) | | ├─IdentifierSyntax -//@[007:0015) | | | └─Token(Identifier) |resource| -//@[015:0016) | | ├─Token(LeftChevron) |<| -//@[016:0067) | | ├─ParameterizedTypeArgumentSyntax -//@[016:0067) | | | └─StringTypeLiteralSyntax -//@[016:0067) | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[067:0068) | | └─Token(RightChevron) |>| -//@[068:0069) | ├─Token(NewLine) |\n| +//@[007:0073) | | └─ParameterizedTypeInstantiationSyntax +//@[007:0020) | | ├─IdentifierSyntax +//@[007:0020) | | | └─Token(Identifier) |resourceInput| +//@[020:0021) | | ├─Token(LeftChevron) |<| +//@[021:0072) | | ├─ParameterizedTypeArgumentSyntax +//@[021:0072) | | | └─StringTypeLiteralSyntax +//@[021:0072) | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[072:0073) | | └─Token(RightChevron) |>| +//@[073:0074) | ├─Token(NewLine) |\n| } //@[000:0001) | └─Token(RightBrace) |}| //@[001:0003) ├─Token(NewLine) |\n\n| -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom -//@[000:0086) ├─TypeDeclarationSyntax +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +//@[000:0091) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0023) | ├─IdentifierSyntax //@[005:0023) | | └─Token(Identifier) |typoInPropertyName| //@[024:0025) | ├─Token(Assignment) |=| -//@[026:0086) | └─TypePropertyAccessSyntax -//@[026:0082) | ├─ParameterizedTypeInstantiationSyntax -//@[026:0034) | | ├─IdentifierSyntax -//@[026:0034) | | | └─Token(Identifier) |resource| -//@[034:0035) | | ├─Token(LeftChevron) |<| -//@[035:0081) | | ├─ParameterizedTypeArgumentSyntax -//@[035:0081) | | | └─StringTypeLiteralSyntax -//@[035:0081) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[081:0082) | | └─Token(RightChevron) |>| -//@[082:0083) | ├─Token(Dot) |.| -//@[083:0086) | └─IdentifierSyntax -//@[083:0086) | └─Token(Identifier) |nom| -//@[086:0087) ├─Token(NewLine) |\n| -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId -//@[000:0112) ├─TypeDeclarationSyntax +//@[026:0091) | └─TypePropertyAccessSyntax +//@[026:0087) | ├─ParameterizedTypeInstantiationSyntax +//@[026:0039) | | ├─IdentifierSyntax +//@[026:0039) | | | └─Token(Identifier) |resourceInput| +//@[039:0040) | | ├─Token(LeftChevron) |<| +//@[040:0086) | | ├─ParameterizedTypeArgumentSyntax +//@[040:0086) | | | └─StringTypeLiteralSyntax +//@[040:0086) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:0087) | | └─Token(RightChevron) |>| +//@[087:0088) | ├─Token(Dot) |.| +//@[088:0091) | └─IdentifierSyntax +//@[088:0091) | └─Token(Identifier) |nom| +//@[091:0092) ├─Token(NewLine) |\n| +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +//@[000:0117) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0024) | ├─IdentifierSyntax //@[005:0024) | | └─Token(Identifier) |typoInPropertyName2| //@[025:0026) | ├─Token(Assignment) |=| -//@[027:0112) | └─TypePropertyAccessSyntax -//@[027:0104) | ├─TypeItemsAccessSyntax -//@[027:0101) | | ├─TypePropertyAccessSyntax -//@[027:0086) | | | ├─TypePropertyAccessSyntax -//@[027:0075) | | | | ├─ParameterizedTypeInstantiationSyntax -//@[027:0035) | | | | | ├─IdentifierSyntax -//@[027:0035) | | | | | | └─Token(Identifier) |resource| -//@[035:0036) | | | | | ├─Token(LeftChevron) |<| -//@[036:0074) | | | | | ├─ParameterizedTypeArgumentSyntax -//@[036:0074) | | | | | | └─StringTypeLiteralSyntax -//@[036:0074) | | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[074:0075) | | | | | └─Token(RightChevron) |>| -//@[075:0076) | | | | ├─Token(Dot) |.| -//@[076:0086) | | | | └─IdentifierSyntax -//@[076:0086) | | | | └─Token(Identifier) |properties| -//@[086:0087) | | | ├─Token(Dot) |.| -//@[087:0101) | | | └─IdentifierSyntax -//@[087:0101) | | | └─Token(Identifier) |accessPolicies| -//@[101:0102) | | ├─Token(LeftSquare) |[| -//@[102:0103) | | ├─Token(Asterisk) |*| -//@[103:0104) | | └─Token(RightSquare) |]| -//@[104:0105) | ├─Token(Dot) |.| -//@[105:0112) | └─IdentifierSyntax -//@[105:0112) | └─Token(Identifier) |tenatId| -//@[112:0113) ├─Token(NewLine) |\n| -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId -//@[000:0113) ├─TypeDeclarationSyntax +//@[027:0117) | └─TypePropertyAccessSyntax +//@[027:0109) | ├─TypeItemsAccessSyntax +//@[027:0106) | | ├─TypePropertyAccessSyntax +//@[027:0091) | | | ├─TypePropertyAccessSyntax +//@[027:0080) | | | | ├─ParameterizedTypeInstantiationSyntax +//@[027:0040) | | | | | ├─IdentifierSyntax +//@[027:0040) | | | | | | └─Token(Identifier) |resourceInput| +//@[040:0041) | | | | | ├─Token(LeftChevron) |<| +//@[041:0079) | | | | | ├─ParameterizedTypeArgumentSyntax +//@[041:0079) | | | | | | └─StringTypeLiteralSyntax +//@[041:0079) | | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[079:0080) | | | | | └─Token(RightChevron) |>| +//@[080:0081) | | | | ├─Token(Dot) |.| +//@[081:0091) | | | | └─IdentifierSyntax +//@[081:0091) | | | | └─Token(Identifier) |properties| +//@[091:0092) | | | ├─Token(Dot) |.| +//@[092:0106) | | | └─IdentifierSyntax +//@[092:0106) | | | └─Token(Identifier) |accessPolicies| +//@[106:0107) | | ├─Token(LeftSquare) |[| +//@[107:0108) | | ├─Token(Asterisk) |*| +//@[108:0109) | | └─Token(RightSquare) |]| +//@[109:0110) | ├─Token(Dot) |.| +//@[110:0117) | └─IdentifierSyntax +//@[110:0117) | └─Token(Identifier) |tenatId| +//@[117:0118) ├─Token(NewLine) |\n| +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +//@[000:0118) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0024) | ├─IdentifierSyntax //@[005:0024) | | └─Token(Identifier) |typoInPropertyName3| //@[025:0026) | ├─Token(Assignment) |=| -//@[027:0113) | └─TypePropertyAccessSyntax -//@[027:0104) | ├─TypePropertyAccessSyntax -//@[027:0089) | | ├─TypeItemsAccessSyntax -//@[027:0086) | | | ├─TypePropertyAccessSyntax -//@[027:0075) | | | | ├─ParameterizedTypeInstantiationSyntax -//@[027:0035) | | | | | ├─IdentifierSyntax -//@[027:0035) | | | | | | └─Token(Identifier) |resource| -//@[035:0036) | | | | | ├─Token(LeftChevron) |<| -//@[036:0074) | | | | | ├─ParameterizedTypeArgumentSyntax -//@[036:0074) | | | | | | └─StringTypeLiteralSyntax -//@[036:0074) | | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[074:0075) | | | | | └─Token(RightChevron) |>| -//@[075:0076) | | | | ├─Token(Dot) |.| -//@[076:0086) | | | | └─IdentifierSyntax -//@[076:0086) | | | | └─Token(Identifier) |properties| -//@[086:0087) | | | ├─Token(LeftSquare) |[| -//@[087:0088) | | | ├─Token(Asterisk) |*| -//@[088:0089) | | | └─Token(RightSquare) |]| -//@[089:0090) | | ├─Token(Dot) |.| -//@[090:0104) | | └─IdentifierSyntax -//@[090:0104) | | └─Token(Identifier) |accessPolicies| -//@[104:0105) | ├─Token(Dot) |.| -//@[105:0113) | └─IdentifierSyntax -//@[105:0113) | └─Token(Identifier) |tenantId| -//@[113:0114) ├─Token(NewLine) |\n| -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype -//@[000:0114) ├─TypeDeclarationSyntax +//@[027:0118) | └─TypePropertyAccessSyntax +//@[027:0109) | ├─TypePropertyAccessSyntax +//@[027:0094) | | ├─TypeItemsAccessSyntax +//@[027:0091) | | | ├─TypePropertyAccessSyntax +//@[027:0080) | | | | ├─ParameterizedTypeInstantiationSyntax +//@[027:0040) | | | | | ├─IdentifierSyntax +//@[027:0040) | | | | | | └─Token(Identifier) |resourceInput| +//@[040:0041) | | | | | ├─Token(LeftChevron) |<| +//@[041:0079) | | | | | ├─ParameterizedTypeArgumentSyntax +//@[041:0079) | | | | | | └─StringTypeLiteralSyntax +//@[041:0079) | | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[079:0080) | | | | | └─Token(RightChevron) |>| +//@[080:0081) | | | | ├─Token(Dot) |.| +//@[081:0091) | | | | └─IdentifierSyntax +//@[081:0091) | | | | └─Token(Identifier) |properties| +//@[091:0092) | | | ├─Token(LeftSquare) |[| +//@[092:0093) | | | ├─Token(Asterisk) |*| +//@[093:0094) | | | └─Token(RightSquare) |]| +//@[094:0095) | | ├─Token(Dot) |.| +//@[095:0109) | | └─IdentifierSyntax +//@[095:0109) | | └─Token(Identifier) |accessPolicies| +//@[109:0110) | ├─Token(Dot) |.| +//@[110:0118) | └─IdentifierSyntax +//@[110:0118) | └─Token(Identifier) |tenantId| +//@[118:0119) ├─Token(NewLine) |\n| +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +//@[000:0119) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0024) | ├─IdentifierSyntax //@[005:0024) | | └─Token(Identifier) |typoInPropertyName4| //@[025:0026) | ├─Token(Assignment) |=| -//@[027:0114) | └─TypePropertyAccessSyntax -//@[027:0108) | ├─TypeAdditionalPropertiesAccessSyntax -//@[027:0106) | | ├─TypePropertyAccessSyntax -//@[027:0085) | | | ├─TypePropertyAccessSyntax -//@[027:0074) | | | | ├─ParameterizedTypeInstantiationSyntax -//@[027:0035) | | | | | ├─IdentifierSyntax -//@[027:0035) | | | | | | └─Token(Identifier) |resource| -//@[035:0036) | | | | | ├─Token(LeftChevron) |<| -//@[036:0073) | | | | | ├─ParameterizedTypeArgumentSyntax -//@[036:0073) | | | | | | └─StringTypeLiteralSyntax -//@[036:0073) | | | | | | └─Token(StringComplete) |'Microsoft.Web/customApis@2016-06-01'| -//@[073:0074) | | | | | └─Token(RightChevron) |>| -//@[074:0075) | | | | ├─Token(Dot) |.| -//@[075:0085) | | | | └─IdentifierSyntax -//@[075:0085) | | | | └─Token(Identifier) |properties| -//@[085:0086) | | | ├─Token(Dot) |.| -//@[086:0106) | | | └─IdentifierSyntax -//@[086:0106) | | | └─Token(Identifier) |connectionParameters| -//@[106:0107) | | ├─Token(Dot) |.| -//@[107:0108) | | └─Token(Asterisk) |*| -//@[108:0109) | ├─Token(Dot) |.| -//@[109:0114) | └─IdentifierSyntax -//@[109:0114) | └─Token(Identifier) |tyype| -//@[114:0115) ├─Token(NewLine) |\n| -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type -//@[000:0113) ├─TypeDeclarationSyntax +//@[027:0119) | └─TypePropertyAccessSyntax +//@[027:0113) | ├─TypeAdditionalPropertiesAccessSyntax +//@[027:0111) | | ├─TypePropertyAccessSyntax +//@[027:0090) | | | ├─TypePropertyAccessSyntax +//@[027:0079) | | | | ├─ParameterizedTypeInstantiationSyntax +//@[027:0040) | | | | | ├─IdentifierSyntax +//@[027:0040) | | | | | | └─Token(Identifier) |resourceInput| +//@[040:0041) | | | | | ├─Token(LeftChevron) |<| +//@[041:0078) | | | | | ├─ParameterizedTypeArgumentSyntax +//@[041:0078) | | | | | | └─StringTypeLiteralSyntax +//@[041:0078) | | | | | | └─Token(StringComplete) |'Microsoft.Web/customApis@2016-06-01'| +//@[078:0079) | | | | | └─Token(RightChevron) |>| +//@[079:0080) | | | | ├─Token(Dot) |.| +//@[080:0090) | | | | └─IdentifierSyntax +//@[080:0090) | | | | └─Token(Identifier) |properties| +//@[090:0091) | | | ├─Token(Dot) |.| +//@[091:0111) | | | └─IdentifierSyntax +//@[091:0111) | | | └─Token(Identifier) |connectionParameters| +//@[111:0112) | | ├─Token(Dot) |.| +//@[112:0113) | | └─Token(Asterisk) |*| +//@[113:0114) | ├─Token(Dot) |.| +//@[114:0119) | └─IdentifierSyntax +//@[114:0119) | └─Token(Identifier) |tyype| +//@[119:0120) ├─Token(NewLine) |\n| +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +//@[000:0118) ├─TypeDeclarationSyntax //@[000:0004) | ├─Token(Identifier) |type| //@[005:0024) | ├─IdentifierSyntax //@[005:0024) | | └─Token(Identifier) |typoInPropertyName5| //@[025:0026) | ├─Token(Assignment) |=| -//@[027:0113) | └─TypePropertyAccessSyntax -//@[027:0108) | ├─TypePropertyAccessSyntax -//@[027:0087) | | ├─TypeAdditionalPropertiesAccessSyntax -//@[027:0085) | | | ├─TypePropertyAccessSyntax -//@[027:0074) | | | | ├─ParameterizedTypeInstantiationSyntax -//@[027:0035) | | | | | ├─IdentifierSyntax -//@[027:0035) | | | | | | └─Token(Identifier) |resource| -//@[035:0036) | | | | | ├─Token(LeftChevron) |<| -//@[036:0073) | | | | | ├─ParameterizedTypeArgumentSyntax -//@[036:0073) | | | | | | └─StringTypeLiteralSyntax -//@[036:0073) | | | | | | └─Token(StringComplete) |'Microsoft.Web/customApis@2016-06-01'| -//@[073:0074) | | | | | └─Token(RightChevron) |>| -//@[074:0075) | | | | ├─Token(Dot) |.| -//@[075:0085) | | | | └─IdentifierSyntax -//@[075:0085) | | | | └─Token(Identifier) |properties| -//@[085:0086) | | | ├─Token(Dot) |.| -//@[086:0087) | | | └─Token(Asterisk) |*| -//@[087:0088) | | ├─Token(Dot) |.| -//@[088:0108) | | └─IdentifierSyntax -//@[088:0108) | | └─Token(Identifier) |connectionParameters| -//@[108:0109) | ├─Token(Dot) |.| -//@[109:0113) | └─IdentifierSyntax -//@[109:0113) | └─Token(Identifier) |type| -//@[113:0115) ├─Token(NewLine) |\n\n| +//@[027:0118) | └─TypePropertyAccessSyntax +//@[027:0113) | ├─TypePropertyAccessSyntax +//@[027:0092) | | ├─TypeAdditionalPropertiesAccessSyntax +//@[027:0090) | | | ├─TypePropertyAccessSyntax +//@[027:0079) | | | | ├─ParameterizedTypeInstantiationSyntax +//@[027:0040) | | | | | ├─IdentifierSyntax +//@[027:0040) | | | | | | └─Token(Identifier) |resourceInput| +//@[040:0041) | | | | | ├─Token(LeftChevron) |<| +//@[041:0078) | | | | | ├─ParameterizedTypeArgumentSyntax +//@[041:0078) | | | | | | └─StringTypeLiteralSyntax +//@[041:0078) | | | | | | └─Token(StringComplete) |'Microsoft.Web/customApis@2016-06-01'| +//@[078:0079) | | | | | └─Token(RightChevron) |>| +//@[079:0080) | | | | ├─Token(Dot) |.| +//@[080:0090) | | | | └─IdentifierSyntax +//@[080:0090) | | | | └─Token(Identifier) |properties| +//@[090:0091) | | | ├─Token(Dot) |.| +//@[091:0092) | | | └─Token(Asterisk) |*| +//@[092:0093) | | ├─Token(Dot) |.| +//@[093:0113) | | └─IdentifierSyntax +//@[093:0113) | | └─Token(Identifier) |connectionParameters| +//@[113:0114) | ├─Token(Dot) |.| +//@[114:0118) | └─IdentifierSyntax +//@[114:0118) | └─Token(Identifier) |type| +//@[118:0120) ├─Token(NewLine) |\n\n| module mod 'modules/mod.json' = { //@[000:0077) ├─ModuleDeclarationSyntax diff --git a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.tokens.bicep b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.tokens.bicep index 1fd85e987fd..2187a4ba566 100644 --- a/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.tokens.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/InvalidResourceDerivedTypes_LF/main.tokens.bicep @@ -1,121 +1,121 @@ -type invalid1 = resource +type invalid1 = resourceInput //@[000:004) Identifier |type| //@[005:013) Identifier |invalid1| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:026) NewLine |\n\n| +//@[016:029) Identifier |resourceInput| +//@[029:031) NewLine |\n\n| -type invalid2 = resource<> +type invalid2 = resourceInput<> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid2| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:026) RightChevron |>| -//@[026:028) NewLine |\n\n| +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:031) RightChevron |>| +//@[031:033) NewLine |\n\n| -type invalid3 = resource<'abc', 'def'> +type invalid3 = resourceInput<'abc', 'def'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid3| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:030) StringComplete |'abc'| -//@[030:031) Comma |,| -//@[032:037) StringComplete |'def'| -//@[037:038) RightChevron |>| -//@[038:039) NewLine |\n| -type invalid4 = resource +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:035) StringComplete |'abc'| +//@[035:036) Comma |,| +//@[037:042) StringComplete |'def'| +//@[042:043) RightChevron |>| +//@[043:044) NewLine |\n| +type invalid4 = resourceInput //@[000:004) Identifier |type| //@[005:013) Identifier |invalid4| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:030) Identifier |hello| -//@[030:031) RightChevron |>| -//@[031:032) NewLine |\n| -type invalid5 = resource<'Microsoft.Storage/storageAccounts'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:035) Identifier |hello| +//@[035:036) RightChevron |>| +//@[036:037) NewLine |\n| +type invalid5 = resourceInput<'Microsoft.Storage/storageAccounts'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid5| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:060) StringComplete |'Microsoft.Storage/storageAccounts'| -//@[060:061) RightChevron |>| -//@[061:062) NewLine |\n| -type invalid6 = resource<'Microsoft.Storage/storageAccounts@'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:065) StringComplete |'Microsoft.Storage/storageAccounts'| +//@[065:066) RightChevron |>| +//@[066:067) NewLine |\n| +type invalid6 = resourceInput<'Microsoft.Storage/storageAccounts@'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid6| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:061) StringComplete |'Microsoft.Storage/storageAccounts@'| -//@[061:062) RightChevron |>| -//@[062:063) NewLine |\n| -type invalid7 = resource<'Microsoft.Storage/storageAccounts@hello'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:066) StringComplete |'Microsoft.Storage/storageAccounts@'| +//@[066:067) RightChevron |>| +//@[067:068) NewLine |\n| +type invalid7 = resourceInput<'Microsoft.Storage/storageAccounts@hello'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid7| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:066) StringComplete |'Microsoft.Storage/storageAccounts@hello'| -//@[066:067) RightChevron |>| -//@[067:068) NewLine |\n| -type invalid8 = resource<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:071) StringComplete |'Microsoft.Storage/storageAccounts@hello'| +//@[071:072) RightChevron |>| +//@[072:073) NewLine |\n| +type invalid8 = resourceInput<'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid8| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:089) StringComplete |'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'| -//@[089:090) RightChevron |>| -//@[090:091) NewLine |\n| -type invalid9 = resource<':Microsoft.Storage/storageAccounts@2022-09-01'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:094) StringComplete |'notARealNamespace:Microsoft.Storage/storageAccounts@2022-09-01'| +//@[094:095) RightChevron |>| +//@[095:096) NewLine |\n| +type invalid9 = resourceInput<':Microsoft.Storage/storageAccounts@2022-09-01'> //@[000:004) Identifier |type| //@[005:013) Identifier |invalid9| //@[014:015) Assignment |=| -//@[016:024) Identifier |resource| -//@[024:025) LeftChevron |<| -//@[025:072) StringComplete |':Microsoft.Storage/storageAccounts@2022-09-01'| -//@[072:073) RightChevron |>| -//@[073:074) NewLine |\n| -type invalid10 = resource<'abc' 'def'> +//@[016:029) Identifier |resourceInput| +//@[029:030) LeftChevron |<| +//@[030:077) StringComplete |':Microsoft.Storage/storageAccounts@2022-09-01'| +//@[077:078) RightChevron |>| +//@[078:079) NewLine |\n| +type invalid10 = resourceInput<'abc' 'def'> //@[000:004) Identifier |type| //@[005:014) Identifier |invalid10| //@[015:016) Assignment |=| -//@[017:025) Identifier |resource| -//@[025:026) LeftChevron |<| -//@[026:031) StringComplete |'abc'| -//@[032:037) StringComplete |'def'| -//@[037:038) RightChevron |>| -//@[038:039) NewLine |\n| -type invalid11 = resource<123> +//@[017:030) Identifier |resourceInput| +//@[030:031) LeftChevron |<| +//@[031:036) StringComplete |'abc'| +//@[037:042) StringComplete |'def'| +//@[042:043) RightChevron |>| +//@[043:044) NewLine |\n| +type invalid11 = resourceInput<123> //@[000:004) Identifier |type| //@[005:014) Identifier |invalid11| //@[015:016) Assignment |=| -//@[017:025) Identifier |resource| -//@[025:026) LeftChevron |<| -//@[026:029) Integer |123| -//@[029:030) RightChevron |>| -//@[030:031) NewLine |\n| -type invalid12 = resource +//@[017:030) Identifier |resourceInput| +//@[030:031) LeftChevron |<| +//@[031:034) Integer |123| +//@[034:035) RightChevron |>| +//@[035:036) NewLine |\n| +type invalid12 = resourceInput //@[000:004) Identifier |type| //@[005:014) Identifier |invalid12| //@[015:016) Assignment |=| -//@[017:025) Identifier |resource| -//@[025:026) LeftChevron |<| -//@[026:039) Identifier |resourceGroup| -//@[039:040) LeftParen |(| -//@[040:041) RightParen |)| -//@[041:042) RightChevron |>| -//@[042:044) NewLine |\n\n| +//@[017:030) Identifier |resourceInput| +//@[030:031) LeftChevron |<| +//@[031:044) Identifier |resourceGroup| +//@[044:045) LeftParen |(| +//@[045:046) RightParen |)| +//@[046:047) RightChevron |>| +//@[047:049) NewLine |\n\n| -type thisIsWeird = resource| //@[001:003) NewLine |\n\n| -type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> +type interpolated = resourceInput<'Microsoft.${'Storage'}/storageAccounts@2022-09-01'> //@[000:004) Identifier |type| //@[005:017) Identifier |interpolated| //@[018:019) Assignment |=| -//@[020:028) Identifier |resource| -//@[028:029) LeftChevron |<| -//@[029:042) StringLeftPiece |'Microsoft.${| -//@[042:051) StringComplete |'Storage'| -//@[051:080) StringRightPiece |}/storageAccounts@2022-09-01'| -//@[080:081) RightChevron |>| -//@[081:083) NewLine |\n\n| +//@[020:033) Identifier |resourceInput| +//@[033:034) LeftChevron |<| +//@[034:047) StringLeftPiece |'Microsoft.${| +//@[047:056) StringComplete |'Storage'| +//@[056:085) StringRightPiece |}/storageAccounts@2022-09-01'| +//@[085:086) RightChevron |>| +//@[086:088) NewLine |\n\n| @sealed() //@[000:001) At |@| @@ -143,15 +143,15 @@ type interpolated = resource<'Microsoft.${'Storage'}/storageAccounts@2022-09-01' //@[007:008) LeftParen |(| //@[008:009) RightParen |)| //@[009:010) NewLine |\n| -type shouldNotBeSealable = resource<'Microsoft.Storage/storageAccounts@2022-09-01'> +type shouldNotBeSealable = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'> //@[000:004) Identifier |type| //@[005:024) Identifier |shouldNotBeSealable| //@[025:026) Assignment |=| -//@[027:035) Identifier |resource| -//@[035:036) LeftChevron |<| -//@[036:082) StringComplete |'Microsoft.Storage/storageAccounts@2022-09-01'| -//@[082:083) RightChevron |>| -//@[083:085) NewLine |\n\n| +//@[027:040) Identifier |resourceInput| +//@[040:041) LeftChevron |<| +//@[041:087) StringComplete |'Microsoft.Storage/storageAccounts@2022-09-01'| +//@[087:088) RightChevron |>| +//@[088:090) NewLine |\n\n| type hello = { //@[000:004) Identifier |type| @@ -166,99 +166,99 @@ type hello = { //@[017:021) StringComplete |'hi'| //@[021:022) RightParen |)| //@[022:023) NewLine |\n| - bar: resource<'Astronomer.Astro/organizations@2023-08-01-preview'> + bar: resourceInput<'Astronomer.Astro/organizations@2023-08-01-preview'> //@[002:005) Identifier |bar| //@[005:006) Colon |:| -//@[007:015) Identifier |resource| -//@[015:016) LeftChevron |<| -//@[016:067) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[067:068) RightChevron |>| -//@[068:069) NewLine |\n| +//@[007:020) Identifier |resourceInput| +//@[020:021) LeftChevron |<| +//@[021:072) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[072:073) RightChevron |>| +//@[073:074) NewLine |\n| } //@[000:001) RightBrace |}| //@[001:003) NewLine |\n\n| -type typoInPropertyName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom +type typoInPropertyName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.nom //@[000:004) Identifier |type| //@[005:023) Identifier |typoInPropertyName| //@[024:025) Assignment |=| -//@[026:034) Identifier |resource| -//@[034:035) LeftChevron |<| -//@[035:081) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[081:082) RightChevron |>| -//@[082:083) Dot |.| -//@[083:086) Identifier |nom| -//@[086:087) NewLine |\n| -type typoInPropertyName2 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId +//@[026:039) Identifier |resourceInput| +//@[039:040) LeftChevron |<| +//@[040:086) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:087) RightChevron |>| +//@[087:088) Dot |.| +//@[088:091) Identifier |nom| +//@[091:092) NewLine |\n| +type typoInPropertyName2 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*].tenatId //@[000:004) Identifier |type| //@[005:024) Identifier |typoInPropertyName2| //@[025:026) Assignment |=| -//@[027:035) Identifier |resource| -//@[035:036) LeftChevron |<| -//@[036:074) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[074:075) RightChevron |>| -//@[075:076) Dot |.| -//@[076:086) Identifier |properties| -//@[086:087) Dot |.| -//@[087:101) Identifier |accessPolicies| -//@[101:102) LeftSquare |[| -//@[102:103) Asterisk |*| -//@[103:104) RightSquare |]| -//@[104:105) Dot |.| -//@[105:112) Identifier |tenatId| -//@[112:113) NewLine |\n| -type typoInPropertyName3 = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId +//@[027:040) Identifier |resourceInput| +//@[040:041) LeftChevron |<| +//@[041:079) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[079:080) RightChevron |>| +//@[080:081) Dot |.| +//@[081:091) Identifier |properties| +//@[091:092) Dot |.| +//@[092:106) Identifier |accessPolicies| +//@[106:107) LeftSquare |[| +//@[107:108) Asterisk |*| +//@[108:109) RightSquare |]| +//@[109:110) Dot |.| +//@[110:117) Identifier |tenatId| +//@[117:118) NewLine |\n| +type typoInPropertyName3 = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties[*].accessPolicies.tenantId //@[000:004) Identifier |type| //@[005:024) Identifier |typoInPropertyName3| //@[025:026) Assignment |=| -//@[027:035) Identifier |resource| -//@[035:036) LeftChevron |<| -//@[036:074) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[074:075) RightChevron |>| -//@[075:076) Dot |.| -//@[076:086) Identifier |properties| -//@[086:087) LeftSquare |[| -//@[087:088) Asterisk |*| -//@[088:089) RightSquare |]| -//@[089:090) Dot |.| -//@[090:104) Identifier |accessPolicies| -//@[104:105) Dot |.| -//@[105:113) Identifier |tenantId| -//@[113:114) NewLine |\n| -type typoInPropertyName4 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype +//@[027:040) Identifier |resourceInput| +//@[040:041) LeftChevron |<| +//@[041:079) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[079:080) RightChevron |>| +//@[080:081) Dot |.| +//@[081:091) Identifier |properties| +//@[091:092) LeftSquare |[| +//@[092:093) Asterisk |*| +//@[093:094) RightSquare |]| +//@[094:095) Dot |.| +//@[095:109) Identifier |accessPolicies| +//@[109:110) Dot |.| +//@[110:118) Identifier |tenantId| +//@[118:119) NewLine |\n| +type typoInPropertyName4 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.connectionParameters.*.tyype //@[000:004) Identifier |type| //@[005:024) Identifier |typoInPropertyName4| //@[025:026) Assignment |=| -//@[027:035) Identifier |resource| -//@[035:036) LeftChevron |<| -//@[036:073) StringComplete |'Microsoft.Web/customApis@2016-06-01'| -//@[073:074) RightChevron |>| -//@[074:075) Dot |.| -//@[075:085) Identifier |properties| -//@[085:086) Dot |.| -//@[086:106) Identifier |connectionParameters| -//@[106:107) Dot |.| -//@[107:108) Asterisk |*| -//@[108:109) Dot |.| -//@[109:114) Identifier |tyype| -//@[114:115) NewLine |\n| -type typoInPropertyName5 = resource<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type +//@[027:040) Identifier |resourceInput| +//@[040:041) LeftChevron |<| +//@[041:078) StringComplete |'Microsoft.Web/customApis@2016-06-01'| +//@[078:079) RightChevron |>| +//@[079:080) Dot |.| +//@[080:090) Identifier |properties| +//@[090:091) Dot |.| +//@[091:111) Identifier |connectionParameters| +//@[111:112) Dot |.| +//@[112:113) Asterisk |*| +//@[113:114) Dot |.| +//@[114:119) Identifier |tyype| +//@[119:120) NewLine |\n| +type typoInPropertyName5 = resourceInput<'Microsoft.Web/customApis@2016-06-01'>.properties.*.connectionParameters.type //@[000:004) Identifier |type| //@[005:024) Identifier |typoInPropertyName5| //@[025:026) Assignment |=| -//@[027:035) Identifier |resource| -//@[035:036) LeftChevron |<| -//@[036:073) StringComplete |'Microsoft.Web/customApis@2016-06-01'| -//@[073:074) RightChevron |>| -//@[074:075) Dot |.| -//@[075:085) Identifier |properties| -//@[085:086) Dot |.| -//@[086:087) Asterisk |*| -//@[087:088) Dot |.| -//@[088:108) Identifier |connectionParameters| -//@[108:109) Dot |.| -//@[109:113) Identifier |type| -//@[113:115) NewLine |\n\n| +//@[027:040) Identifier |resourceInput| +//@[040:041) LeftChevron |<| +//@[041:078) StringComplete |'Microsoft.Web/customApis@2016-06-01'| +//@[078:079) RightChevron |>| +//@[079:080) Dot |.| +//@[080:090) Identifier |properties| +//@[090:091) Dot |.| +//@[091:092) Asterisk |*| +//@[092:093) Dot |.| +//@[093:113) Identifier |connectionParameters| +//@[113:114) Dot |.| +//@[114:118) Identifier |type| +//@[118:120) NewLine |\n\n| module mod 'modules/mod.json' = { //@[000:006) Identifier |module| diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.bicep index 6a6f1765ec7..4105467692f 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.bicep @@ -1,38 +1,38 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name type test = { - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name resC: sys.array - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name } type strangeFormatting = { - test: resource< + test: resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name - test3: resource.name + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name + test3: resourceInput.name } @description('I love space(s)') -type test2 = resource< +type test2 = resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { tags: { fizz: 'buzz' snap: 'crackle' } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.diagnostics.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.diagnostics.bicep index b41f10e8b33..89228a9c697 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.diagnostics.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.diagnostics.bicep @@ -1,30 +1,30 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name type test = { - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name resC: sys.array - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name } type strangeFormatting = { - test: resource< + test: resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name - test3: resource.name + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name + test3: resourceInput.name } @description('I love space(s)') -type test2 = resource< +type test2 = resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { //@[6:9) [no-unused-params (Warning)] Parameter "bar" is declared but never used. (bicep core linter https://aka.ms/bicep/linter/no-unused-params) |bar| tags: { fizz: 'buzz' @@ -32,9 +32,9 @@ param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.formatted.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.formatted.bicep index 565eb9f22ad..3c0fb8583a8 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.formatted.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.formatted.bicep @@ -1,34 +1,34 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name type test = { - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name resC: sys.array - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name } type strangeFormatting = { - test: resource< + test: resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name - test3: resource.name + test2: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + test3: resourceInput.name } @description('I love space(s)') -type test2 = resource< +type test2 = resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { tags: { fizz: 'buzz' snap: 'crackle' } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.ir.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.ir.bicep index ecf2767bbc7..7bac22bf627 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.ir.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.ir.bicep @@ -1,66 +1,66 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:1214) ProgramExpression -//@[00:0072) ├─DeclaredTypeExpression { Name = foo } -//@[11:0072) | └─TypeReferencePropertyAccessExpression { Name = string } -//@[11:0067) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[00:1279) ProgramExpression +//@[00:0077) ├─DeclaredTypeExpression { Name = foo } +//@[11:0077) | └─TypeReferencePropertyAccessExpression { Name = string } +//@[11:0072) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } type test = { -//@[00:0254) ├─DeclaredTypeExpression { Name = test } -//@[12:0254) | └─ObjectTypeExpression { Name = { resA: string, resB: string, resC: array, resD: string } } - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:0069) | ├─ObjectTypePropertyExpression -//@[08:0069) | | └─TypeReferencePropertyAccessExpression { Name = string } -//@[08:0064) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:0073) | ├─ObjectTypePropertyExpression -//@[08:0073) | | └─TypeReferencePropertyAccessExpression { Name = string } -//@[08:0068) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } +//@[00:0269) ├─DeclaredTypeExpression { Name = test } +//@[12:0269) | └─ObjectTypeExpression { Name = { resA: string, resB: string, resC: array, resD: string } } + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[02:0074) | ├─ObjectTypePropertyExpression +//@[08:0074) | | └─TypeReferencePropertyAccessExpression { Name = string } +//@[08:0069) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[02:0078) | ├─ObjectTypePropertyExpression +//@[08:0078) | | └─TypeReferencePropertyAccessExpression { Name = string } +//@[08:0073) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } resC: sys.array //@[02:0017) | ├─ObjectTypePropertyExpression //@[08:0017) | | └─FullyQualifiedAmbientTypeReferenceExpression { Name = sys.array } - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:0076) | └─ObjectTypePropertyExpression -//@[08:0076) | └─TypeReferencePropertyAccessExpression { Name = string } -//@[08:0071) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[02:0081) | └─ObjectTypePropertyExpression +//@[08:0081) | └─TypeReferencePropertyAccessExpression { Name = string } +//@[08:0076) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } } type strangeFormatting = { -//@[00:0272) ├─DeclaredTypeExpression { Name = strangeFormatting } -//@[25:0272) | └─ObjectTypeExpression { Name = { test: string, test2: string, test3: string } } - test: resource< -//@[02:0080) | ├─ObjectTypePropertyExpression -//@[08:0080) | | └─TypeReferencePropertyAccessExpression { Name = string } -//@[08:0075) | | └─ResourceDerivedTypeExpression { Name = Astronomer.Astro/organizations } +//@[00:0287) ├─DeclaredTypeExpression { Name = strangeFormatting } +//@[25:0287) | └─ObjectTypeExpression { Name = { test: string, test2: string, test3: string } } + test: resourceInput< +//@[02:0085) | ├─ObjectTypePropertyExpression +//@[08:0085) | | └─TypeReferencePropertyAccessExpression { Name = string } +//@[08:0080) | | └─ResourceDerivedTypeExpression { Name = Astronomer.Astro/organizations } 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:0074) | ├─ObjectTypePropertyExpression -//@[09:0074) | | └─TypeReferencePropertyAccessExpression { Name = string } -//@[09:0069) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } - test3: resource.name -//@[02:0087) | └─ObjectTypePropertyExpression -//@[09:0087) | └─TypeReferencePropertyAccessExpression { Name = string } -//@[09:0082) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[02:0079) | ├─ObjectTypePropertyExpression +//@[09:0079) | | └─TypeReferencePropertyAccessExpression { Name = string } +//@[09:0074) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } + test3: resourceInput.name +//@[02:0092) | └─ObjectTypePropertyExpression +//@[09:0092) | └─TypeReferencePropertyAccessExpression { Name = string } +//@[09:0087) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } } @description('I love space(s)') -//@[00:0120) ├─DeclaredTypeExpression { Name = test2 } +//@[00:0125) ├─DeclaredTypeExpression { Name = test2 } //@[13:0030) | ├─StringLiteralExpression { Value = I love space(s) } -type test2 = resource< -//@[13:0088) | └─TypeReferencePropertyAccessExpression { Name = string } -//@[13:0083) | └─ResourceDerivedTypeExpression { Name = Astronomer.Astro/organizations } +type test2 = resourceInput< +//@[13:0093) | └─TypeReferencePropertyAccessExpression { Name = string } +//@[13:0088) | └─ResourceDerivedTypeExpression { Name = Astronomer.Astro/organizations } 'Astronomer.Astro/organizations@2023-08-01-preview' >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { -//@[00:0125) ├─DeclaredParameterExpression { Name = bar } -//@[10:0068) | ├─TypeReferencePropertyAccessExpression { Name = Tags } -//@[10:0057) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Resources/tags } -//@[71:0125) | └─ObjectExpression +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { +//@[00:0130) ├─DeclaredParameterExpression { Name = bar } +//@[10:0073) | ├─TypeReferencePropertyAccessExpression { Name = Tags } +//@[10:0062) | | └─ResourceDerivedTypeExpression { Name = Microsoft.Resources/tags } +//@[76:0130) | └─ObjectExpression tags: { //@[02:0050) | └─ObjectPropertyExpression //@[02:0006) | ├─StringLiteralExpression { Value = tags } @@ -76,26 +76,26 @@ param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -//@[00:0096) └─DeclaredOutputExpression { Name = baz } -//@[11:0087) ├─TypeReferencePropertyAccessExpression { Name = string } -//@[11:0082) | └─ResourceDerivedTypeExpression { Name = Microsoft.ManagedIdentity/userAssignedIdentities } -//@[90:0096) └─StringLiteralExpression { Value = myId } +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +//@[00:0101) └─DeclaredOutputExpression { Name = baz } +//@[11:0092) ├─TypeReferencePropertyAccessExpression { Name = string } +//@[11:0087) | └─ResourceDerivedTypeExpression { Name = Microsoft.ManagedIdentity/userAssignedIdentities } +//@[95:0101) └─StringLiteralExpression { Value = myId } -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:0087) ├─DeclaredTypeExpression { Name = storageAccountName } -//@[26:0087) | └─TypeReferencePropertyAccessExpression { Name = string } -//@[26:0082) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -//@[00:0097) ├─DeclaredTypeExpression { Name = accessPolicy } -//@[20:0097) | └─TypeReferenceItemsAccessExpression { Name = AccessPolicyEntry } -//@[20:0094) | └─TypeReferencePropertyAccessExpression { Name = AccessPolicyEntry[] } -//@[20:0079) | └─TypeReferencePropertyAccessExpression { Name = VaultProperties } -//@[20:0068) | └─ResourceDerivedTypeExpression { Name = Microsoft.KeyVault/vaults } -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* -//@[00:0076) ├─DeclaredTypeExpression { Name = tag } -//@[11:0076) | └─TypeReferenceAdditionalPropertiesAccessExpression { Name = string } -//@[11:0074) | └─TypeReferencePropertyAccessExpression { Name = Tags } -//@[11:0069) | └─TypeReferencePropertyAccessExpression { Name = Tags } -//@[11:0058) | └─ResourceDerivedTypeExpression { Name = Microsoft.Resources/tags } +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[00:0092) ├─DeclaredTypeExpression { Name = storageAccountName } +//@[26:0092) | └─TypeReferencePropertyAccessExpression { Name = string } +//@[26:0087) | └─ResourceDerivedTypeExpression { Name = Microsoft.Storage/storageAccounts } +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +//@[00:0102) ├─DeclaredTypeExpression { Name = accessPolicy } +//@[20:0102) | └─TypeReferenceItemsAccessExpression { Name = AccessPolicyEntry } +//@[20:0099) | └─TypeReferencePropertyAccessExpression { Name = AccessPolicyEntry[] } +//@[20:0084) | └─TypeReferencePropertyAccessExpression { Name = VaultProperties } +//@[20:0073) | └─ResourceDerivedTypeExpression { Name = Microsoft.KeyVault/vaults } +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +//@[00:0081) ├─DeclaredTypeExpression { Name = tag } +//@[11:0081) | └─TypeReferenceAdditionalPropertiesAccessExpression { Name = string } +//@[11:0079) | └─TypeReferencePropertyAccessExpression { Name = Tags } +//@[11:0074) | └─TypeReferencePropertyAccessExpression { Name = Tags } +//@[11:0063) | └─ResourceDerivedTypeExpression { Name = Microsoft.Resources/tags } diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.json b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.json index 9533e6ece40..861aacbee1c 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.json +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.json @@ -6,14 +6,16 @@ "_generator": { "name": "bicep", "version": "dev", - "templateHash": "3374352344527551547" + "templateHash": "16997408782622068406" } }, "definitions": { "foo": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "test": { @@ -22,13 +24,17 @@ "resA": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "resB": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } }, "resC": { @@ -37,7 +43,9 @@ "resD": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } } } @@ -48,19 +56,25 @@ "test": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + "__bicep_resource_derived_type!": { + "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + } } }, "test2": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "test3": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } } } @@ -68,26 +82,34 @@ "test2": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name", + "__bicep_resource_derived_type!": { + "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + }, "description": "I love space(s)" } }, "storageAccountName": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "accessPolicy": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + "__bicep_resource_derived_type!": { + "source": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + } } }, "tag": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + } } } }, @@ -95,7 +117,9 @@ "bar": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Resources/tags@2022-09-01#properties/properties" + } }, "defaultValue": { "tags": { @@ -110,7 +134,9 @@ "baz": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" + } }, "value": "myId" } diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.sourcemap.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.sourcemap.bicep index 1208cc669bb..50a19c243f0 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.sourcemap.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.sourcemap.bicep @@ -1,8 +1,10 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name //@ "foo": { //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ } //@ } //@ }, @@ -18,24 +20,30 @@ type test = { //@ } //@ } //@ }, - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ } //@ } - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" +//@ } //@ } resC: sys.array //@ "resC": { //@ "type": "array" //@ }, - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" +//@ } //@ } } @@ -51,34 +59,42 @@ type strangeFormatting = { //@ } //@ } //@ }, - test: resource< + test: resourceInput< //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" +//@ } //@ } 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ } //@ } - test3: resource.name + test3: resourceInput.name //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ } //@ } } @description('I love space(s)') //@ "description": "I love space(s)" -type test2 = resource< +type test2 = resourceInput< //@ "test2": { //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name", +//@ "__bicep_resource_derived_type!": { +//@ "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" +//@ }, //@ } //@ }, @@ -86,11 +102,13 @@ type test2 = resource< >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { //@ "bar": { //@ "type": "object", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Resources/tags@2022-09-01#properties/properties" +//@ } //@ }, //@ "defaultValue": { //@ } @@ -105,34 +123,42 @@ param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' //@ "baz": { //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" +//@ } //@ }, //@ "value": "myId" //@ } -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name //@ "storageAccountName": { //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" +//@ } //@ } //@ }, -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] //@ "accessPolicy": { //@ "type": "object", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" +//@ } //@ } //@ }, -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* //@ "tag": { //@ "type": "string", //@ "metadata": { -//@ "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" +//@ "__bicep_resource_derived_type!": { +//@ "source": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" +//@ } //@ } //@ } diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbolicnames.json b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbolicnames.json index 9533e6ece40..861aacbee1c 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbolicnames.json +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbolicnames.json @@ -6,14 +6,16 @@ "_generator": { "name": "bicep", "version": "dev", - "templateHash": "3374352344527551547" + "templateHash": "16997408782622068406" } }, "definitions": { "foo": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "test": { @@ -22,13 +24,17 @@ "resA": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "resB": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } }, "resC": { @@ -37,7 +43,9 @@ "resD": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2022-09-01#properties/name" + } } } } @@ -48,19 +56,25 @@ "test": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + "__bicep_resource_derived_type!": { + "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + } } }, "test2": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "test3": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } } } @@ -68,26 +82,34 @@ "test2": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name", + "__bicep_resource_derived_type!": { + "source": "Astronomer.Astro/organizations@2023-08-01-preview#properties/name" + }, "description": "I love space(s)" } }, "storageAccountName": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Storage/storageAccounts@2023-01-01#properties/name" + } } }, "accessPolicy": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + "__bicep_resource_derived_type!": { + "source": "Microsoft.KeyVault/vaults@2022-07-01#properties/properties/properties/accessPolicies/items" + } } }, "tag": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Resources/tags@2022-09-01#properties/properties/properties/tags/additionalProperties" + } } } }, @@ -95,7 +117,9 @@ "bar": { "type": "object", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.Resources/tags@2022-09-01#properties/properties" + "__bicep_resource_derived_type!": { + "source": "Microsoft.Resources/tags@2022-09-01#properties/properties" + } }, "defaultValue": { "tags": { @@ -110,7 +134,9 @@ "baz": { "type": "string", "metadata": { - "__bicep_resource_derived_type!": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" + "__bicep_resource_derived_type!": { + "source": "Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31#properties/name" + } }, "value": "myId" } diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbols.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbols.bicep index a8d4e7b88ae..88c08864de6 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbols.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.symbols.bicep @@ -1,48 +1,48 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[5:08) TypeAlias foo. Type: Type. Declaration start char: 0, length: 72 +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[5:08) TypeAlias foo. Type: Type. Declaration start char: 0, length: 77 type test = { -//@[5:09) TypeAlias test. Type: Type<{ resA: string, resB: string, resC: array, resD: string }>. Declaration start char: 0, length: 254 - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[5:09) TypeAlias test. Type: Type<{ resA: string, resB: string, resC: array, resD: string }>. Declaration start char: 0, length: 269 + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name resC: sys.array - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name } type strangeFormatting = { -//@[5:22) TypeAlias strangeFormatting. Type: Type<{ test: string, test2: string, test3: string }>. Declaration start char: 0, length: 272 - test: resource< +//@[5:22) TypeAlias strangeFormatting. Type: Type<{ test: string, test2: string, test3: string }>. Declaration start char: 0, length: 287 + test: resourceInput< 'Astronomer.Astro/organizations@2023-08-01-preview' >.name - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name - test3: resource.name + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name + test3: resourceInput.name } @description('I love space(s)') -type test2 = resource< -//@[5:10) TypeAlias test2. Type: Type. Declaration start char: 0, length: 120 +type test2 = resourceInput< +//@[5:10) TypeAlias test2. Type: Type. Declaration start char: 0, length: 125 'Astronomer.Astro/organizations@2023-08-01-preview' >.name -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { -//@[6:09) Parameter bar. Type: Tags. Declaration start char: 0, length: 125 +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { +//@[6:09) Parameter bar. Type: Tags. Declaration start char: 0, length: 130 tags: { fizz: 'buzz' snap: 'crackle' } } -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -//@[7:10) Output baz. Type: string. Declaration start char: 0, length: 96 +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +//@[7:10) Output baz. Type: string. Declaration start char: 0, length: 101 -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[5:23) TypeAlias storageAccountName. Type: Type. Declaration start char: 0, length: 87 -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -//@[5:17) TypeAlias accessPolicy. Type: Type. Declaration start char: 0, length: 97 -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* -//@[5:08) TypeAlias tag. Type: Type. Declaration start char: 0, length: 76 +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[5:23) TypeAlias storageAccountName. Type: Type. Declaration start char: 0, length: 92 +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +//@[5:17) TypeAlias accessPolicy. Type: Type. Declaration start char: 0, length: 102 +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +//@[5:08) TypeAlias tag. Type: Type. Declaration start char: 0, length: 81 diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.syntax.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.syntax.bicep index 4631207074f..ac901703ec4 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.syntax.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.syntax.bicep @@ -1,369 +1,369 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:1214) ProgramSyntax -//@[00:0072) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0008) | ├─IdentifierSyntax -//@[05:0008) | | └─Token(Identifier) |foo| -//@[09:0010) | ├─Token(Assignment) |=| -//@[11:0072) | └─TypePropertyAccessSyntax -//@[11:0067) | ├─ParameterizedTypeInstantiationSyntax -//@[11:0019) | | ├─IdentifierSyntax -//@[11:0019) | | | └─Token(Identifier) |resource| -//@[19:0020) | | ├─Token(LeftChevron) |<| -//@[20:0066) | | ├─ParameterizedTypeArgumentSyntax -//@[20:0066) | | | └─StringTypeLiteralSyntax -//@[20:0066) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[66:0067) | | └─Token(RightChevron) |>| -//@[67:0068) | ├─Token(Dot) |.| -//@[68:0072) | └─IdentifierSyntax -//@[68:0072) | └─Token(Identifier) |name| -//@[72:0074) ├─Token(NewLine) |\n\n| +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[000:1279) ProgramSyntax +//@[000:0077) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0008) | ├─IdentifierSyntax +//@[005:0008) | | └─Token(Identifier) |foo| +//@[009:0010) | ├─Token(Assignment) |=| +//@[011:0077) | └─TypePropertyAccessSyntax +//@[011:0072) | ├─ParameterizedTypeInstantiationSyntax +//@[011:0024) | | ├─IdentifierSyntax +//@[011:0024) | | | └─Token(Identifier) |resourceInput| +//@[024:0025) | | ├─Token(LeftChevron) |<| +//@[025:0071) | | ├─ParameterizedTypeArgumentSyntax +//@[025:0071) | | | └─StringTypeLiteralSyntax +//@[025:0071) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[071:0072) | | └─Token(RightChevron) |>| +//@[072:0073) | ├─Token(Dot) |.| +//@[073:0077) | └─IdentifierSyntax +//@[073:0077) | └─Token(Identifier) |name| +//@[077:0079) ├─Token(NewLine) |\n\n| type test = { -//@[00:0254) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0009) | ├─IdentifierSyntax -//@[05:0009) | | └─Token(Identifier) |test| -//@[10:0011) | ├─Token(Assignment) |=| -//@[12:0254) | └─ObjectTypeSyntax -//@[12:0013) | ├─Token(LeftBrace) |{| -//@[13:0014) | ├─Token(NewLine) |\n| - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:0069) | ├─ObjectTypePropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |resA| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0069) | | └─TypePropertyAccessSyntax -//@[08:0064) | | ├─ParameterizedTypeInstantiationSyntax -//@[08:0016) | | | ├─IdentifierSyntax -//@[08:0016) | | | | └─Token(Identifier) |resource| -//@[16:0017) | | | ├─Token(LeftChevron) |<| -//@[17:0063) | | | ├─ParameterizedTypeArgumentSyntax -//@[17:0063) | | | | └─StringTypeLiteralSyntax -//@[17:0063) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[63:0064) | | | └─Token(RightChevron) |>| -//@[64:0065) | | ├─Token(Dot) |.| -//@[65:0069) | | └─IdentifierSyntax -//@[65:0069) | | └─Token(Identifier) |name| -//@[69:0070) | ├─Token(NewLine) |\n| - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:0073) | ├─ObjectTypePropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |resB| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0073) | | └─TypePropertyAccessSyntax -//@[08:0068) | | ├─InstanceParameterizedTypeInstantiationSyntax -//@[08:0011) | | | ├─TypeVariableAccessSyntax -//@[08:0011) | | | | └─IdentifierSyntax -//@[08:0011) | | | | └─Token(Identifier) |sys| -//@[11:0012) | | | ├─Token(Dot) |.| -//@[12:0020) | | | ├─IdentifierSyntax -//@[12:0020) | | | | └─Token(Identifier) |resource| -//@[20:0021) | | | ├─Token(LeftChevron) |<| -//@[21:0067) | | | ├─ParameterizedTypeArgumentSyntax -//@[21:0067) | | | | └─StringTypeLiteralSyntax -//@[21:0067) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2022-09-01'| -//@[67:0068) | | | └─Token(RightChevron) |>| -//@[68:0069) | | ├─Token(Dot) |.| -//@[69:0073) | | └─IdentifierSyntax -//@[69:0073) | | └─Token(Identifier) |name| -//@[73:0074) | ├─Token(NewLine) |\n| +//@[000:0269) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0009) | ├─IdentifierSyntax +//@[005:0009) | | └─Token(Identifier) |test| +//@[010:0011) | ├─Token(Assignment) |=| +//@[012:0269) | └─ObjectTypeSyntax +//@[012:0013) | ├─Token(LeftBrace) |{| +//@[013:0014) | ├─Token(NewLine) |\n| + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[002:0074) | ├─ObjectTypePropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |resA| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0074) | | └─TypePropertyAccessSyntax +//@[008:0069) | | ├─ParameterizedTypeInstantiationSyntax +//@[008:0021) | | | ├─IdentifierSyntax +//@[008:0021) | | | | └─Token(Identifier) |resourceInput| +//@[021:0022) | | | ├─Token(LeftChevron) |<| +//@[022:0068) | | | ├─ParameterizedTypeArgumentSyntax +//@[022:0068) | | | | └─StringTypeLiteralSyntax +//@[022:0068) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[068:0069) | | | └─Token(RightChevron) |>| +//@[069:0070) | | ├─Token(Dot) |.| +//@[070:0074) | | └─IdentifierSyntax +//@[070:0074) | | └─Token(Identifier) |name| +//@[074:0075) | ├─Token(NewLine) |\n| + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[002:0078) | ├─ObjectTypePropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |resB| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0078) | | └─TypePropertyAccessSyntax +//@[008:0073) | | ├─InstanceParameterizedTypeInstantiationSyntax +//@[008:0011) | | | ├─TypeVariableAccessSyntax +//@[008:0011) | | | | └─IdentifierSyntax +//@[008:0011) | | | | └─Token(Identifier) |sys| +//@[011:0012) | | | ├─Token(Dot) |.| +//@[012:0025) | | | ├─IdentifierSyntax +//@[012:0025) | | | | └─Token(Identifier) |resourceInput| +//@[025:0026) | | | ├─Token(LeftChevron) |<| +//@[026:0072) | | | ├─ParameterizedTypeArgumentSyntax +//@[026:0072) | | | | └─StringTypeLiteralSyntax +//@[026:0072) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2022-09-01'| +//@[072:0073) | | | └─Token(RightChevron) |>| +//@[073:0074) | | ├─Token(Dot) |.| +//@[074:0078) | | └─IdentifierSyntax +//@[074:0078) | | └─Token(Identifier) |name| +//@[078:0079) | ├─Token(NewLine) |\n| resC: sys.array -//@[02:0017) | ├─ObjectTypePropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |resC| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0017) | | └─TypePropertyAccessSyntax -//@[08:0011) | | ├─TypeVariableAccessSyntax -//@[08:0011) | | | └─IdentifierSyntax -//@[08:0011) | | | └─Token(Identifier) |sys| -//@[11:0012) | | ├─Token(Dot) |.| -//@[12:0017) | | └─IdentifierSyntax -//@[12:0017) | | └─Token(Identifier) |array| -//@[17:0018) | ├─Token(NewLine) |\n| - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:0076) | ├─ObjectTypePropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |resD| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0076) | | └─TypePropertyAccessSyntax -//@[08:0071) | | ├─InstanceParameterizedTypeInstantiationSyntax -//@[08:0011) | | | ├─TypeVariableAccessSyntax -//@[08:0011) | | | | └─IdentifierSyntax -//@[08:0011) | | | | └─Token(Identifier) |sys| -//@[11:0012) | | | ├─Token(Dot) |.| -//@[12:0020) | | | ├─IdentifierSyntax -//@[12:0020) | | | | └─Token(Identifier) |resource| -//@[20:0021) | | | ├─Token(LeftChevron) |<| -//@[21:0070) | | | ├─ParameterizedTypeArgumentSyntax -//@[21:0070) | | | | └─StringTypeLiteralSyntax -//@[21:0070) | | | | └─Token(StringComplete) |'az:Microsoft.Storage/storageAccounts@2022-09-01'| -//@[70:0071) | | | └─Token(RightChevron) |>| -//@[71:0072) | | ├─Token(Dot) |.| -//@[72:0076) | | └─IdentifierSyntax -//@[72:0076) | | └─Token(Identifier) |name| -//@[76:0077) | ├─Token(NewLine) |\n| +//@[002:0017) | ├─ObjectTypePropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |resC| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0017) | | └─TypePropertyAccessSyntax +//@[008:0011) | | ├─TypeVariableAccessSyntax +//@[008:0011) | | | └─IdentifierSyntax +//@[008:0011) | | | └─Token(Identifier) |sys| +//@[011:0012) | | ├─Token(Dot) |.| +//@[012:0017) | | └─IdentifierSyntax +//@[012:0017) | | └─Token(Identifier) |array| +//@[017:0018) | ├─Token(NewLine) |\n| + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[002:0081) | ├─ObjectTypePropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |resD| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0081) | | └─TypePropertyAccessSyntax +//@[008:0076) | | ├─InstanceParameterizedTypeInstantiationSyntax +//@[008:0011) | | | ├─TypeVariableAccessSyntax +//@[008:0011) | | | | └─IdentifierSyntax +//@[008:0011) | | | | └─Token(Identifier) |sys| +//@[011:0012) | | | ├─Token(Dot) |.| +//@[012:0025) | | | ├─IdentifierSyntax +//@[012:0025) | | | | └─Token(Identifier) |resourceInput| +//@[025:0026) | | | ├─Token(LeftChevron) |<| +//@[026:0075) | | | ├─ParameterizedTypeArgumentSyntax +//@[026:0075) | | | | └─StringTypeLiteralSyntax +//@[026:0075) | | | | └─Token(StringComplete) |'az:Microsoft.Storage/storageAccounts@2022-09-01'| +//@[075:0076) | | | └─Token(RightChevron) |>| +//@[076:0077) | | ├─Token(Dot) |.| +//@[077:0081) | | └─IdentifierSyntax +//@[077:0081) | | └─Token(Identifier) |name| +//@[081:0082) | ├─Token(NewLine) |\n| } -//@[00:0001) | └─Token(RightBrace) |}| -//@[01:0003) ├─Token(NewLine) |\n\n| +//@[000:0001) | └─Token(RightBrace) |}| +//@[001:0003) ├─Token(NewLine) |\n\n| type strangeFormatting = { -//@[00:0272) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0022) | ├─IdentifierSyntax -//@[05:0022) | | └─Token(Identifier) |strangeFormatting| -//@[23:0024) | ├─Token(Assignment) |=| -//@[25:0272) | └─ObjectTypeSyntax -//@[25:0026) | ├─Token(LeftBrace) |{| -//@[26:0027) | ├─Token(NewLine) |\n| - test: resource< -//@[02:0080) | ├─ObjectTypePropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |test| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0080) | | └─TypePropertyAccessSyntax -//@[08:0075) | | ├─ParameterizedTypeInstantiationSyntax -//@[08:0016) | | | ├─IdentifierSyntax -//@[08:0016) | | | | └─Token(Identifier) |resource| -//@[16:0017) | | | ├─Token(LeftChevron) |<| -//@[17:0019) | | | ├─Token(NewLine) |\n\n| +//@[000:0287) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0022) | ├─IdentifierSyntax +//@[005:0022) | | └─Token(Identifier) |strangeFormatting| +//@[023:0024) | ├─Token(Assignment) |=| +//@[025:0287) | └─ObjectTypeSyntax +//@[025:0026) | ├─Token(LeftBrace) |{| +//@[026:0027) | ├─Token(NewLine) |\n| + test: resourceInput< +//@[002:0085) | ├─ObjectTypePropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |test| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0085) | | └─TypePropertyAccessSyntax +//@[008:0080) | | ├─ParameterizedTypeInstantiationSyntax +//@[008:0021) | | | ├─IdentifierSyntax +//@[008:0021) | | | | └─Token(Identifier) |resourceInput| +//@[021:0022) | | | ├─Token(LeftChevron) |<| +//@[022:0024) | | | ├─Token(NewLine) |\n\n| 'Astronomer.Astro/organizations@2023-08-01-preview' -//@[02:0053) | | | ├─ParameterizedTypeArgumentSyntax -//@[02:0053) | | | | └─StringTypeLiteralSyntax -//@[02:0053) | | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[53:0055) | | | ├─Token(NewLine) |\n\n| +//@[002:0053) | | | ├─ParameterizedTypeArgumentSyntax +//@[002:0053) | | | | └─StringTypeLiteralSyntax +//@[002:0053) | | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[053:0055) | | | ├─Token(NewLine) |\n\n| >.name -//@[00:0001) | | | └─Token(RightChevron) |>| -//@[01:0002) | | ├─Token(Dot) |.| -//@[02:0006) | | └─IdentifierSyntax -//@[02:0006) | | └─Token(Identifier) |name| -//@[06:0007) | ├─Token(NewLine) |\n| - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:0074) | ├─ObjectTypePropertySyntax -//@[02:0007) | | ├─IdentifierSyntax -//@[02:0007) | | | └─Token(Identifier) |test2| -//@[07:0008) | | ├─Token(Colon) |:| -//@[09:0074) | | └─TypePropertyAccessSyntax -//@[09:0069) | | ├─ParameterizedTypeInstantiationSyntax -//@[09:0017) | | | ├─IdentifierSyntax -//@[09:0017) | | | | └─Token(Identifier) |resource| -//@[21:0022) | | | ├─Token(LeftChevron) |<| -//@[22:0068) | | | ├─ParameterizedTypeArgumentSyntax -//@[22:0068) | | | | └─StringTypeLiteralSyntax -//@[22:0068) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[68:0069) | | | └─Token(RightChevron) |>| -//@[69:0070) | | ├─Token(Dot) |.| -//@[70:0074) | | └─IdentifierSyntax -//@[70:0074) | | └─Token(Identifier) |name| -//@[74:0075) | ├─Token(NewLine) |\n| - test3: resource.name -//@[02:0087) | ├─ObjectTypePropertySyntax -//@[02:0007) | | ├─IdentifierSyntax -//@[02:0007) | | | └─Token(Identifier) |test3| -//@[07:0008) | | ├─Token(Colon) |:| -//@[09:0087) | | └─TypePropertyAccessSyntax -//@[09:0082) | | ├─ParameterizedTypeInstantiationSyntax -//@[09:0017) | | | ├─IdentifierSyntax -//@[09:0017) | | | | └─Token(Identifier) |resource| -//@[17:0018) | | | ├─Token(LeftChevron) |<| -//@[26:0072) | | | ├─ParameterizedTypeArgumentSyntax -//@[26:0072) | | | | └─StringTypeLiteralSyntax -//@[26:0072) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[81:0082) | | | └─Token(RightChevron) |>| -//@[82:0083) | | ├─Token(Dot) |.| -//@[83:0087) | | └─IdentifierSyntax -//@[83:0087) | | └─Token(Identifier) |name| -//@[87:0088) | ├─Token(NewLine) |\n| +//@[000:0001) | | | └─Token(RightChevron) |>| +//@[001:0002) | | ├─Token(Dot) |.| +//@[002:0006) | | └─IdentifierSyntax +//@[002:0006) | | └─Token(Identifier) |name| +//@[006:0007) | ├─Token(NewLine) |\n| + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[002:0079) | ├─ObjectTypePropertySyntax +//@[002:0007) | | ├─IdentifierSyntax +//@[002:0007) | | | └─Token(Identifier) |test2| +//@[007:0008) | | ├─Token(Colon) |:| +//@[009:0079) | | └─TypePropertyAccessSyntax +//@[009:0074) | | ├─ParameterizedTypeInstantiationSyntax +//@[009:0022) | | | ├─IdentifierSyntax +//@[009:0022) | | | | └─Token(Identifier) |resourceInput| +//@[026:0027) | | | ├─Token(LeftChevron) |<| +//@[027:0073) | | | ├─ParameterizedTypeArgumentSyntax +//@[027:0073) | | | | └─StringTypeLiteralSyntax +//@[027:0073) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[073:0074) | | | └─Token(RightChevron) |>| +//@[074:0075) | | ├─Token(Dot) |.| +//@[075:0079) | | └─IdentifierSyntax +//@[075:0079) | | └─Token(Identifier) |name| +//@[079:0080) | ├─Token(NewLine) |\n| + test3: resourceInput.name +//@[002:0092) | ├─ObjectTypePropertySyntax +//@[002:0007) | | ├─IdentifierSyntax +//@[002:0007) | | | └─Token(Identifier) |test3| +//@[007:0008) | | ├─Token(Colon) |:| +//@[009:0092) | | └─TypePropertyAccessSyntax +//@[009:0087) | | ├─ParameterizedTypeInstantiationSyntax +//@[009:0022) | | | ├─IdentifierSyntax +//@[009:0022) | | | | └─Token(Identifier) |resourceInput| +//@[022:0023) | | | ├─Token(LeftChevron) |<| +//@[031:0077) | | | ├─ParameterizedTypeArgumentSyntax +//@[031:0077) | | | | └─StringTypeLiteralSyntax +//@[031:0077) | | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:0087) | | | └─Token(RightChevron) |>| +//@[087:0088) | | ├─Token(Dot) |.| +//@[088:0092) | | └─IdentifierSyntax +//@[088:0092) | | └─Token(Identifier) |name| +//@[092:0093) | ├─Token(NewLine) |\n| } -//@[00:0001) | └─Token(RightBrace) |}| -//@[01:0003) ├─Token(NewLine) |\n\n| +//@[000:0001) | └─Token(RightBrace) |}| +//@[001:0003) ├─Token(NewLine) |\n\n| @description('I love space(s)') -//@[00:0120) ├─TypeDeclarationSyntax -//@[00:0031) | ├─DecoratorSyntax -//@[00:0001) | | ├─Token(At) |@| -//@[01:0031) | | └─FunctionCallSyntax -//@[01:0012) | | ├─IdentifierSyntax -//@[01:0012) | | | └─Token(Identifier) |description| -//@[12:0013) | | ├─Token(LeftParen) |(| -//@[13:0030) | | ├─FunctionArgumentSyntax -//@[13:0030) | | | └─StringSyntax -//@[13:0030) | | | └─Token(StringComplete) |'I love space(s)'| -//@[30:0031) | | └─Token(RightParen) |)| -//@[31:0032) | ├─Token(NewLine) |\n| -type test2 = resource< -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0010) | ├─IdentifierSyntax -//@[05:0010) | | └─Token(Identifier) |test2| -//@[11:0012) | ├─Token(Assignment) |=| -//@[13:0088) | └─TypePropertyAccessSyntax -//@[13:0083) | ├─ParameterizedTypeInstantiationSyntax -//@[13:0021) | | ├─IdentifierSyntax -//@[13:0021) | | | └─Token(Identifier) |resource| -//@[21:0022) | | ├─Token(LeftChevron) |<| -//@[22:0024) | | ├─Token(NewLine) |\n\n| +//@[000:0125) ├─TypeDeclarationSyntax +//@[000:0031) | ├─DecoratorSyntax +//@[000:0001) | | ├─Token(At) |@| +//@[001:0031) | | └─FunctionCallSyntax +//@[001:0012) | | ├─IdentifierSyntax +//@[001:0012) | | | └─Token(Identifier) |description| +//@[012:0013) | | ├─Token(LeftParen) |(| +//@[013:0030) | | ├─FunctionArgumentSyntax +//@[013:0030) | | | └─StringSyntax +//@[013:0030) | | | └─Token(StringComplete) |'I love space(s)'| +//@[030:0031) | | └─Token(RightParen) |)| +//@[031:0032) | ├─Token(NewLine) |\n| +type test2 = resourceInput< +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0010) | ├─IdentifierSyntax +//@[005:0010) | | └─Token(Identifier) |test2| +//@[011:0012) | ├─Token(Assignment) |=| +//@[013:0093) | └─TypePropertyAccessSyntax +//@[013:0088) | ├─ParameterizedTypeInstantiationSyntax +//@[013:0026) | | ├─IdentifierSyntax +//@[013:0026) | | | └─Token(Identifier) |resourceInput| +//@[026:0027) | | ├─Token(LeftChevron) |<| +//@[027:0029) | | ├─Token(NewLine) |\n\n| 'Astronomer.Astro/organizations@2023-08-01-preview' -//@[05:0056) | | ├─ParameterizedTypeArgumentSyntax -//@[05:0056) | | | └─StringTypeLiteralSyntax -//@[05:0056) | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[56:0058) | | ├─Token(NewLine) |\n\n| +//@[005:0056) | | ├─ParameterizedTypeArgumentSyntax +//@[005:0056) | | | └─StringTypeLiteralSyntax +//@[005:0056) | | | └─Token(StringComplete) |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[056:0058) | | ├─Token(NewLine) |\n\n| >.name -//@[00:0001) | | └─Token(RightChevron) |>| -//@[01:0002) | ├─Token(Dot) |.| -//@[02:0006) | └─IdentifierSyntax -//@[02:0006) | └─Token(Identifier) |name| -//@[06:0008) ├─Token(NewLine) |\n\n| +//@[000:0001) | | └─Token(RightChevron) |>| +//@[001:0002) | ├─Token(Dot) |.| +//@[002:0006) | └─IdentifierSyntax +//@[002:0006) | └─Token(Identifier) |name| +//@[006:0008) ├─Token(NewLine) |\n\n| -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { -//@[00:0125) ├─ParameterDeclarationSyntax -//@[00:0005) | ├─Token(Identifier) |param| -//@[06:0009) | ├─IdentifierSyntax -//@[06:0009) | | └─Token(Identifier) |bar| -//@[10:0068) | ├─TypePropertyAccessSyntax -//@[10:0057) | | ├─ParameterizedTypeInstantiationSyntax -//@[10:0018) | | | ├─IdentifierSyntax -//@[10:0018) | | | | └─Token(Identifier) |resource| -//@[18:0019) | | | ├─Token(LeftChevron) |<| -//@[19:0056) | | | ├─ParameterizedTypeArgumentSyntax -//@[19:0056) | | | | └─StringTypeLiteralSyntax -//@[19:0056) | | | | └─Token(StringComplete) |'Microsoft.Resources/tags@2022-09-01'| -//@[56:0057) | | | └─Token(RightChevron) |>| -//@[57:0058) | | ├─Token(Dot) |.| -//@[58:0068) | | └─IdentifierSyntax -//@[58:0068) | | └─Token(Identifier) |properties| -//@[69:0125) | └─ParameterDefaultValueSyntax -//@[69:0070) | ├─Token(Assignment) |=| -//@[71:0125) | └─ObjectSyntax -//@[71:0072) | ├─Token(LeftBrace) |{| -//@[72:0073) | ├─Token(NewLine) |\n| +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { +//@[000:0130) ├─ParameterDeclarationSyntax +//@[000:0005) | ├─Token(Identifier) |param| +//@[006:0009) | ├─IdentifierSyntax +//@[006:0009) | | └─Token(Identifier) |bar| +//@[010:0073) | ├─TypePropertyAccessSyntax +//@[010:0062) | | ├─ParameterizedTypeInstantiationSyntax +//@[010:0023) | | | ├─IdentifierSyntax +//@[010:0023) | | | | └─Token(Identifier) |resourceInput| +//@[023:0024) | | | ├─Token(LeftChevron) |<| +//@[024:0061) | | | ├─ParameterizedTypeArgumentSyntax +//@[024:0061) | | | | └─StringTypeLiteralSyntax +//@[024:0061) | | | | └─Token(StringComplete) |'Microsoft.Resources/tags@2022-09-01'| +//@[061:0062) | | | └─Token(RightChevron) |>| +//@[062:0063) | | ├─Token(Dot) |.| +//@[063:0073) | | └─IdentifierSyntax +//@[063:0073) | | └─Token(Identifier) |properties| +//@[074:0130) | └─ParameterDefaultValueSyntax +//@[074:0075) | ├─Token(Assignment) |=| +//@[076:0130) | └─ObjectSyntax +//@[076:0077) | ├─Token(LeftBrace) |{| +//@[077:0078) | ├─Token(NewLine) |\n| tags: { -//@[02:0050) | ├─ObjectPropertySyntax -//@[02:0006) | | ├─IdentifierSyntax -//@[02:0006) | | | └─Token(Identifier) |tags| -//@[06:0007) | | ├─Token(Colon) |:| -//@[08:0050) | | └─ObjectSyntax -//@[08:0009) | | ├─Token(LeftBrace) |{| -//@[09:0010) | | ├─Token(NewLine) |\n| +//@[002:0050) | ├─ObjectPropertySyntax +//@[002:0006) | | ├─IdentifierSyntax +//@[002:0006) | | | └─Token(Identifier) |tags| +//@[006:0007) | | ├─Token(Colon) |:| +//@[008:0050) | | └─ObjectSyntax +//@[008:0009) | | ├─Token(LeftBrace) |{| +//@[009:0010) | | ├─Token(NewLine) |\n| fizz: 'buzz' -//@[04:0016) | | ├─ObjectPropertySyntax -//@[04:0008) | | | ├─IdentifierSyntax -//@[04:0008) | | | | └─Token(Identifier) |fizz| -//@[08:0009) | | | ├─Token(Colon) |:| -//@[10:0016) | | | └─StringSyntax -//@[10:0016) | | | └─Token(StringComplete) |'buzz'| -//@[16:0017) | | ├─Token(NewLine) |\n| +//@[004:0016) | | ├─ObjectPropertySyntax +//@[004:0008) | | | ├─IdentifierSyntax +//@[004:0008) | | | | └─Token(Identifier) |fizz| +//@[008:0009) | | | ├─Token(Colon) |:| +//@[010:0016) | | | └─StringSyntax +//@[010:0016) | | | └─Token(StringComplete) |'buzz'| +//@[016:0017) | | ├─Token(NewLine) |\n| snap: 'crackle' -//@[04:0019) | | ├─ObjectPropertySyntax -//@[04:0008) | | | ├─IdentifierSyntax -//@[04:0008) | | | | └─Token(Identifier) |snap| -//@[08:0009) | | | ├─Token(Colon) |:| -//@[10:0019) | | | └─StringSyntax -//@[10:0019) | | | └─Token(StringComplete) |'crackle'| -//@[19:0020) | | ├─Token(NewLine) |\n| +//@[004:0019) | | ├─ObjectPropertySyntax +//@[004:0008) | | | ├─IdentifierSyntax +//@[004:0008) | | | | └─Token(Identifier) |snap| +//@[008:0009) | | | ├─Token(Colon) |:| +//@[010:0019) | | | └─StringSyntax +//@[010:0019) | | | └─Token(StringComplete) |'crackle'| +//@[019:0020) | | ├─Token(NewLine) |\n| } -//@[02:0003) | | └─Token(RightBrace) |}| -//@[03:0004) | ├─Token(NewLine) |\n| +//@[002:0003) | | └─Token(RightBrace) |}| +//@[003:0004) | ├─Token(NewLine) |\n| } -//@[00:0001) | └─Token(RightBrace) |}| -//@[01:0003) ├─Token(NewLine) |\n\n| +//@[000:0001) | └─Token(RightBrace) |}| +//@[001:0003) ├─Token(NewLine) |\n\n| -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -//@[00:0096) ├─OutputDeclarationSyntax -//@[00:0006) | ├─Token(Identifier) |output| -//@[07:0010) | ├─IdentifierSyntax -//@[07:0010) | | └─Token(Identifier) |baz| -//@[11:0087) | ├─TypePropertyAccessSyntax -//@[11:0082) | | ├─ParameterizedTypeInstantiationSyntax -//@[11:0019) | | | ├─IdentifierSyntax -//@[11:0019) | | | | └─Token(Identifier) |resource| -//@[19:0020) | | | ├─Token(LeftChevron) |<| -//@[20:0081) | | | ├─ParameterizedTypeArgumentSyntax -//@[20:0081) | | | | └─StringTypeLiteralSyntax -//@[20:0081) | | | | └─Token(StringComplete) |'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'| -//@[81:0082) | | | └─Token(RightChevron) |>| -//@[82:0083) | | ├─Token(Dot) |.| -//@[83:0087) | | └─IdentifierSyntax -//@[83:0087) | | └─Token(Identifier) |name| -//@[88:0089) | ├─Token(Assignment) |=| -//@[90:0096) | └─StringSyntax -//@[90:0096) | └─Token(StringComplete) |'myId'| -//@[96:0098) ├─Token(NewLine) |\n\n| +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +//@[000:0101) ├─OutputDeclarationSyntax +//@[000:0006) | ├─Token(Identifier) |output| +//@[007:0010) | ├─IdentifierSyntax +//@[007:0010) | | └─Token(Identifier) |baz| +//@[011:0092) | ├─TypePropertyAccessSyntax +//@[011:0087) | | ├─ParameterizedTypeInstantiationSyntax +//@[011:0024) | | | ├─IdentifierSyntax +//@[011:0024) | | | | └─Token(Identifier) |resourceInput| +//@[024:0025) | | | ├─Token(LeftChevron) |<| +//@[025:0086) | | | ├─ParameterizedTypeArgumentSyntax +//@[025:0086) | | | | └─StringTypeLiteralSyntax +//@[025:0086) | | | | └─Token(StringComplete) |'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'| +//@[086:0087) | | | └─Token(RightChevron) |>| +//@[087:0088) | | ├─Token(Dot) |.| +//@[088:0092) | | └─IdentifierSyntax +//@[088:0092) | | └─Token(Identifier) |name| +//@[093:0094) | ├─Token(Assignment) |=| +//@[095:0101) | └─StringSyntax +//@[095:0101) | └─Token(StringComplete) |'myId'| +//@[101:0103) ├─Token(NewLine) |\n\n| -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:0087) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0023) | ├─IdentifierSyntax -//@[05:0023) | | └─Token(Identifier) |storageAccountName| -//@[24:0025) | ├─Token(Assignment) |=| -//@[26:0087) | └─TypePropertyAccessSyntax -//@[26:0082) | ├─ParameterizedTypeInstantiationSyntax -//@[26:0034) | | ├─IdentifierSyntax -//@[26:0034) | | | └─Token(Identifier) |resource| -//@[34:0035) | | ├─Token(LeftChevron) |<| -//@[35:0081) | | ├─ParameterizedTypeArgumentSyntax -//@[35:0081) | | | └─StringTypeLiteralSyntax -//@[35:0081) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[81:0082) | | └─Token(RightChevron) |>| -//@[82:0083) | ├─Token(Dot) |.| -//@[83:0087) | └─IdentifierSyntax -//@[83:0087) | └─Token(Identifier) |name| -//@[87:0088) ├─Token(NewLine) |\n| -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -//@[00:0097) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0017) | ├─IdentifierSyntax -//@[05:0017) | | └─Token(Identifier) |accessPolicy| -//@[18:0019) | ├─Token(Assignment) |=| -//@[20:0097) | └─TypeItemsAccessSyntax -//@[20:0094) | ├─TypePropertyAccessSyntax -//@[20:0079) | | ├─TypePropertyAccessSyntax -//@[20:0068) | | | ├─ParameterizedTypeInstantiationSyntax -//@[20:0028) | | | | ├─IdentifierSyntax -//@[20:0028) | | | | | └─Token(Identifier) |resource| -//@[28:0029) | | | | ├─Token(LeftChevron) |<| -//@[29:0067) | | | | ├─ParameterizedTypeArgumentSyntax -//@[29:0067) | | | | | └─StringTypeLiteralSyntax -//@[29:0067) | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[67:0068) | | | | └─Token(RightChevron) |>| -//@[68:0069) | | | ├─Token(Dot) |.| -//@[69:0079) | | | └─IdentifierSyntax -//@[69:0079) | | | └─Token(Identifier) |properties| -//@[79:0080) | | ├─Token(Dot) |.| -//@[80:0094) | | └─IdentifierSyntax -//@[80:0094) | | └─Token(Identifier) |accessPolicies| -//@[94:0095) | ├─Token(LeftSquare) |[| -//@[95:0096) | ├─Token(Asterisk) |*| -//@[96:0097) | └─Token(RightSquare) |]| -//@[97:0098) ├─Token(NewLine) |\n| -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* -//@[00:0076) ├─TypeDeclarationSyntax -//@[00:0004) | ├─Token(Identifier) |type| -//@[05:0008) | ├─IdentifierSyntax -//@[05:0008) | | └─Token(Identifier) |tag| -//@[09:0010) | ├─Token(Assignment) |=| -//@[11:0076) | └─TypeAdditionalPropertiesAccessSyntax -//@[11:0074) | ├─TypePropertyAccessSyntax -//@[11:0069) | | ├─TypePropertyAccessSyntax -//@[11:0058) | | | ├─ParameterizedTypeInstantiationSyntax -//@[11:0019) | | | | ├─IdentifierSyntax -//@[11:0019) | | | | | └─Token(Identifier) |resource| -//@[19:0020) | | | | ├─Token(LeftChevron) |<| -//@[20:0057) | | | | ├─ParameterizedTypeArgumentSyntax -//@[20:0057) | | | | | └─StringTypeLiteralSyntax -//@[20:0057) | | | | | └─Token(StringComplete) |'Microsoft.Resources/tags@2022-09-01'| -//@[57:0058) | | | | └─Token(RightChevron) |>| -//@[58:0059) | | | ├─Token(Dot) |.| -//@[59:0069) | | | └─IdentifierSyntax -//@[59:0069) | | | └─Token(Identifier) |properties| -//@[69:0070) | | ├─Token(Dot) |.| -//@[70:0074) | | └─IdentifierSyntax -//@[70:0074) | | └─Token(Identifier) |tags| -//@[74:0075) | ├─Token(Dot) |.| -//@[75:0076) | └─Token(Asterisk) |*| -//@[76:0077) ├─Token(NewLine) |\n| +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[000:0092) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0023) | ├─IdentifierSyntax +//@[005:0023) | | └─Token(Identifier) |storageAccountName| +//@[024:0025) | ├─Token(Assignment) |=| +//@[026:0092) | └─TypePropertyAccessSyntax +//@[026:0087) | ├─ParameterizedTypeInstantiationSyntax +//@[026:0039) | | ├─IdentifierSyntax +//@[026:0039) | | | └─Token(Identifier) |resourceInput| +//@[039:0040) | | ├─Token(LeftChevron) |<| +//@[040:0086) | | ├─ParameterizedTypeArgumentSyntax +//@[040:0086) | | | └─StringTypeLiteralSyntax +//@[040:0086) | | | └─Token(StringComplete) |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:0087) | | └─Token(RightChevron) |>| +//@[087:0088) | ├─Token(Dot) |.| +//@[088:0092) | └─IdentifierSyntax +//@[088:0092) | └─Token(Identifier) |name| +//@[092:0093) ├─Token(NewLine) |\n| +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +//@[000:0102) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0017) | ├─IdentifierSyntax +//@[005:0017) | | └─Token(Identifier) |accessPolicy| +//@[018:0019) | ├─Token(Assignment) |=| +//@[020:0102) | └─TypeItemsAccessSyntax +//@[020:0099) | ├─TypePropertyAccessSyntax +//@[020:0084) | | ├─TypePropertyAccessSyntax +//@[020:0073) | | | ├─ParameterizedTypeInstantiationSyntax +//@[020:0033) | | | | ├─IdentifierSyntax +//@[020:0033) | | | | | └─Token(Identifier) |resourceInput| +//@[033:0034) | | | | ├─Token(LeftChevron) |<| +//@[034:0072) | | | | ├─ParameterizedTypeArgumentSyntax +//@[034:0072) | | | | | └─StringTypeLiteralSyntax +//@[034:0072) | | | | | └─Token(StringComplete) |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[072:0073) | | | | └─Token(RightChevron) |>| +//@[073:0074) | | | ├─Token(Dot) |.| +//@[074:0084) | | | └─IdentifierSyntax +//@[074:0084) | | | └─Token(Identifier) |properties| +//@[084:0085) | | ├─Token(Dot) |.| +//@[085:0099) | | └─IdentifierSyntax +//@[085:0099) | | └─Token(Identifier) |accessPolicies| +//@[099:0100) | ├─Token(LeftSquare) |[| +//@[100:0101) | ├─Token(Asterisk) |*| +//@[101:0102) | └─Token(RightSquare) |]| +//@[102:0103) ├─Token(NewLine) |\n| +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +//@[000:0081) ├─TypeDeclarationSyntax +//@[000:0004) | ├─Token(Identifier) |type| +//@[005:0008) | ├─IdentifierSyntax +//@[005:0008) | | └─Token(Identifier) |tag| +//@[009:0010) | ├─Token(Assignment) |=| +//@[011:0081) | └─TypeAdditionalPropertiesAccessSyntax +//@[011:0079) | ├─TypePropertyAccessSyntax +//@[011:0074) | | ├─TypePropertyAccessSyntax +//@[011:0063) | | | ├─ParameterizedTypeInstantiationSyntax +//@[011:0024) | | | | ├─IdentifierSyntax +//@[011:0024) | | | | | └─Token(Identifier) |resourceInput| +//@[024:0025) | | | | ├─Token(LeftChevron) |<| +//@[025:0062) | | | | ├─ParameterizedTypeArgumentSyntax +//@[025:0062) | | | | | └─StringTypeLiteralSyntax +//@[025:0062) | | | | | └─Token(StringComplete) |'Microsoft.Resources/tags@2022-09-01'| +//@[062:0063) | | | | └─Token(RightChevron) |>| +//@[063:0064) | | | ├─Token(Dot) |.| +//@[064:0074) | | | └─IdentifierSyntax +//@[064:0074) | | | └─Token(Identifier) |properties| +//@[074:0075) | | ├─Token(Dot) |.| +//@[075:0079) | | └─IdentifierSyntax +//@[075:0079) | | └─Token(Identifier) |tags| +//@[079:0080) | ├─Token(Dot) |.| +//@[080:0081) | └─Token(Asterisk) |*| +//@[081:0082) ├─Token(NewLine) |\n| -//@[00:0000) └─Token(EndOfFile) || +//@[000:0000) └─Token(EndOfFile) || diff --git a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.tokens.bicep b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.tokens.bicep index 75cf974cdb3..31a12770b7e 100644 --- a/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.tokens.bicep +++ b/src/Bicep.Core.Samples/Files/baselines/ResourceDerivedTypes_LF/main.tokens.bicep @@ -1,225 +1,225 @@ -type foo = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:04) Identifier |type| -//@[05:08) Identifier |foo| -//@[09:10) Assignment |=| -//@[11:19) Identifier |resource| -//@[19:20) LeftChevron |<| -//@[20:66) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[66:67) RightChevron |>| -//@[67:68) Dot |.| -//@[68:72) Identifier |name| -//@[72:74) NewLine |\n\n| +type foo = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[000:004) Identifier |type| +//@[005:008) Identifier |foo| +//@[009:010) Assignment |=| +//@[011:024) Identifier |resourceInput| +//@[024:025) LeftChevron |<| +//@[025:071) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[071:072) RightChevron |>| +//@[072:073) Dot |.| +//@[073:077) Identifier |name| +//@[077:079) NewLine |\n\n| type test = { -//@[00:04) Identifier |type| -//@[05:09) Identifier |test| -//@[10:11) Assignment |=| -//@[12:13) LeftBrace |{| -//@[13:14) NewLine |\n| - resA: resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:06) Identifier |resA| -//@[06:07) Colon |:| -//@[08:16) Identifier |resource| -//@[16:17) LeftChevron |<| -//@[17:63) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[63:64) RightChevron |>| -//@[64:65) Dot |.| -//@[65:69) Identifier |name| -//@[69:70) NewLine |\n| - resB: sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:06) Identifier |resB| -//@[06:07) Colon |:| -//@[08:11) Identifier |sys| -//@[11:12) Dot |.| -//@[12:20) Identifier |resource| -//@[20:21) LeftChevron |<| -//@[21:67) StringComplete |'Microsoft.Storage/storageAccounts@2022-09-01'| -//@[67:68) RightChevron |>| -//@[68:69) Dot |.| -//@[69:73) Identifier |name| -//@[73:74) NewLine |\n| +//@[000:004) Identifier |type| +//@[005:009) Identifier |test| +//@[010:011) Assignment |=| +//@[012:013) LeftBrace |{| +//@[013:014) NewLine |\n| + resA: resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[002:006) Identifier |resA| +//@[006:007) Colon |:| +//@[008:021) Identifier |resourceInput| +//@[021:022) LeftChevron |<| +//@[022:068) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[068:069) RightChevron |>| +//@[069:070) Dot |.| +//@[070:074) Identifier |name| +//@[074:075) NewLine |\n| + resB: sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[002:006) Identifier |resB| +//@[006:007) Colon |:| +//@[008:011) Identifier |sys| +//@[011:012) Dot |.| +//@[012:025) Identifier |resourceInput| +//@[025:026) LeftChevron |<| +//@[026:072) StringComplete |'Microsoft.Storage/storageAccounts@2022-09-01'| +//@[072:073) RightChevron |>| +//@[073:074) Dot |.| +//@[074:078) Identifier |name| +//@[078:079) NewLine |\n| resC: sys.array -//@[02:06) Identifier |resC| -//@[06:07) Colon |:| -//@[08:11) Identifier |sys| -//@[11:12) Dot |.| -//@[12:17) Identifier |array| -//@[17:18) NewLine |\n| - resD: sys.resource<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name -//@[02:06) Identifier |resD| -//@[06:07) Colon |:| -//@[08:11) Identifier |sys| -//@[11:12) Dot |.| -//@[12:20) Identifier |resource| -//@[20:21) LeftChevron |<| -//@[21:70) StringComplete |'az:Microsoft.Storage/storageAccounts@2022-09-01'| -//@[70:71) RightChevron |>| -//@[71:72) Dot |.| -//@[72:76) Identifier |name| -//@[76:77) NewLine |\n| +//@[002:006) Identifier |resC| +//@[006:007) Colon |:| +//@[008:011) Identifier |sys| +//@[011:012) Dot |.| +//@[012:017) Identifier |array| +//@[017:018) NewLine |\n| + resD: sys.resourceInput<'az:Microsoft.Storage/storageAccounts@2022-09-01'>.name +//@[002:006) Identifier |resD| +//@[006:007) Colon |:| +//@[008:011) Identifier |sys| +//@[011:012) Dot |.| +//@[012:025) Identifier |resourceInput| +//@[025:026) LeftChevron |<| +//@[026:075) StringComplete |'az:Microsoft.Storage/storageAccounts@2022-09-01'| +//@[075:076) RightChevron |>| +//@[076:077) Dot |.| +//@[077:081) Identifier |name| +//@[081:082) NewLine |\n| } -//@[00:01) RightBrace |}| -//@[01:03) NewLine |\n\n| +//@[000:001) RightBrace |}| +//@[001:003) NewLine |\n\n| type strangeFormatting = { -//@[00:04) Identifier |type| -//@[05:22) Identifier |strangeFormatting| -//@[23:24) Assignment |=| -//@[25:26) LeftBrace |{| -//@[26:27) NewLine |\n| - test: resource< -//@[02:06) Identifier |test| -//@[06:07) Colon |:| -//@[08:16) Identifier |resource| -//@[16:17) LeftChevron |<| -//@[17:19) NewLine |\n\n| +//@[000:004) Identifier |type| +//@[005:022) Identifier |strangeFormatting| +//@[023:024) Assignment |=| +//@[025:026) LeftBrace |{| +//@[026:027) NewLine |\n| + test: resourceInput< +//@[002:006) Identifier |test| +//@[006:007) Colon |:| +//@[008:021) Identifier |resourceInput| +//@[021:022) LeftChevron |<| +//@[022:024) NewLine |\n\n| 'Astronomer.Astro/organizations@2023-08-01-preview' -//@[02:53) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[53:55) NewLine |\n\n| +//@[002:053) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[053:055) NewLine |\n\n| >.name -//@[00:01) RightChevron |>| -//@[01:02) Dot |.| -//@[02:06) Identifier |name| -//@[06:07) NewLine |\n| - test2: resource <'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[02:07) Identifier |test2| -//@[07:08) Colon |:| -//@[09:17) Identifier |resource| -//@[21:22) LeftChevron |<| -//@[22:68) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[68:69) RightChevron |>| -//@[69:70) Dot |.| -//@[70:74) Identifier |name| -//@[74:75) NewLine |\n| - test3: resource.name -//@[02:07) Identifier |test3| -//@[07:08) Colon |:| -//@[09:17) Identifier |resource| -//@[17:18) LeftChevron |<| -//@[26:72) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[81:82) RightChevron |>| -//@[82:83) Dot |.| -//@[83:87) Identifier |name| -//@[87:88) NewLine |\n| +//@[000:001) RightChevron |>| +//@[001:002) Dot |.| +//@[002:006) Identifier |name| +//@[006:007) NewLine |\n| + test2: resourceInput <'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[002:007) Identifier |test2| +//@[007:008) Colon |:| +//@[009:022) Identifier |resourceInput| +//@[026:027) LeftChevron |<| +//@[027:073) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[073:074) RightChevron |>| +//@[074:075) Dot |.| +//@[075:079) Identifier |name| +//@[079:080) NewLine |\n| + test3: resourceInput.name +//@[002:007) Identifier |test3| +//@[007:008) Colon |:| +//@[009:022) Identifier |resourceInput| +//@[022:023) LeftChevron |<| +//@[031:077) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:087) RightChevron |>| +//@[087:088) Dot |.| +//@[088:092) Identifier |name| +//@[092:093) NewLine |\n| } -//@[00:01) RightBrace |}| -//@[01:03) NewLine |\n\n| +//@[000:001) RightBrace |}| +//@[001:003) NewLine |\n\n| @description('I love space(s)') -//@[00:01) At |@| -//@[01:12) Identifier |description| -//@[12:13) LeftParen |(| -//@[13:30) StringComplete |'I love space(s)'| -//@[30:31) RightParen |)| -//@[31:32) NewLine |\n| -type test2 = resource< -//@[00:04) Identifier |type| -//@[05:10) Identifier |test2| -//@[11:12) Assignment |=| -//@[13:21) Identifier |resource| -//@[21:22) LeftChevron |<| -//@[22:24) NewLine |\n\n| +//@[000:001) At |@| +//@[001:012) Identifier |description| +//@[012:013) LeftParen |(| +//@[013:030) StringComplete |'I love space(s)'| +//@[030:031) RightParen |)| +//@[031:032) NewLine |\n| +type test2 = resourceInput< +//@[000:004) Identifier |type| +//@[005:010) Identifier |test2| +//@[011:012) Assignment |=| +//@[013:026) Identifier |resourceInput| +//@[026:027) LeftChevron |<| +//@[027:029) NewLine |\n\n| 'Astronomer.Astro/organizations@2023-08-01-preview' -//@[05:56) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| -//@[56:58) NewLine |\n\n| +//@[005:056) StringComplete |'Astronomer.Astro/organizations@2023-08-01-preview'| +//@[056:058) NewLine |\n\n| >.name -//@[00:01) RightChevron |>| -//@[01:02) Dot |.| -//@[02:06) Identifier |name| -//@[06:08) NewLine |\n\n| +//@[000:001) RightChevron |>| +//@[001:002) Dot |.| +//@[002:006) Identifier |name| +//@[006:008) NewLine |\n\n| -param bar resource<'Microsoft.Resources/tags@2022-09-01'>.properties = { -//@[00:05) Identifier |param| -//@[06:09) Identifier |bar| -//@[10:18) Identifier |resource| -//@[18:19) LeftChevron |<| -//@[19:56) StringComplete |'Microsoft.Resources/tags@2022-09-01'| -//@[56:57) RightChevron |>| -//@[57:58) Dot |.| -//@[58:68) Identifier |properties| -//@[69:70) Assignment |=| -//@[71:72) LeftBrace |{| -//@[72:73) NewLine |\n| +param bar resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties = { +//@[000:005) Identifier |param| +//@[006:009) Identifier |bar| +//@[010:023) Identifier |resourceInput| +//@[023:024) LeftChevron |<| +//@[024:061) StringComplete |'Microsoft.Resources/tags@2022-09-01'| +//@[061:062) RightChevron |>| +//@[062:063) Dot |.| +//@[063:073) Identifier |properties| +//@[074:075) Assignment |=| +//@[076:077) LeftBrace |{| +//@[077:078) NewLine |\n| tags: { -//@[02:06) Identifier |tags| -//@[06:07) Colon |:| -//@[08:09) LeftBrace |{| -//@[09:10) NewLine |\n| +//@[002:006) Identifier |tags| +//@[006:007) Colon |:| +//@[008:009) LeftBrace |{| +//@[009:010) NewLine |\n| fizz: 'buzz' -//@[04:08) Identifier |fizz| -//@[08:09) Colon |:| -//@[10:16) StringComplete |'buzz'| -//@[16:17) NewLine |\n| +//@[004:008) Identifier |fizz| +//@[008:009) Colon |:| +//@[010:016) StringComplete |'buzz'| +//@[016:017) NewLine |\n| snap: 'crackle' -//@[04:08) Identifier |snap| -//@[08:09) Colon |:| -//@[10:19) StringComplete |'crackle'| -//@[19:20) NewLine |\n| +//@[004:008) Identifier |snap| +//@[008:009) Colon |:| +//@[010:019) StringComplete |'crackle'| +//@[019:020) NewLine |\n| } -//@[02:03) RightBrace |}| -//@[03:04) NewLine |\n| +//@[002:003) RightBrace |}| +//@[003:004) NewLine |\n| } -//@[00:01) RightBrace |}| -//@[01:03) NewLine |\n\n| +//@[000:001) RightBrace |}| +//@[001:003) NewLine |\n\n| -output baz resource<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' -//@[00:06) Identifier |output| -//@[07:10) Identifier |baz| -//@[11:19) Identifier |resource| -//@[19:20) LeftChevron |<| -//@[20:81) StringComplete |'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'| -//@[81:82) RightChevron |>| -//@[82:83) Dot |.| -//@[83:87) Identifier |name| -//@[88:89) Assignment |=| -//@[90:96) StringComplete |'myId'| -//@[96:98) NewLine |\n\n| +output baz resourceInput<'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'>.name = 'myId' +//@[000:006) Identifier |output| +//@[007:010) Identifier |baz| +//@[011:024) Identifier |resourceInput| +//@[024:025) LeftChevron |<| +//@[025:086) StringComplete |'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31'| +//@[086:087) RightChevron |>| +//@[087:088) Dot |.| +//@[088:092) Identifier |name| +//@[093:094) Assignment |=| +//@[095:101) StringComplete |'myId'| +//@[101:103) NewLine |\n\n| -type storageAccountName = resource<'Microsoft.Storage/storageAccounts@2023-01-01'>.name -//@[00:04) Identifier |type| -//@[05:23) Identifier |storageAccountName| -//@[24:25) Assignment |=| -//@[26:34) Identifier |resource| -//@[34:35) LeftChevron |<| -//@[35:81) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| -//@[81:82) RightChevron |>| -//@[82:83) Dot |.| -//@[83:87) Identifier |name| -//@[87:88) NewLine |\n| -type accessPolicy = resource<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] -//@[00:04) Identifier |type| -//@[05:17) Identifier |accessPolicy| -//@[18:19) Assignment |=| -//@[20:28) Identifier |resource| -//@[28:29) LeftChevron |<| -//@[29:67) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| -//@[67:68) RightChevron |>| -//@[68:69) Dot |.| -//@[69:79) Identifier |properties| -//@[79:80) Dot |.| -//@[80:94) Identifier |accessPolicies| -//@[94:95) LeftSquare |[| -//@[95:96) Asterisk |*| -//@[96:97) RightSquare |]| -//@[97:98) NewLine |\n| -type tag = resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* -//@[00:04) Identifier |type| -//@[05:08) Identifier |tag| -//@[09:10) Assignment |=| -//@[11:19) Identifier |resource| -//@[19:20) LeftChevron |<| -//@[20:57) StringComplete |'Microsoft.Resources/tags@2022-09-01'| -//@[57:58) RightChevron |>| -//@[58:59) Dot |.| -//@[59:69) Identifier |properties| -//@[69:70) Dot |.| -//@[70:74) Identifier |tags| -//@[74:75) Dot |.| -//@[75:76) Asterisk |*| -//@[76:77) NewLine |\n| +type storageAccountName = resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.name +//@[000:004) Identifier |type| +//@[005:023) Identifier |storageAccountName| +//@[024:025) Assignment |=| +//@[026:039) Identifier |resourceInput| +//@[039:040) LeftChevron |<| +//@[040:086) StringComplete |'Microsoft.Storage/storageAccounts@2023-01-01'| +//@[086:087) RightChevron |>| +//@[087:088) Dot |.| +//@[088:092) Identifier |name| +//@[092:093) NewLine |\n| +type accessPolicy = resourceInput<'Microsoft.KeyVault/vaults@2022-07-01'>.properties.accessPolicies[*] +//@[000:004) Identifier |type| +//@[005:017) Identifier |accessPolicy| +//@[018:019) Assignment |=| +//@[020:033) Identifier |resourceInput| +//@[033:034) LeftChevron |<| +//@[034:072) StringComplete |'Microsoft.KeyVault/vaults@2022-07-01'| +//@[072:073) RightChevron |>| +//@[073:074) Dot |.| +//@[074:084) Identifier |properties| +//@[084:085) Dot |.| +//@[085:099) Identifier |accessPolicies| +//@[099:100) LeftSquare |[| +//@[100:101) Asterisk |*| +//@[101:102) RightSquare |]| +//@[102:103) NewLine |\n| +type tag = resourceInput<'Microsoft.Resources/tags@2022-09-01'>.properties.tags.* +//@[000:004) Identifier |type| +//@[005:008) Identifier |tag| +//@[009:010) Assignment |=| +//@[011:024) Identifier |resourceInput| +//@[024:025) LeftChevron |<| +//@[025:062) StringComplete |'Microsoft.Resources/tags@2022-09-01'| +//@[062:063) RightChevron |>| +//@[063:064) Dot |.| +//@[064:074) Identifier |properties| +//@[074:075) Dot |.| +//@[075:079) Identifier |tags| +//@[079:080) Dot |.| +//@[080:081) Asterisk |*| +//@[081:082) NewLine |\n| -//@[00:00) EndOfFile || +//@[000:000) EndOfFile || diff --git a/src/Bicep.Core.UnitTests/Diagnostics/ErrorBuilderTests.cs b/src/Bicep.Core.UnitTests/Diagnostics/ErrorBuilderTests.cs index 44a843122ce..8e8be614d76 100644 --- a/src/Bicep.Core.UnitTests/Diagnostics/ErrorBuilderTests.cs +++ b/src/Bicep.Core.UnitTests/Diagnostics/ErrorBuilderTests.cs @@ -201,6 +201,15 @@ private static object CreateMockParameter(ParameterInfo parameter, int index) TestSyntaxFactory.CreateVariableAccess("identifier")); } + if (parameter.ParameterType == typeof(ParameterizedTypeInstantiationSyntaxBase)) + { + return new ParameterizedTypeInstantiationSyntax( + TestSyntaxFactory.CreateIdentifier("foo"), + SyntaxFactory.CreateToken(TokenType.LeftChevron), + TestSyntaxFactory.CreateString("RP.Namespace/widgets@v1").AsEnumerable(), + SyntaxFactory.CreateToken(TokenType.RightChevron)); + } + if (parameter.ParameterType == typeof(ExportMetadataKind)) { return ExportMetadataKind.Error; diff --git a/src/Bicep.Core.UnitTests/Parsing/ParserTests.cs b/src/Bicep.Core.UnitTests/Parsing/ParserTests.cs index 0636a707955..9a737b4c298 100644 --- a/src/Bicep.Core.UnitTests/Parsing/ParserTests.cs +++ b/src/Bicep.Core.UnitTests/Parsing/ParserTests.cs @@ -537,13 +537,13 @@ public void Wildcard_import_should_parse_successfully() [TestMethod] public void Parameterized_type_should_parse_successfully() { - var typeStatement = "type saType = resource<'Microsoft.Storage/storageAccounts@2022-09-01'>"; + var typeStatement = "type saType = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>"; var parsed = ParserHelper.Parse(typeStatement); var statement = parsed.Declarations.Single().Should().BeOfType().Subject; var imported = statement.Value.Should().BeOfType().Subject; - imported.Name.IdentifierName.Should().Be("resource"); + imported.Name.IdentifierName.Should().Be("resourceInput"); imported.Arguments.Should().HaveCount(1); var singleParam = imported.Arguments.Single().Expression.Should().BeOfType().Subject; @@ -554,13 +554,13 @@ public void Parameterized_type_should_parse_successfully() [TestMethod] public void Qualified_parameterized_type_should_parse_successfully() { - var typeStatement = "type saType = sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'>"; + var typeStatement = "type saType = sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'>"; var parsed = ParserHelper.Parse(typeStatement); var statement = parsed.Declarations.Single().Should().BeOfType().Subject; var imported = statement.Value.Should().BeOfType().Subject; - imported.PropertyName.IdentifierName.Should().Be("resource"); + imported.PropertyName.IdentifierName.Should().Be("resourceInput"); imported.Arguments.Should().HaveCount(1); var singleParam = imported.Arguments.Single().Expression.Should().BeOfType().Subject; diff --git a/src/Bicep.Core.UnitTests/TypeSystem/ResourceDerivedTypeResolverTests.cs b/src/Bicep.Core.UnitTests/TypeSystem/ResourceDerivedTypeResolverTests.cs index 132271aa1da..fbaad14eae3 100644 --- a/src/Bicep.Core.UnitTests/TypeSystem/ResourceDerivedTypeResolverTests.cs +++ b/src/Bicep.Core.UnitTests/TypeSystem/ResourceDerivedTypeResolverTests.cs @@ -62,7 +62,7 @@ public void Hydrates_array_item_types() var hydrated = TypeFactory.CreateBooleanLiteralType(false); var (sut, unhydratedTypeRef) = SetupResolver(hydrated); - var containsUnresolved = TypeFactory.CreateArrayType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)); + var containsUnresolved = TypeFactory.CreateArrayType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)); sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType() .Subject.Item.Should().BeSameAs(hydrated); } @@ -73,7 +73,7 @@ public void Hydrates_tuple_item_types() var hydrated = TypeFactory.CreateBooleanLiteralType(false); var (sut, unhydratedTypeRef) = SetupResolver(hydrated); - var containsUnresolved = new TupleType([new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)], + var containsUnresolved = new TupleType([new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)], TypeSymbolValidationFlags.Default); sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType() .Subject.Items.First().Should().BeSameAs(hydrated); @@ -93,7 +93,7 @@ public void Hydrates_discriminated_object_variant_types() "property", new ITypeReference[] { - new UnresolvedResourceDerivedPartialObjectType(unhydratedTypeRef, [], "property", "foo"), + new UnresolvedResourceDerivedPartialObjectType(unhydratedTypeRef, [], ResourceDerivedTypeVariant.None, "property", "foo"), new ObjectType("bar", TypeSymbolValidationFlags.Default, new TypeProperty("property", TypeFactory.CreateStringLiteralType("bar")).AsEnumerable(), @@ -112,7 +112,7 @@ public void Hydrates_object_property_types() var containsUnresolved = new ObjectType("object", TypeSymbolValidationFlags.Default, - new TypeProperty("property", new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)).AsEnumerable(), + new TypeProperty("property", new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)).AsEnumerable(), null); sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType() @@ -128,7 +128,7 @@ public void Hydrates_object_additionalProperties_types() var containsUnresolved = new ObjectType("object", TypeSymbolValidationFlags.Default, ImmutableArray.Empty, - new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)); + new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)); var hydratedContainer = sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType().Subject; hydratedContainer.AdditionalPropertiesType.Should().NotBeNull(); @@ -142,7 +142,7 @@ public void Hydrates_union_member_types() var (sut, unhydratedTypeRef) = SetupResolver(hydrated); var containsUnresolved = TypeHelper.CreateTypeUnion(LanguageConstants.String, - new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)); + new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)); sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType() .Subject.Members.Should().Contain(hydrated); @@ -154,7 +154,7 @@ public void Hydrates_wrapped_types() var hydrated = TypeFactory.CreateBooleanLiteralType(false); var (sut, unhydratedTypeRef) = SetupResolver(hydrated); - var containsUnresolved = new TypeType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)); + var containsUnresolved = new TypeType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)); sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType() .Subject.Unwrapped.Should().BeSameAs(hydrated); @@ -168,11 +168,11 @@ public void Hydrates_lambda_types() var containsUnresolved = new LambdaType( [ - TypeFactory.CreateArrayType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)), - new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any), + TypeFactory.CreateArrayType(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)), + new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input), ], [], - new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any)); + new UnresolvedResourceDerivedType(unhydratedTypeRef, [], LanguageConstants.Any, ResourceDerivedTypeVariant.Input)); var bound = sut.ResolveResourceDerivedTypes(containsUnresolved).Should().BeOfType().Subject; bound.ArgumentTypes.Should().SatisfyRespectively( @@ -238,7 +238,7 @@ public void Emits_diagnostic_and_uses_fallback_type_when_resource_not_found() ResourceDerivedTypeResolver sut = new(binderMock.Object); var fallbackType = LanguageConstants.SecureString; - sut.ResolveResourceDerivedTypes(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], fallbackType)).Should().BeSameAs(fallbackType); + sut.ResolveResourceDerivedTypes(new UnresolvedResourceDerivedType(unhydratedTypeRef, [], fallbackType, ResourceDerivedTypeVariant.Input)).Should().BeSameAs(fallbackType); resourceTypeProviderMock.Verify(x => x.TryGetDefinedType(stubbedNamespaceType, unhydratedTypeRef, ResourceTypeGenerationFlags.None), Times.Once()); resourceTypeProviderMock.Verify(x => x.TryGenerateFallbackType(stubbedNamespaceType, unhydratedTypeRef, ResourceTypeGenerationFlags.None), Times.Once()); @@ -248,40 +248,98 @@ public void Emits_diagnostic_and_uses_fallback_type_when_resource_not_found() public void Supports_pointers_to_partial_resource_body_types() { var targetType = TypeFactory.CreateBooleanLiteralType(false); - var hydrated = new ObjectType("object", + var hydrated = new ObjectType( + "object", TypeSymbolValidationFlags.Default, - ImmutableArray.Create(new TypeProperty("property", + ImmutableArray.Create(new TypeProperty( + "property", new TupleType( - [ - new ObjectType("dictionary", - TypeSymbolValidationFlags.Default, - ImmutableArray.Empty, - TypeFactory.CreateArrayType(new DiscriminatedObjectType("taggedUnion", - TypeSymbolValidationFlags.Default, - "type", - ImmutableArray.Create( - new ObjectType("fooVariant", - TypeSymbolValidationFlags.Default, - ImmutableArray.Create( - new TypeProperty("type", TypeFactory.CreateStringLiteralType("foo")), - new TypeProperty("property", LanguageConstants.Int)), - null), - new ObjectType("barVariant", - TypeSymbolValidationFlags.Default, - ImmutableArray.Create( - new TypeProperty("type", TypeFactory.CreateStringLiteralType("bar")), - new TypeProperty("property", targetType)), - null))))), - ], - TypeSymbolValidationFlags.Default))), + [ + new ObjectType( + "dictionary", + TypeSymbolValidationFlags.Default, + ImmutableArray.Empty, + TypeFactory.CreateArrayType(new DiscriminatedObjectType( + "taggedUnion", + TypeSymbolValidationFlags.Default, + "type", + ImmutableArray.Create( + new ObjectType( + "fooVariant", + TypeSymbolValidationFlags.Default, + ImmutableArray.Create( + new TypeProperty("type", TypeFactory.CreateStringLiteralType("foo")), + new TypeProperty("property", LanguageConstants.Int)), + null), + new ObjectType( + "barVariant", + TypeSymbolValidationFlags.Default, + ImmutableArray.Create( + new TypeProperty("type", TypeFactory.CreateStringLiteralType("bar")), + new TypeProperty("property", targetType)), + null))))), + ], + TypeSymbolValidationFlags.Default))), null); var (sut, unhydratedTypeRef) = SetupResolver(hydrated); - UnresolvedResourceDerivedType unresolved = new(unhydratedTypeRef, + UnresolvedResourceDerivedType unresolved = new( + unhydratedTypeRef, ["properties", "property", "prefixItems", "0", "additionalProperties", "items", "discriminator", "mapping", "bar", "properties", "property"], - LanguageConstants.Any); + LanguageConstants.Any, + ResourceDerivedTypeVariant.Input); var bound = sut.ResolveResourceDerivedTypes(unresolved); bound.Should().BeSameAs(targetType); } + + [TestMethod] + public void Input_variant_strips_WriteOnly_flags() + { + var hydrated = new ObjectType( + "object", + TypeSymbolValidationFlags.Default, + ImmutableArray.Create(new TypeProperty( + "property", + LanguageConstants.String, + TypePropertyFlags.WriteOnly)), + null); + var (sut, unhydratedTypeRef) = SetupResolver(hydrated); + + UnresolvedResourceDerivedType unresolved = new( + unhydratedTypeRef, + [], + LanguageConstants.Any, + ResourceDerivedTypeVariant.Input); + + var bound = sut.ResolveResourceDerivedTypes(unresolved); + var boundObject = bound.Should().BeAssignableTo().Subject; + boundObject.Properties.TryGetValue("property", out var property).Should().BeTrue(); + property!.Flags.Should().NotHaveFlag(TypePropertyFlags.WriteOnly); + } + + [TestMethod] + public void Output_variant_strips_ReadOnly_flags() + { + var hydrated = new ObjectType( + "object", + TypeSymbolValidationFlags.Default, + ImmutableArray.Create(new TypeProperty( + "property", + LanguageConstants.String, + TypePropertyFlags.ReadOnly)), + null); + var (sut, unhydratedTypeRef) = SetupResolver(hydrated); + + UnresolvedResourceDerivedType unresolved = new( + unhydratedTypeRef, + [], + LanguageConstants.Any, + ResourceDerivedTypeVariant.Output); + + var bound = sut.ResolveResourceDerivedTypes(unresolved); + var boundObject = bound.Should().BeAssignableTo().Subject; + boundObject.Properties.TryGetValue("property", out var property).Should().BeTrue(); + property!.Flags.Should().NotHaveFlag(TypePropertyFlags.ReadOnly); + } } diff --git a/src/Bicep.Core.UnitTests/Utils/CompilationResultExtensions.cs b/src/Bicep.Core.UnitTests/Utils/CompilationResultExtensions.cs index 21679681d48..c9f4b584203 100644 --- a/src/Bicep.Core.UnitTests/Utils/CompilationResultExtensions.cs +++ b/src/Bicep.Core.UnitTests/Utils/CompilationResultExtensions.cs @@ -43,8 +43,13 @@ public static string ApplyCodeFix(this ICompilationResult result, IDiagnostic di throw new InvalidOperationException("Diagnostic is not fixable"); } - // TODO - support multiple fixes / replacements - var fix = fixable.Fixes.Single(); + // TODO - support multiple fixes + return ApplyCodeFix(result, fixable.Fixes.Single()); + } + + public static string ApplyCodeFix(this ICompilationResult result, CodeFix fix) + { + // TODO - support multiple replacements var replacement = fix.Replacements.Single(); var sourceText = result.SourceFile.Text; diff --git a/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs b/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs index c58f1d9a1ee..4d28b6ee823 100644 --- a/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs +++ b/src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs @@ -1851,6 +1851,28 @@ public Diagnostic MicrosoftGraphBuiltinDeprecatedSoon(ExtensionDeclarationSyntax public Diagnostic NameofInvalidOnUnnamedExpression() => CoreError( "BCP408", $"The \"{LanguageConstants.NameofFunctionName}\" function can only be used with an expression which has a name."); + + public Diagnostic ResourceParameterizedTypeIsDeprecated(ParameterizedTypeInstantiationSyntaxBase syntax) + { + var fixToResourceInput = new CodeFix( + $"Replace the 'resource<>' parameterized type with the 'resourceInput<>' parameterized type (for values that will be used in the right-hand side of a `resource` statement)", + true, + CodeFixKind.QuickFix, + new CodeReplacement(syntax.Name.Span, LanguageConstants.TypeNameResourceInput)); + + var fixToResourceOutput = new CodeFix( + $"Replace the 'resource<>' parameterized type with the 'resourceOutput<>' parameterized type (for values that should match the value of a `resource` symbol after it has been declared)", + // we've encouraged users to adopt resource-derived types for when values will be passed to resource statements. Few if any existing usages should align with `resourceOutput<>` + isPreferred: false, + CodeFixKind.QuickFix, + new CodeReplacement(syntax.Name.Span, LanguageConstants.TypeNameResourceOutput)); + + return CoreWarning( + "BCP409", + "The 'resource<>' parameterized type has been deprecated. Please specify whether you want this type to correspond to the resource input or the resource output.") + with + { Fixes = [fixToResourceInput, fixToResourceOutput] }; + } } public static DiagnosticBuilderInternal ForPosition(TextSpan span) diff --git a/src/Bicep.Core/Emit/TemplateWriter.cs b/src/Bicep.Core/Emit/TemplateWriter.cs index 9509f75fd82..75005157ed3 100644 --- a/src/Bicep.Core/Emit/TemplateWriter.cs +++ b/src/Bicep.Core/Emit/TemplateWriter.cs @@ -465,27 +465,50 @@ ImmutableArray SegmentsForVariant(string discriminatorValue) => PointerSegments.AddRange("discriminator", "mapping", discriminatorValue); } - private record ResourceDerivedTypeResolution(ResourceTypeReference RootResourceTypeReference, ImmutableArray PointerSegments, TypeSymbol DerivedType) : ITypeReferenceExpressionResolution + private record ResourceDerivedTypeResolution( + ResourceTypeReference RootResourceTypeReference, + ImmutableArray PointerSegments, + TypeSymbol DerivedType, + ResourceDerivedTypeVariant Variant) : ITypeReferenceExpressionResolution { internal ResourceDerivedTypeResolution(ResourceDerivedTypeExpression expression) - : this(expression.RootResourceType.TypeReference, [], expression.RootResourceType.Body.Type) { } + : this(expression.RootResourceType.TypeReference, [], expression.ExpressedType, expression.Variant) { } public ObjectExpression GetTypePropertiesForResolvedReferenceExpression(SyntaxBase? sourceSyntax) - => ExpressionFactory.CreateObject(new[] + { + var typePointerProperty = ExpressionFactory.CreateObjectProperty( + LanguageConstants.MetadataResourceDerivedTypePointerPropertyName, + ExpressionFactory.CreateStringLiteral(string.Concat( + RootResourceTypeReference.FormatName(), + PointerSegments.IsEmpty ? string.Empty : '#', + string.Join('/', PointerSegments.Select(StringExtensions.Rfc6901Encode))))); + var metadataValue = Variant switch + { + ResourceDerivedTypeVariant.Input => ExpressionFactory.CreateObject(typePointerProperty.AsEnumerable()), + ResourceDerivedTypeVariant.Output => ExpressionFactory.CreateObject(new[] + { + typePointerProperty, + ExpressionFactory.CreateObjectProperty( + LanguageConstants.MetadataResourceDerivedTypeOutputFlagName, + ExpressionFactory.CreateBooleanLiteral(true)) + }), + // The legacy representation uses a string (the type pointer), not an object + _ => typePointerProperty.Value, + }; + + return ExpressionFactory.CreateObject(new[] { TypeProperty(GetNonLiteralTypeName(DerivedType), sourceSyntax), ExpressionFactory.CreateObjectProperty(LanguageConstants.ParameterMetadataPropertyName, ExpressionFactory.CreateObject( - ExpressionFactory.CreateObjectProperty(LanguageConstants.MetadataResourceDerivedTypePropertyName, - ExpressionFactory.CreateStringLiteral( - PointerSegments.IsEmpty - ? RootResourceTypeReference.FormatName() - : $"{RootResourceTypeReference.FormatName()}#{string.Join('/', PointerSegments.Select(StringExtensions.Rfc6901Encode))}", - sourceSyntax), + ExpressionFactory.CreateObjectProperty( + LanguageConstants.MetadataResourceDerivedTypePropertyName, + metadataValue, sourceSyntax).AsEnumerable(), sourceSyntax), sourceSyntax), }); + } } private record ResolvedInternalReference(ImmutableArray PointerSegments, TypeExpression Declaration) : ITypeReferenceExpressionResolution @@ -566,7 +589,8 @@ private ITypeReferenceExpressionResolution ResolveTypeReferenceExpressionPropert return new ResourceDerivedTypeResolution( resourceDerived.RootResourceTypeReference, resolution.SegmentsForProperty(propertyAccess.PropertyName), - propertyAccess.ExpressedType); + propertyAccess.ExpressedType, + resourceDerived.Variant); } throw new ArgumentException($"Unable to handle resolution of type {resolution.GetType().Name}."); @@ -595,7 +619,8 @@ private ITypeReferenceExpressionResolution ResolveTypeReferenceExpressionAdditio return new ResourceDerivedTypeResolution( resourceDerived.RootResourceTypeReference, resolution.SegmentsForAdditionalProperties(), - additionalPropertiesAccess.ExpressedType); + additionalPropertiesAccess.ExpressedType, + resourceDerived.Variant); } throw new ArgumentException($"Unable to handle resolution of type {resolution.GetType().Name}."); @@ -639,7 +664,8 @@ private ITypeReferenceExpressionResolution ResolveTypeReferenceExpressionIndex( return new ResourceDerivedTypeResolution( resourceDerived.RootResourceTypeReference, currentResolution.SegmentsForIndex(indexAccess.Index), - indexAccess.ExpressedType); + indexAccess.ExpressedType, + resourceDerived.Variant); } throw new ArgumentException($"Unable to handle resolution of type {currentResolution.GetType().Name}."); @@ -667,7 +693,8 @@ private ITypeReferenceExpressionResolution ResolveTypeReferenceExpressionItems( return new ResourceDerivedTypeResolution( resourceDerived.RootResourceTypeReference, currentResolution.SegmentsForItems(), - itemsAccess.ExpressedType); + itemsAccess.ExpressedType, + resourceDerived.Variant); } throw new ArgumentException($"Unable to handle resolution of type {currentResolution.GetType().Name}."); @@ -910,7 +937,8 @@ private static IEnumerable GetDiscriminatedUnionMappin var variantResolution = new ResourceDerivedTypeResolution( resolution.RootResourceTypeReference, (resolution as ITypeReferenceExpressionResolution).SegmentsForVariant(discriminatorValue), - variant); + variant, + resolution.Variant); yield return ExpressionFactory.CreateObjectProperty( discriminatorValue, diff --git a/src/Bicep.Core/Intermediate/Expression.cs b/src/Bicep.Core/Intermediate/Expression.cs index 6bcb6f674f4..e9674e2247b 100644 --- a/src/Bicep.Core/Intermediate/Expression.cs +++ b/src/Bicep.Core/Intermediate/Expression.cs @@ -950,8 +950,17 @@ public override void Accept(IExpressionVisitor visitor) public record ResourceDerivedTypeExpression( SyntaxBase? SourceSyntax, - ResourceType RootResourceType -) : TypeExpression(SourceSyntax, RootResourceType.Body.Type) + ResourceType RootResourceType, + ResourceDerivedTypeVariant Variant) : TypeExpression( + SourceSyntax, + Variant switch + { + ResourceDerivedTypeVariant.Input + => TypeHelper.RemovePropertyFlagsRecursively(RootResourceType.Body.Type, TypePropertyFlags.WriteOnly), + ResourceDerivedTypeVariant.Output + => TypeHelper.RemovePropertyFlagsRecursively(RootResourceType.Body.Type, TypePropertyFlags.ReadOnly), + _ => RootResourceType.Body.Type, + }) { public override void Accept(IExpressionVisitor visitor) => visitor.VisitResourceDerivedTypeExpression(this); diff --git a/src/Bicep.Core/LanguageConstants.cs b/src/Bicep.Core/LanguageConstants.cs index 125b9cf63d0..2e23d8dbe63 100644 --- a/src/Bicep.Core/LanguageConstants.cs +++ b/src/Bicep.Core/LanguageConstants.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Collections.Frozen; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -152,6 +153,8 @@ public static class LanguageConstants public const string MetadataDescriptionPropertyName = "description"; public const string MetadataResourceTypePropertyName = "resourceType"; public const string MetadataResourceDerivedTypePropertyName = "__bicep_resource_derived_type!"; + public const string MetadataResourceDerivedTypePointerPropertyName = "source"; + public const string MetadataResourceDerivedTypeOutputFlagName = "output"; public const string MetadataExportedPropertyName = "__bicep_export!"; public const string MetadataImportedFromPropertyName = "__bicep_imported_from!"; public const string TemplateMetadataExportedVariablesName = "__bicep_exported_variables!"; @@ -184,6 +187,14 @@ public static class LanguageConstants public const string TypeNameModule = "module"; public const string TypeNameTest = "test"; public const string TypeNameResource = "resource"; + public const string TypeNameResourceInput = "resourceInput"; + public const string TypeNameResourceOutput = "resourceOutput"; + public static readonly FrozenSet ResourceDerivedTypeNames = new[] + { + TypeNameResource, + TypeNameResourceInput, + TypeNameResourceOutput, + }.ToFrozenSet(IdentifierComparer); public static readonly StringComparer IdentifierComparer = StringComparer.Ordinal; public static readonly StringComparison IdentifierComparison = StringComparison.Ordinal; diff --git a/src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs b/src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs index 1babb05e5a8..e98932e5291 100644 --- a/src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs +++ b/src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs @@ -576,8 +576,8 @@ public IEnumerable LayoutParameterizedTypeInstantiationSyntax(Paramete if (tail is GroupDocument) { - // ParameterizedTypeInstantiationSyntax is only applied to resource derived types (resource<'xxx'>). - // It is more readable to print resource<'xxx'> on a single line, even if it's longer than the max line width. + // ParameterizedTypeInstantiationSyntax is only applied to resource derived types (resourceInput<'xxx'>). + // It is more readable to print resourceInput<'xxx'> on a single line, even if it's longer than the max line width. // We may need to revisit this if we introduce generic types later at some point. tail = tail.Flatten().Glue(); } @@ -597,8 +597,8 @@ private IEnumerable LayoutInstanceParameterizedTypeInstantiationSyntax if (tail is GroupDocument) { - // InstanceParameterizedTypeInstantiationSyntax is only applied to resource derived types (resource<'xxx'>). - // It is more readable to print resource<'xxx'> on a single line, even if it's longer than the max line width. + // InstanceParameterizedTypeInstantiationSyntax is only applied to resource derived types (resourceInput<'xxx'>). + // It is more readable to print resourceInput<'xxx'> on a single line, even if it's longer than the max line width. // We may need to revisit this if we introduce generic types later at some point. tail = tail.Flatten().Glue(); } diff --git a/src/Bicep.Core/Semantics/AmbientTypeSymbol.cs b/src/Bicep.Core/Semantics/AmbientTypeSymbol.cs index e22f7996048..4e98fc3163f 100644 --- a/src/Bicep.Core/Semantics/AmbientTypeSymbol.cs +++ b/src/Bicep.Core/Semantics/AmbientTypeSymbol.cs @@ -7,10 +7,11 @@ namespace Bicep.Core.Semantics; public class AmbientTypeSymbol : Symbol, ITypeReference { - public AmbientTypeSymbol(string name, TypeSymbol type, NamespaceType declaringNamespace, string? description) : base(name) + public AmbientTypeSymbol(string name, TypeSymbol type, NamespaceType declaringNamespace, TypePropertyFlags flags, string? description) : base(name) { Type = type; DeclaringNamespace = declaringNamespace; + Flags = flags; Description = description; } @@ -20,6 +21,8 @@ public AmbientTypeSymbol(string name, TypeSymbol type, NamespaceType declaringNa public string? Description { get; } + public TypePropertyFlags Flags { get; } + public override IEnumerable Descendants { get diff --git a/src/Bicep.Core/Semantics/Namespaces/NamespaceResolver.cs b/src/Bicep.Core/Semantics/Namespaces/NamespaceResolver.cs index 58ab5fbae84..e04f8f75a68 100644 --- a/src/Bicep.Core/Semantics/Namespaces/NamespaceResolver.cs +++ b/src/Bicep.Core/Semantics/Namespaces/NamespaceResolver.cs @@ -71,7 +71,7 @@ public IEnumerable ResolveUnqualifiedFunction(IdentifierSyntax identifie /// public IEnumerable ResolveUnqualifiedTypeSymbol(IdentifierSyntax identifierSyntax) => this.namespaceTypes.Values .Select(@namespace => @namespace.Properties.TryGetValue(identifierSyntax.IdentifierName, out var found) - ? new AmbientTypeSymbol(identifierSyntax.IdentifierName, found.TypeReference.Type, @namespace, found.Description) + ? new AmbientTypeSymbol(identifierSyntax.IdentifierName, found.TypeReference.Type, @namespace, found.Flags, found.Description) : null) .WhereNotNull(); @@ -90,7 +90,7 @@ public IEnumerable GetKnownPropertyNames() => this.namespaceTypes.Values.SelectMany(type => type.Properties.Keys); public IEnumerable GetKnownTypes() => this.namespaceTypes.Values - .SelectMany(@namespace => @namespace.Properties.Select(p => new AmbientTypeSymbol(p.Key, p.Value.TypeReference.Type, @namespace, p.Value.Description))); + .SelectMany(@namespace => @namespace.Properties.Select(p => new AmbientTypeSymbol(p.Key, p.Value.TypeReference.Type, @namespace, p.Value.Flags, p.Value.Description))); public IEnumerable GetNamespaceNames() => this.namespaceTypes.Keys; diff --git a/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs b/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs index 29678f7edc5..7a68eb8998c 100644 --- a/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs +++ b/src/Bicep.Core/Semantics/Namespaces/SystemNamespaceType.cs @@ -1803,7 +1803,7 @@ static IEnumerable GetBicepTemplateDecorators(IFeatureProvider featur case AccessExpressionSyntax accessExpression when binder.GetSymbolInfo(accessExpression.BaseExpression) is not BuiltInNamespaceSymbol: diagnosticWriter.Write(DiagnosticBuilder.ForPosition(decoratorSyntax).DecoratorMayNotTargetTypeAlias(decoratorName)); break; - case ParameterizedTypeInstantiationSyntaxBase parameterized when LanguageConstants.IdentifierComparer.Equals(parameterized.Name.IdentifierName, LanguageConstants.TypeNameResource): + case ParameterizedTypeInstantiationSyntaxBase parameterized when LanguageConstants.ResourceDerivedTypeNames.Contains(parameterized.Name.IdentifierName): diagnosticWriter.Write(DiagnosticBuilder.ForPosition(decoratorSyntax).DecoratorMayNotTargetResourceDerivedType(decoratorName)); break; case ObjectTypeSyntax @object when @object.AdditionalProperties is not null: @@ -1933,33 +1933,67 @@ static IEnumerable GetArmPrimitiveTypes() static IEnumerable GetResourceDerivedTypesTypeProperties() { - yield return new(LanguageConstants.TypeNameResource, - 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.", - LanguageConstants.StringResourceIdentifier), - ], - (binder, syntax, argumentTypes) => + ImmutableArray resourceInputParameters = [new TypeParameter( + "ResourceTypeIdentifier", + "A string of the format `@` that identifies the kind of resource whose body type definition is to be used.", + LanguageConstants.StringResourceIdentifier)]; + + static TypeTemplate.InstantiatorDelegate GetResourceDerivedTypeInstantiator(ResourceDerivedTypeVariant derivedTypeVariant) + => (binder, syntax, argumentTypes) => + { + if (syntax.Arguments.FirstOrDefault()?.Expression is not StringTypeLiteralSyntax stringArg || stringArg.SegmentValues.Length > 1) { - if (syntax.Arguments.FirstOrDefault()?.Expression is not StringTypeLiteralSyntax stringArg || stringArg.SegmentValues.Length > 1) - { - return new(DiagnosticBuilder.ForPosition(TextSpan.BetweenExclusive(syntax.OpenChevron, syntax.CloseChevron)).CompileTimeConstantRequired()); - } + return new(DiagnosticBuilder.ForPosition(TextSpan.BetweenExclusive(syntax.OpenChevron, syntax.CloseChevron)).CompileTimeConstantRequired()); + } - if (!TypeHelper.GetResourceTypeFromString(binder, stringArg.SegmentValues[0], ResourceTypeGenerationFlags.None, parentResourceType: null) - .IsSuccess(out var resourceType, out var errorBuilder)) - { - return new(errorBuilder(DiagnosticBuilder.ForPosition(syntax.GetArgumentByPosition(0)))); - } + if (!TypeHelper.GetResourceTypeFromString(binder, stringArg.SegmentValues[0], ResourceTypeGenerationFlags.None, parentResourceType: null) + .IsSuccess(out var resourceType, out var errorBuilder)) + { + return new(errorBuilder(DiagnosticBuilder.ForPosition(syntax.GetArgumentByPosition(0)))); + } - return new(new ResourceDerivedTypeExpression(syntax, resourceType)); - }), - description: """ + return new(new ResourceDerivedTypeExpression(syntax, resourceType, derivedTypeVariant)); + }; + + var resourceDerivedTypeNotaBene = "NB: The type definition will be checked by Bicep when the template is compiled but will not be enforced by the ARM engine during a deployment."; + + yield return new( + LanguageConstants.TypeNameResource, + new TypeTemplate( + LanguageConstants.TypeNameResource, + resourceInputParameters, + GetResourceDerivedTypeInstantiator(ResourceDerivedTypeVariant.None)), + flags: TypePropertyFlags.FallbackProperty, + description: $""" Use the type definition of the body of a specific resource rather than a user-defined type. - NB: The type definition will be checked by Bicep when the template is compiled but will not be enforced by the ARM engine during a deployment. + {resourceDerivedTypeNotaBene} + """); + + yield return new( + LanguageConstants.TypeNameResourceInput, + new TypeTemplate( + LanguageConstants.TypeNameResourceInput, + resourceInputParameters, + GetResourceDerivedTypeInstantiator(ResourceDerivedTypeVariant.Input)), + description: $""" + Use the type definition of the input for a specific resource rather than a user-defined type. + + {resourceDerivedTypeNotaBene} """); + + yield return new( + LanguageConstants.TypeNameResourceOutput, + new TypeTemplate( + LanguageConstants.TypeNameResourceOutput, + resourceInputParameters, + GetResourceDerivedTypeInstantiator(ResourceDerivedTypeVariant.Output)), + description: $""" + Use the type definition of the return value of a specific resource rather than a user-defined type. + + {resourceDerivedTypeNotaBene} + """); + } foreach (var typeProp in GetArmPrimitiveTypes()) diff --git a/src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs b/src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs index a3c5cb8ad09..ea7a8e76083 100644 --- a/src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs +++ b/src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs @@ -12,6 +12,7 @@ using Bicep.Core.TypeSystem.Types; using Microsoft.WindowsAzure.ResourceStack.Common.Collections; using Microsoft.WindowsAzure.ResourceStack.Common.Extensions; +using Microsoft.WindowsAzure.ResourceStack.Common.Json; using Newtonsoft.Json.Linq; namespace Bicep.Core.TypeSystem; @@ -62,10 +63,29 @@ private static ITypeReference ToTypeReferenceIgnoringNullability(SchemaValidatio private static ITypeReference? TryGetResourceDerivedType(SchemaValidationContext context, ITemplateSchemaNode schemaNode, TypeSymbolValidationFlags flags) { if (schemaNode.Metadata?.Value is JObject metadataObject && - metadataObject.TryGetValue(LanguageConstants.MetadataResourceDerivedTypePropertyName, out var resourceType) && - resourceType is JValue { Value: string resourceTypeString }) + metadataObject.TryGetValue(LanguageConstants.MetadataResourceDerivedTypePropertyName, out var resourceType)) { var fallbackType = ToTypeReference(context, new SansMetadata(schemaNode), flags).Type; + var variant = ResourceDerivedTypeVariant.None; + string? resourceTypeString = null; + if (resourceType.GetProperty(LanguageConstants.MetadataResourceDerivedTypePointerPropertyName) + ?.TryGetStringValue() is string pointerPropVal) + { + variant = resourceType.TryGetProperty(LanguageConstants.MetadataResourceDerivedTypeOutputFlagName) + ? ResourceDerivedTypeVariant.Output + : ResourceDerivedTypeVariant.Input; + resourceTypeString = pointerPropVal; + } + // The legacy representation uses a string (the type pointer), not an object + else if (resourceType.TryGetStringValue() is string strVal) + { + resourceTypeString = strVal; + } + + if (resourceTypeString is null) + { + return new UnparsableResourceDerivedType(resourceType.ToString(), fallbackType); + } var resourceTypeStringParts = resourceTypeString.Split('#', 2); var resourceTypeIdentifier = resourceTypeStringParts[0]; @@ -74,7 +94,7 @@ private static ITypeReference ToTypeReferenceIgnoringNullability(SchemaValidatio : []; return ResourceTypeReference.TryParse(resourceTypeIdentifier) is ResourceTypeReference resourceTypeReference - ? new UnresolvedResourceDerivedType(resourceTypeReference, internalPointerSegments, fallbackType) + ? new UnresolvedResourceDerivedType(resourceTypeReference, internalPointerSegments, fallbackType, variant) : new UnparsableResourceDerivedType(resourceTypeIdentifier, fallbackType); } @@ -231,6 +251,7 @@ private static TypeSymbol GetObjectType(SchemaValidationContext context, ITempla variants.Add(TryGetResourceDerivedType(context, variant, flags) is UnresolvedResourceDerivedType resourceDerivedObject ? new UnresolvedResourceDerivedPartialObjectType(resourceDerivedObject.TypeReference, resourceDerivedObject.PointerSegments, + resourceDerivedObject.Variant, discriminator.PropertyName.Value, mappingEntry.Key) : GetObjectType( diff --git a/src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs b/src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs index 5ae78bb86fe..1fcef5662aa 100644 --- a/src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs +++ b/src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs @@ -294,7 +294,7 @@ private TypeSymbol GetUserDefinedTypeType(TypeAliasSymbol symbol) }; private TypeSymbol GetTypePropertyType(ObjectTypePropertySyntax syntax, TypeSymbol typeSymbol) - => ApplyTypeModifyingDecorators(DisallowNamespaceTypes(UnwrapType(syntax.Value, typeSymbol), syntax.Value), syntax); + => ApplyTypeModifyingDecorators(DisallowNamespaceTypes(UnwrapType(typeSymbol), syntax.Value), syntax); private TypeSymbol GetInstantiatedType(ParameterizedTypeInstantiationSyntaxBase syntax) => GetReifiedTypeResult(syntax).IsSuccess(out var typeExpression, out var error) @@ -554,9 +554,9 @@ private ITypeReference ConvertTypeExpressionToType(TypeVariableAccessSyntax synt BuiltInNamespaceSymbol builtInNamespace => builtInNamespace.Type, ExtensionNamespaceSymbol extensionNamespace => extensionNamespace.Type, WildcardImportSymbol wildcardImport => wildcardImport.Type, - AmbientTypeSymbol ambientType => UnwrapType(syntax, ambientType.Type), - ImportedTypeSymbol importedType => UnwrapType(syntax, importedType.Type), - TypeAliasSymbol declaredType => TypeRefToType(syntax, declaredType), + AmbientTypeSymbol ambientType => EnsureNonParameterizedType(syntax, UnwrapType(ambientType.Type)), + ImportedTypeSymbol importedType => EnsureNonParameterizedType(syntax, UnwrapType(importedType.Type)), + TypeAliasSymbol declaredType => EnsureNonParameterizedType(syntax, TypeRefToType(syntax, declaredType)), DeclaredSymbol declaredSymbol => ErrorType.Create(DiagnosticBuilder.ForPosition(syntax).ValueSymbolUsedAsType(declaredSymbol.Name)), _ => ErrorType.Create(DiagnosticBuilder.ForPosition(syntax).SymbolicNameIsNotAType(syntax.Name.IdentifierName, GetValidTypeNames())), }; @@ -588,7 +588,7 @@ private ResultWithDiagnostic GetReifiedTypeResult(ParameterizedT private ResultWithDiagnostic InstantiateType(InstanceParameterizedTypeInstantiationSyntax syntax) { var baseType = GetTypeFromTypeSyntax(syntax.BaseExpression).Type; - var propertyType = FinalizeTypePropertyType(baseType, syntax.PropertyName.IdentifierName, syntax.PropertyName); + var propertyType = GetTypePropertyType(baseType, syntax.PropertyName.IdentifierName, syntax.PropertyName); return InstantiateType(syntax, $"{baseType.Name}.{syntax.PropertyName.IdentifierName}", propertyType); } @@ -961,15 +961,18 @@ TypeArrayAccessSyntax or ParameterizedTypeInstantiationSyntax parameterized when binder.GetSymbolInfo(parameterized) is AmbientTypeSymbol ambient && ambient.DeclaringNamespace.ExtensionNameEquals(SystemNamespaceType.BuiltInName) && - LanguageConstants.IdentifierComparer.Equals(ambient.Name, LanguageConstants.TypeNameResource) => true, + LanguageConstants.ResourceDerivedTypeNames.Contains(ambient.Name) => true, InstanceParameterizedTypeInstantiationSyntax parameterized when binder.GetSymbolInfo(parameterized.BaseExpression) is BuiltInNamespaceSymbol ns && ns.TryGetNamespaceType()?.ExtensionNameEquals(SystemNamespaceType.BuiltInName) is true && - LanguageConstants.IdentifierComparer.Equals(parameterized.Name.IdentifierName, LanguageConstants.TypeNameResource) => true, + LanguageConstants.ResourceDerivedTypeNames.Contains(parameterized.Name.IdentifierName) => true, _ => false, }; private static TypeSymbol FinalizeTypePropertyType(ITypeReference baseExpressionType, string propertyName, SyntaxBase propertyNameSyntax) + => EnsureNonParameterizedType(propertyNameSyntax, GetTypePropertyType(baseExpressionType, propertyName, propertyNameSyntax)); + + private static TypeSymbol GetTypePropertyType(ITypeReference baseExpressionType, string propertyName, SyntaxBase propertyNameSyntax) { var baseType = baseExpressionType.Type; @@ -995,7 +998,7 @@ private static TypeSymbol FinalizeTypePropertyType(ITypeReference baseExpression .Invoke(DiagnosticBuilder.ForPosition(propertyNameSyntax))); } - return UnwrapType(propertyNameSyntax, typeProperty.TypeReference.Type); + return UnwrapType(typeProperty.TypeReference.Type); } private ITypeReference ConvertTypeExpressionToType(TypeArrayAccessSyntax syntax, ulong index) @@ -1037,7 +1040,7 @@ private static TypeSymbol FinalizeTypeIndexAccessType(TypeArrayAccessSyntax synt .IndexOutOfBounds(baseType.Name, tupleType.Items.Length, index <= long.MaxValue ? (long)index : long.MaxValue)); } - return UnwrapType(syntax.IndexExpression, tupleType.Items[(int)index].Type); + return EnsureNonParameterizedType(syntax.IndexExpression, UnwrapType(tupleType.Items[(int)index].Type)); } private ITypeReference ConvertTypeExpressionToType(TypeAdditionalPropertiesAccessSyntax syntax) @@ -1073,7 +1076,7 @@ private static TypeSymbol FinalizeAdditionalPropertiesAccessType(TypeAdditionalP return ErrorType.Create(DiagnosticBuilder.ForPosition(syntax.Asterisk).ExplicitAdditionalPropertiesTypeRequiredForAccessThereto(baseType)); } - return UnwrapType(syntax.Asterisk, @object.AdditionalPropertiesType.Type); + return EnsureNonParameterizedType(syntax.Asterisk, UnwrapType(@object.AdditionalPropertiesType.Type)); } private ITypeReference ConvertTypeExpressionToType(TypeItemsAccessSyntax syntax) @@ -1109,7 +1112,7 @@ private static TypeSymbol FinalizeItemsAccessType(TypeItemsAccessSyntax syntax, return ErrorType.Create(DiagnosticBuilder.ForPosition(TextSpan.Between(syntax.OpenSquare, syntax.CloseSquare)).ExplicitItemsTypeRequiredForAccessThereto()); } - return UnwrapType(syntax.Asterisk, @array.Item.Type); + return EnsureNonParameterizedType(syntax.Asterisk, UnwrapType(@array.Item.Type)); } private static TypeSymbol EnsureNonParameterizedType(SyntaxBase syntax, TypeSymbol type) => type switch @@ -1118,16 +1121,22 @@ private static TypeSymbol FinalizeItemsAccessType(TypeItemsAccessSyntax syntax, _ => type, }; - private static TypeSymbol UnwrapType(SyntaxBase syntax, TypeSymbol type) => EnsureNonParameterizedType(syntax, type) switch + private static ITypeReference EnsureNonParameterizedType(SyntaxBase syntax, ITypeReference type) => type switch + { + DeferredTypeReference => new DeferredTypeReference(() => EnsureNonParameterizedType(syntax, type.Type)), + _ => EnsureNonParameterizedType(syntax, type.Type), + }; + + private static TypeSymbol UnwrapType(TypeSymbol type) => type switch { TypeType tt => tt.Unwrapped, _ => type, }; - private static ITypeReference UnwrapType(SyntaxBase syntax, ITypeReference typeReference) => typeReference switch + private static ITypeReference UnwrapType(ITypeReference typeReference) => typeReference switch { - DeferredTypeReference => new DeferredTypeReference(() => UnwrapType(syntax, typeReference.Type)), - _ => UnwrapType(syntax, typeReference.Type), + DeferredTypeReference => new DeferredTypeReference(() => UnwrapType(typeReference.Type)), + _ => UnwrapType(typeReference.Type), }; private ITypeReference ConvertTypeExpressionToType(NullableTypeSyntax syntax) diff --git a/src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs b/src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs index c9cf8b5c95c..a9424949796 100644 --- a/src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs +++ b/src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs @@ -97,7 +97,12 @@ private TypeSymbol ResolveType(IUnresolvedResourceDerivedType unresolved) return unresolved.FallbackType; } - return current; + return unresolved.Variant switch + { + ResourceDerivedTypeVariant.Input => TypeHelper.RemovePropertyFlagsRecursively(current, TypePropertyFlags.WriteOnly), + ResourceDerivedTypeVariant.Output => TypeHelper.RemovePropertyFlagsRecursively(current, TypePropertyFlags.ReadOnly), + _ => current, + }; } return unresolved.FallbackType; diff --git a/src/Bicep.Core/TypeSystem/ResourceDerivedTypeVariant.cs b/src/Bicep.Core/TypeSystem/ResourceDerivedTypeVariant.cs new file mode 100644 index 00000000000..3e46a032370 --- /dev/null +++ b/src/Bicep.Core/TypeSystem/ResourceDerivedTypeVariant.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Bicep.Core.TypeSystem; + +public enum ResourceDerivedTypeVariant +{ + None, + Input, + Output, +} diff --git a/src/Bicep.Core/TypeSystem/TypeAssignmentVisitor.cs b/src/Bicep.Core/TypeSystem/TypeAssignmentVisitor.cs index f1c3efca45c..a5080665ae5 100644 --- a/src/Bicep.Core/TypeSystem/TypeAssignmentVisitor.cs +++ b/src/Bicep.Core/TypeSystem/TypeAssignmentVisitor.cs @@ -729,6 +729,12 @@ public override void VisitResourceTypeSyntax(ResourceTypeSyntax syntax) }); public override void VisitParameterizedTypeInstantiationSyntax(ParameterizedTypeInstantiationSyntax syntax) + => VisitParameterizedTypeInstantiationSyntaxBase(syntax); + + public override void VisitInstanceParameterizedTypeInstantiationSyntax(InstanceParameterizedTypeInstantiationSyntax syntax) + => VisitParameterizedTypeInstantiationSyntaxBase(syntax); + + private void VisitParameterizedTypeInstantiationSyntaxBase(ParameterizedTypeInstantiationSyntaxBase syntax) => AssignTypeWithDiagnostics(syntax, diagnostics => { var declaredType = typeManager.TryGetReifiedType(syntax)?.ExpressedType; @@ -739,6 +745,12 @@ public override void VisitParameterizedTypeInstantiationSyntax(ParameterizedType diagnostics.WriteMultiple(declaredType.GetDiagnostics()); + // resource<> is deprecated + if (syntax.Name.IdentifierName.Equals(LanguageConstants.TypeNameResource)) + { + diagnostics.Write(DiagnosticBuilder.ForPosition(syntax.Name).ResourceParameterizedTypeIsDeprecated(syntax)); + } + return declaredType; }); @@ -1307,7 +1319,12 @@ childType is not ErrorType && { // we've found a declared object type for the containing object, with a matching property name definition. // preserve the type property details (name, descriptions etc.), and update the assigned type. - namedProperties[name] = new TypeProperty(property.Name, resolvedType, property.Flags, property.Description); + // Since this type corresponds to a value that is being supplied, make sure it has the `Required` flag and does not have the `.ReadOnly` flag + namedProperties[name] = new TypeProperty( + property.Name, + resolvedType, + (property.Flags | TypePropertyFlags.Required) & ~TypePropertyFlags.ReadOnly, + property.Description); } else { diff --git a/src/Bicep.Core/TypeSystem/TypeHelper.cs b/src/Bicep.Core/TypeSystem/TypeHelper.cs index c1dea2a8164..f7a347a04c9 100644 --- a/src/Bicep.Core/TypeSystem/TypeHelper.cs +++ b/src/Bicep.Core/TypeSystem/TypeHelper.cs @@ -693,5 +693,15 @@ private static ObjectType TransformProperties(ObjectType input, Func TransformProperties(input, p => p.With(p.Flags & ~TypePropertyFlags.Required)); + + public static TypeSymbol RemovePropertyFlagsRecursively(TypeSymbol type, TypePropertyFlags flagsToRemove) => type switch + { + ObjectType @object => TransformProperties(@object, property => new( + property.Name, + new DeferredTypeReference(() => RemovePropertyFlagsRecursively(property.TypeReference.Type, flagsToRemove)), + property.Flags & ~flagsToRemove, + property.Description)), + _ => type, + }; } } diff --git a/src/Bicep.Core/TypeSystem/TypeValidator.cs b/src/Bicep.Core/TypeSystem/TypeValidator.cs index 5d5ee3cd137..e67da27451d 100644 --- a/src/Bicep.Core/TypeSystem/TypeValidator.cs +++ b/src/Bicep.Core/TypeSystem/TypeValidator.cs @@ -1116,10 +1116,10 @@ static TypeSymbol RemoveImplicitNull(TypeSymbol type, bool typeWasPreserved) { diagnosticWriter.Write(diagnosticTarget, x => x.CannotUsePropertyInExistingResource(declaredProperty.Name)); } - else + else if (!expressionTypeProperty.Flags.HasFlag(TypePropertyFlags.ReadOnly)) { var resourceTypeInaccuracy = !declaredProperty.Flags.HasFlag(TypePropertyFlags.SystemProperty) && config.IsResourceDeclaration; - diagnosticWriter.Write(diagnosticTarget, x => x.CannotAssignToReadOnlyProperty(resourceTypeInaccuracy || ShouldWarn(targetType), declaredProperty.Name, resourceTypeInaccuracy)); + diagnosticWriter.Write(diagnosticTarget, x => x.CannotAssignToReadOnlyProperty(resourceTypeInaccuracy || ShouldWarnForPropertyMismatch(targetType), declaredProperty.Name, resourceTypeInaccuracy)); } narrowedProperties.Add(new TypeProperty(declaredProperty.Name, declaredProperty.TypeReference.Type, declaredProperty.Flags)); @@ -1236,7 +1236,11 @@ static TypeSymbol RemoveImplicitNull(TypeSymbol type, bool typeWasPreserved) } } - return new ObjectType(targetType.Name, targetType.ValidationFlags, narrowedProperties, targetType.AdditionalPropertiesType, targetType.AdditionalPropertiesFlags, targetType.MethodResolver.CopyToObject); + var narrowedObject = new ObjectType(targetType.Name, targetType.ValidationFlags, narrowedProperties, targetType.AdditionalPropertiesType, targetType.AdditionalPropertiesFlags, targetType.MethodResolver.CopyToObject); + + return config.IsResourceDeclaration + ? TypeHelper.RemovePropertyFlagsRecursively(narrowedObject, TypePropertyFlags.ReadOnly) + : narrowedObject; } return null; diff --git a/src/Bicep.Core/TypeSystem/Types/IUnresolvedResourceDerivedType.cs b/src/Bicep.Core/TypeSystem/Types/IUnresolvedResourceDerivedType.cs index dcd376d23bc..7b3c3319add 100644 --- a/src/Bicep.Core/TypeSystem/Types/IUnresolvedResourceDerivedType.cs +++ b/src/Bicep.Core/TypeSystem/Types/IUnresolvedResourceDerivedType.cs @@ -21,4 +21,6 @@ public interface IUnresolvedResourceDerivedType public ImmutableArray PointerSegments { get; } public TypeSymbol FallbackType { get; } + + public ResourceDerivedTypeVariant Variant { get; } } diff --git a/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedPartialObjectType.cs b/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedPartialObjectType.cs index 589fd692b20..f0d30743ca1 100644 --- a/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedPartialObjectType.cs +++ b/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedPartialObjectType.cs @@ -12,8 +12,13 @@ namespace Bicep.Core.TypeSystem.Types; /// public class UnresolvedResourceDerivedPartialObjectType : ObjectType, IUnresolvedResourceDerivedType { - public UnresolvedResourceDerivedPartialObjectType(ResourceTypeReference typeReference, ImmutableArray pointerSegments, string discriminatorName, string discriminatorValue) - : base(typeReference.FormatType(), + public UnresolvedResourceDerivedPartialObjectType( + ResourceTypeReference typeReference, + ImmutableArray pointerSegments, + ResourceDerivedTypeVariant variant, + string discriminatorName, + string discriminatorValue) : base( + typeReference.FormatType(), TypeSymbolValidationFlags.Default, new TypeProperty(discriminatorName, TypeFactory.CreateStringLiteralType(discriminatorValue)).AsEnumerable(), LanguageConstants.Any, @@ -21,6 +26,7 @@ public UnresolvedResourceDerivedPartialObjectType(ResourceTypeReference typeRefe { TypeReference = typeReference; PointerSegments = pointerSegments; + Variant = variant; } public ResourceTypeReference TypeReference { get; } @@ -29,5 +35,7 @@ public UnresolvedResourceDerivedPartialObjectType(ResourceTypeReference typeRefe public TypeSymbol FallbackType => this; + public ResourceDerivedTypeVariant Variant { get; } + public override TypeKind TypeKind => TypeKind.UnboundResourceDerivedType; } diff --git a/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedType.cs b/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedType.cs index e8088b076df..432e9210874 100644 --- a/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedType.cs +++ b/src/Bicep.Core/TypeSystem/Types/UnresolvedResourceDerivedType.cs @@ -8,12 +8,16 @@ namespace Bicep.Core.TypeSystem.Types; public class UnresolvedResourceDerivedType : TypeSymbol, IUnresolvedResourceDerivedType { - public UnresolvedResourceDerivedType(ResourceTypeReference typeReference, ImmutableArray pointerSegments, TypeSymbol fallbackType) - : base(typeReference.FormatType()) + public UnresolvedResourceDerivedType( + ResourceTypeReference typeReference, + ImmutableArray pointerSegments, + TypeSymbol fallbackType, + ResourceDerivedTypeVariant variant) : base(typeReference.FormatType()) { TypeReference = typeReference; PointerSegments = pointerSegments; FallbackType = fallbackType; + Variant = variant; } public ResourceTypeReference TypeReference { get; } @@ -22,5 +26,7 @@ public UnresolvedResourceDerivedType(ResourceTypeReference typeReference, Immuta public TypeSymbol FallbackType { get; } + public ResourceDerivedTypeVariant Variant { get; } + public override TypeKind TypeKind => TypeKind.UnboundResourceDerivedType; } diff --git a/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs b/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs index 83259626713..6c39c4c2233 100644 --- a/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs +++ b/src/Bicep.LangServer.IntegrationTests/CompletionTests.cs @@ -4885,18 +4885,41 @@ public async Task Resource_utility_type_offered_as_completion_if_enabled() var file = new FileRequestHelper(helper.Client, bicepFile); var completions = await file.RequestCompletion(cursors[0]); - var updated = file.ApplyCompletion(completions, "resource"); + var updated = file.ApplyCompletion(completions, "resourceInput"); updated.Should().HaveSourceText(""" - type acct = resource<'|'> + type acct = resourceInput<'|'> """); } + [TestMethod] + public async Task Legacy_resource_utility_type_offered_not_as_completion_if_enabled() + { + var mainContent = """ + type acct = | + """; + + var (text, cursors) = ParserHelper.GetFileWithCursors(mainContent, '|'); + Uri mainUri = InMemoryFileResolver.GetFileUri("/path/to/main.bicep"); + + var bicepFile = SourceFileFactory.CreateBicepFile(mainUri, text); + using var helper = await LanguageServerHelper.StartServerWithText( + this.TestContext, + text, + mainUri, + services => services.WithFeatureOverrides(new(ResourceDerivedTypesEnabled: true))); + + var file = new FileRequestHelper(helper.Client, bicepFile); + var completions = await file.RequestCompletion(cursors[0]); + + completions.Should().NotContain(completion => completion.Label == LanguageConstants.TypeNameResource); + } + [TestMethod] public async Task Resource_types_offered_as_completion_for_single_argument_to_resource_utility_type() { var mainContent = """ - type acct = resource - type fullyQualified = sys.resource + type acct = resourceInput + type fullyQualified = sys.resourceInput """; var (text, cursors) = ParserHelper.GetFileWithCursors(mainContent, '|'); @@ -4914,15 +4937,15 @@ public async Task Resource_types_offered_as_completion_for_single_argument_to_re var completions = await file.RequestCompletion(cursors[0]); var updated = file.ApplyCompletion(completions, "'Microsoft.Storage/storageAccounts'"); updated.Should().HaveSourceText(""" - type acct = resource<'Microsoft.Storage/storageAccounts@|'> - type fullyQualified = sys.resource + type acct = resourceInput<'Microsoft.Storage/storageAccounts@|'> + type fullyQualified = sys.resourceInput """); completions = await file.RequestCompletion(cursors[1]); updated = file.ApplyCompletion(completions, "'Microsoft.Storage/storageAccounts'"); updated.Should().HaveSourceText(""" - type acct = resource - type fullyQualified = sys.resource<'Microsoft.Storage/storageAccounts@|'> + type acct = resourceInput + type fullyQualified = sys.resourceInput<'Microsoft.Storage/storageAccounts@|'> """); } @@ -4930,8 +4953,8 @@ public async Task Resource_types_offered_as_completion_for_single_argument_to_re public async Task Resource_api_versions_offered_as_completion_for_single_argument_to_resource_utility_type_with_resource_type_name_already_filled_in() { var mainContent = """ - type acct = resource<'Microsoft.Storage/storageAccounts@|'> - type fullyQualified = sys.resource<'Microsoft.Storage/storageAccounts@|'> + type acct = resourceInput<'Microsoft.Storage/storageAccounts@|'> + type fullyQualified = sys.resourceInput<'Microsoft.Storage/storageAccounts@|'> """; var (text, cursors) = ParserHelper.GetFileWithCursors(mainContent, '|'); @@ -4949,15 +4972,15 @@ public async Task Resource_api_versions_offered_as_completion_for_single_argumen var completions = await file.RequestCompletion(cursors[0]); var updated = file.ApplyCompletion(completions, "2022-09-01"); updated.Should().HaveSourceText(""" - type acct = resource<'Microsoft.Storage/storageAccounts@2022-09-01'|> - type fullyQualified = sys.resource<'Microsoft.Storage/storageAccounts@'> + type acct = resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'|> + type fullyQualified = sys.resourceInput<'Microsoft.Storage/storageAccounts@'> """); completions = await file.RequestCompletion(cursors[1]); updated = file.ApplyCompletion(completions, "2022-09-01"); updated.Should().HaveSourceText(""" - type acct = resource<'Microsoft.Storage/storageAccounts@'> - type fullyQualified = sys.resource<'Microsoft.Storage/storageAccounts@2022-09-01'|> + type acct = resourceInput<'Microsoft.Storage/storageAccounts@'> + type fullyQualified = sys.resourceInput<'Microsoft.Storage/storageAccounts@2022-09-01'|> """); } diff --git a/src/Bicep.LangServer.IntegrationTests/ExpressionAndTypeExtractorTests.cs b/src/Bicep.LangServer.IntegrationTests/ExpressionAndTypeExtractorTests.cs index 7f5b47d40b6..0462cc341bd 100644 --- a/src/Bicep.LangServer.IntegrationTests/ExpressionAndTypeExtractorTests.cs +++ b/src/Bicep.LangServer.IntegrationTests/ExpressionAndTypeExtractorTests.cs @@ -663,7 +663,7 @@ param properties { param _artifactsLocation string param _artifactsLocationSasToken string @description('Describes the properties of a Virtual Machine Extension.') - param properties resource<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties = { + param properties resourceInput<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties = { // Entire properties object selected publisher: 'Microsoft.Compute' type: 'CustomScriptExtension' @@ -1798,7 +1798,7 @@ public async Task IfThereIsASelection_ThenPickUpEverythingInTheSelection_AfterEx """ // My comment here @description('A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request.') - param options resource<'Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces@2021-06-15'>.properties.options = {} + param options resourceInput<'Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces@2021-06-15'>.properties.options = {} resource cassandraKeyspace 'Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces@2021-06-15' = { name: 'testResource/cassandraKeyspace' @@ -2889,7 +2889,7 @@ await RunExtractToTypeTest( """, """ @description('Properties of the network security group.') - param properties resource<'Microsoft.Network/networkSecurityGroups@2023-09-01'>.properties = { + param properties resourceInput<'Microsoft.Network/networkSecurityGroups@2023-09-01'>.properties = { securityRules: [ { id: 'id1' @@ -2961,7 +2961,7 @@ await RunExtractToTypeTest( """, """ @description('Backend address pool resource of URL path map path rule.') - param backendAddressPool resource<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.urlPathMaps[*].properties.pathRules[*].properties.backendAddressPool = { + param backendAddressPool resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.urlPathMaps[*].properties.pathRules[*].properties.backendAddressPool = { id: 'id' } @@ -3435,7 +3435,7 @@ private async Task RunExtractToParameterTest(string fileWithSelection, string? e } } - var resourceDerivedFix = extractedParamFixes.Where(fix => fix.Title.Contains("resource<")).SingleOrDefault(); + var resourceDerivedFix = extractedParamFixes.Where(fix => fix.Title.Contains("resourceInput<")).SingleOrDefault(); if (expectedResourceDerivedText == null) { resourceDerivedFix.Should().BeNull("expected no code actions to extract parameter with resource-derived type"); diff --git a/src/Bicep.LangServer.IntegrationTests/SignatureHelpTests.cs b/src/Bicep.LangServer.IntegrationTests/SignatureHelpTests.cs index 4aa64e8d14a..722c07b0890 100644 --- a/src/Bicep.LangServer.IntegrationTests/SignatureHelpTests.cs +++ b/src/Bicep.LangServer.IntegrationTests/SignatureHelpTests.cs @@ -163,7 +163,7 @@ func isTrue(input bool) bool => !(input == false) [TestMethod] public async Task Signature_help_works_with_parameterized_types() { - var (text, cursor) = ParserHelper.GetFileWithSingleCursor(@"type resourceDerived = resource<|>"); + var (text, cursor) = ParserHelper.GetFileWithSingleCursor(@"type resourceDerived = resourceInput<|>"); using var server = await MultiFileLanguageServerHelper.StartLanguageServer(TestContext, services => services.WithFeatureOverrides(new(ResourceDerivedTypesEnabled: true))); var file = await new ServerRequestHelper(TestContext, server).OpenFile(text); @@ -171,9 +171,9 @@ public async Task Signature_help_works_with_parameterized_types() var signatureHelp = await file.RequestSignatureHelp(cursor); var signature = signatureHelp!.Signatures.Single(); - signature.Label.Should().Be("resource"); + signature.Label.Should().Be("resourceInput"); signature.Documentation!.MarkupContent!.Value.Should().Be(""" - Use the type definition of the body of a specific resource rather than a user-defined type. + Use the type definition of the input for a specific resource rather than a user-defined type. NB: The type definition will be checked by Bicep when the template is compiled but will not be enforced by the ARM engine during a deployment. """); diff --git a/src/Bicep.LangServer.IntegrationTests/TypeStringifierTests.cs b/src/Bicep.LangServer.IntegrationTests/TypeStringifierTests.cs index 9c6b672b61c..ad12b4b5331 100644 --- a/src/Bicep.LangServer.IntegrationTests/TypeStringifierTests.cs +++ b/src/Bicep.LangServer.IntegrationTests/TypeStringifierTests.cs @@ -666,7 +666,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st typeHandlerVersion: string? }? """, - "type resourceDerived = resource<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", + "type resourceDerived = resourceInput<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", DisplayName = "virtual machine extensions properties property")] [DataRow( """ @@ -710,7 +710,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st }? """, "IGNORE", - "type resourceDerived = resource<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", + "type resourceDerived = resourceInput<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", DisplayName = "if")] [DataRow( """ @@ -755,7 +755,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st }? """, "IGNORE", - "type resourceDerived = resource<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", + "type resourceDerived = resourceInput<'Microsoft.Compute/virtualMachines/extensions@2019-12-01'>.properties", DisplayName = "for")] [DataRow( """ @@ -821,7 +821,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "IGNORE", "IGNORE", "IGNORE", - "type resourceDerived = resource<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.gatewayIPConfigurations[*].properties", + "type resourceDerived = resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.gatewayIPConfigurations[*].properties", DisplayName = "Array 1")] [DataRow( """ @@ -869,7 +869,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "IGNORE", "IGNORE", "IGNORE", - "type resourceDerived = resource<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.gatewayIPConfigurations[*].properties.subnet", + "type resourceDerived = resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.gatewayIPConfigurations[*].properties.subnet", DisplayName = "custom object inside an array")] [DataRow( """ @@ -882,7 +882,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "IGNORE", "IGNORE", "IGNORE", - "type resourceDerived = resource<'Microsoft.Network/applicationGateways@2020-11-01'>.dependsOn", + "type resourceDerived = resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.dependsOn", DisplayName = "dependsOn")] [DataRow( """ @@ -915,7 +915,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "type medium = object?", "type strict = object?", null, - DisplayName = "custom object type with zero writable properties (resource<'Microsoft.Network/applicationGateways@2020-11-01'>.identity.userAssignedIdentities)")] + DisplayName = "custom object type with zero writable properties (resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.identity.userAssignedIdentities)")] [DataRow( """ resource testResource 'Microsoft.Network/applicationGateways@2020-11-01' = { @@ -933,7 +933,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "type loose = array?", "type medium = (string /* 'TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_128_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_128_CBC_SHA256' | 'TLS_DHE_DSS_WITH_AES_256_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_256_CBC_SHA256' | 'TLS_DHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_DHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_DHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_DHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384' | 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_RSA_WITH_3DES_EDE_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA256' | 'TLS_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_AES_256_CBC_SHA256' | 'TLS_RSA_WITH_AES_256_GCM_SHA384' | string */)[]?", "type strict = (string /* 'TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_128_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_128_CBC_SHA256' | 'TLS_DHE_DSS_WITH_AES_256_CBC_SHA' | 'TLS_DHE_DSS_WITH_AES_256_CBC_SHA256' | 'TLS_DHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_DHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_DHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_DHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384' | 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_RSA_WITH_3DES_EDE_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA256' | 'TLS_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_AES_256_CBC_SHA256' | 'TLS_RSA_WITH_AES_256_GCM_SHA384' | string */)[]?", - "type resourceDerived = resource<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.sslPolicy.cipherSuites", + "type resourceDerived = resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.sslPolicy.cipherSuites", DisplayName = "typed array")] [DataRow( """ @@ -965,7 +965,7 @@ public void NullableTypes(string typeDeclaration, string expectedLooseSyntax, st "type loose = object?", "type medium = { id: string? }?", "type strict = { id: string? }?", - "type resourceDerived = resource<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.urlPathMaps[*].properties.pathRules[*].properties.backendAddressPool", + "type resourceDerived = resourceInput<'Microsoft.Network/applicationGateways@2020-11-01'>.properties.urlPathMaps[*].properties.pathRules[*].properties.backendAddressPool", DisplayName = "nested typed arrays")] [DataRow( """ diff --git a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs index 683602d75d2..67207b5f371 100644 --- a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs +++ b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs @@ -334,6 +334,7 @@ private static IEnumerable GetTypeCompletions(SemanticModel mode .Concat(GetImportedTypeCompletions(model, context)); private static IEnumerable GetAmbientTypeCompletions(SemanticModel model, BicepCompletionContext context) => model.Binder.NamespaceResolver.GetKnownTypes() + .Where(ambientType => !ambientType.Flags.HasFlag(TypePropertyFlags.FallbackProperty)) .ToLookup(ambientType => ambientType.Name) .SelectMany(grouping => grouping.Count() > 1 || model.Binder.FileSymbol.Declarations.Any(decl => LanguageConstants.IdentifierComparer.Equals(grouping.Key, decl.Name)) ? grouping.Select(ambientType => ($"{ambientType.DeclaringNamespace.Name}.{ambientType.Name}", ambientType)) diff --git a/src/Bicep.LangServer/Refactor/TypeStringifier.cs b/src/Bicep.LangServer/Refactor/TypeStringifier.cs index 22d31513429..a25b42fb2c0 100644 --- a/src/Bicep.LangServer/Refactor/TypeStringifier.cs +++ b/src/Bicep.LangServer/Refactor/TypeStringifier.cs @@ -56,7 +56,7 @@ public static string Stringify(TypeSymbol? type, TypeProperty? typeProperty, Str { // Found the resource itself var resourceTypeName = (resourceDeclarationSyntax.Type as StringSyntax)?.TryGetLiteralValue(); - return $"resource<'{resourceTypeName}'>{propertyAccessDotNotation}"; + return $"resourceInput<'{resourceTypeName}'>{propertyAccessDotNotation}"; } else if (current is ObjectPropertySyntax objectPropertySyntax) {