public async Task Handle_WithValidInput_VerifyNoEntryInDeploymentFileCompilationCache() { var bicepFileContents = @"param name string = 'test' param location string = 'global resource dnsZone 'Microsoft.Network/dnsZones@2018-05-01' = { name: name location: location }"; var template = @"{ ""$schema"": ""https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"", ""contentVersion"": ""1.0.0.0"", ""metadata"": { ""_generator"": { ""name"": ""bicep"", ""version"": ""0.6.18.56646"", ""templateHash"": ""3422964353444461889"" } }, ""parameters"": { ""name"": { ""type"": ""string"", ""defaultValue"": ""test"" }, ""location"": { ""type"": ""string"", ""defaultValue"": ""global"" } }, ""resources"": [ { ""type"": ""Microsoft.Network/dnsZones"", ""apiVersion"": ""2018-05-01"", ""name"": ""[parameters('name')]"", ""location"": ""[parameters('location')]"" } ] }"; var bicepFilePath = FileHelper.SaveResultFile(TestContext, "input.bicep", bicepFileContents); var documentUri = DocumentUri.FromFileSystemPath(bicepFilePath); var bicepCompilationManager = BicepCompilationManagerHelper.CreateCompilationManager(documentUri, bicepFileContents, true); var compilation = bicepCompilationManager.GetCompilation(documentUri) !.Compilation; DeploymentFileCompilationCache.CacheCompilation(documentUri, compilation); var bicepDeploymentParametersHandler = new BicepDeploymentParametersHandler(DeploymentFileCompilationCache, Serializer); await bicepDeploymentParametersHandler.Handle(bicepFilePath, string.Empty, template, CancellationToken.None); Assert.IsNull(DeploymentFileCompilationCache.FindAndRemoveCompilation(documentUri)); }
private IEnumerable <ParameterSymbol> GetParameterSymbols(string documentPath) { var documentUri = DocumentUri.FromFileSystemPath(documentPath); // Reuse the compilation cached by BicepDeploymentScopeRequestHandler var compilation = deploymentFileCompilationCache.FindAndRemoveCompilation(documentUri); if (compilation is null) { return(Enumerable.Empty <ParameterSymbol>()); } var semanticModel = compilation.GetEntrypointSemanticModel(); return(semanticModel.Root.ParameterDeclarations); }