Skip to content

Commit

Permalink
Remove feature flag for compile-time imports (#13150)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeskew authored Jan 29, 2024
1 parent 12afdcc commit 817ad76
Show file tree
Hide file tree
Showing 28 changed files with 205 additions and 194 deletions.
3 changes: 0 additions & 3 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ The following features can be optionally enabled through your `bicepconfig.json`
### `assertions`
Should be enabled in tandem with `testFramework` experimental feature flag for expected functionality. Allows you to author boolean assertions using the `assert` keyword comparing the actual value of a parameter, variable, or resource name to an expected value. Assert statements can only be written directly within the Bicep file whose resources they reference. For more information, see [Bicep Experimental Test Framework](https://github.com/Azure/bicep/issues/11967).

### `compileTimeImports`
Allows you to use symbols defined in another Bicep file. See [Import types, variables and functions](./bicep-import.md#import-types-variables-and-functions-preview).

### `extensibility`
Allows Bicep to use a provider model to deploy non-ARM resources. Currently, we only support a Kubernetes provider. See [Bicep extensibility Kubernetes provider](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-extensibility-kubernetes-provider).

Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Cli.IntegrationTests/JsonRpcCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ param declaredType asdf
});

await RunServerTest(
services => services.WithFileSystem(fileSystem).WithFeatureOverrides(new(CompileTimeImportsEnabled: true)),
services => services.WithFileSystem(fileSystem),
async (client, token) =>
{
var response = await client.GetMetadata(new("/main.bicep"), token);
Expand Down
132 changes: 58 additions & 74 deletions src/Bicep.Core.IntegrationTests/CompileTimeImportTests.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5448,7 +5448,7 @@ public void Test_Issue12698()
{

var result = CompilationHelper.Compile(
Services.WithFeatureOverrides(new(UserDefinedFunctionsEnabled: true, CompileTimeImportsEnabled: true)),
Services.WithFeatureOverrides(new(UserDefinedFunctionsEnabled: true)),
("main.bicep", """
import { MyFunction } from 'export.bicep'
Expand Down Expand Up @@ -5601,7 +5601,7 @@ param foo {
[TestMethod]
public void Test_Issue12908()
{
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, CompileTimeImportsEnabled: true)),
var result = CompilationHelper.Compile(
("main.bicep", """
import { varSecureType } from 'types.bicep'
import * as types from 'types.bicep'
Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ public void Type_property_access_can_be_used_on_resource_derived_types()
[TestMethod]
public void Type_property_access_resolves_refs_and_traverses_imports()
{
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, CompileTimeImportsEnabled: true, ResourceDerivedTypesEnabled: true)),
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)),
("types.bicep", """
@export()
type myObject = {
Expand Down Expand Up @@ -1295,7 +1295,7 @@ public void Invalid_type_index_access_raises_diagnostic(string accessExpression,
[TestMethod]
public void Type_index_access_resolves_refs_and_traverses_imports()
{
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, CompileTimeImportsEnabled: true)),
var result = CompilationHelper.Compile(
("types.bicep", """
@export()
type myTuple = [int, string]
Expand Down Expand Up @@ -1384,7 +1384,7 @@ public void Type_additional_properties_access_can_be_used_on_resource_derived_ty
[TestMethod]
public void Type_additional_properties_access_resolves_refs_and_traverses_imports()
{
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, CompileTimeImportsEnabled: true, ResourceDerivedTypesEnabled: true)),
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, ResourceDerivedTypesEnabled: true)),
("types.bicep", """
type tagsDict = {
*: resource<'Microsoft.Resources/tags@2022-09-01'>.properties.tags
Expand Down Expand Up @@ -1490,7 +1490,7 @@ public void Type_element_access_can_be_used_on_resource_derived_types()
[TestMethod]
public void Type_element_access_resolves_refs_and_traverses_imports()
{
var result = CompilationHelper.Compile(new ServiceBuilder().WithFeatureOverrides(new(TestContext, CompileTimeImportsEnabled: true, ResourceDerivedTypesEnabled: true)),
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[*]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[
{
"label": "import",
"kind": "keyword",
"detail": "Import keyword",
"deprecated": false,
"preselect": false,
"sortText": "2_import",
"insertTextFormat": "plainText",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "import"
}
},
{
"label": "metadata",
"kind": "keyword",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "export",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nexport(): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_export",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "export()$0"
}
},
{
"label": "maxLength",
"kind": "function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "export",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nexport(): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_export",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "export()$0"
}
},
{
"label": "maxLength",
"kind": "function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,22 @@
"title": "signature help",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "export",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nexport(): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_export",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "export()$0"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "export",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nexport(): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_export",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "export()$0"
}
},
{
"label": "sys",
"kind": "folder",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public void GetBuiltInConfiguration_NoParameter_ReturnsBuiltInConfigurationWithA
"dynamicTypeLoading": false,
"providerRegistry": false,
"microsoftGraphPreview": false,
"compileTimeImports": false,
"publishSource": false,
"optionalModuleNames": false,
"resourceDerivedTypes": false
Expand Down Expand Up @@ -195,7 +194,6 @@ public void GetBuiltInConfiguration_DisableAllAnalyzers_ReturnsBuiltInConfigurat
"dynamicTypeLoading": false,
"providerRegistry": false,
"microsoftGraphPreview": false,
"compileTimeImports": false,
"publishSource": false,
"optionalModuleNames": false,
"resourceDerivedTypes": false
Expand Down Expand Up @@ -304,7 +302,6 @@ public void GetBuiltInConfiguration_DisableAnalyzers_ReturnsBuiltInConfiguration
"dynamicTypeLoading": false,
"providerRegistry": false,
"microsoftGraphPreview": false,
"compileTimeImports": false,
"publishSource": false,
"optionalModuleNames": false,
"resourceDerivedTypes": false
Expand Down Expand Up @@ -741,7 +738,6 @@ public void GetConfiguration_ValidCustomConfiguration_OverridesBuiltInConfigurat
"dynamicTypeLoading": false,
"providerRegistry": false,
"microsoftGraphPreview": false,
"compileTimeImports": false,
"publishSource": false,
"optionalModuleNames": false,
"resourceDerivedTypes": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Exported_variables_are_not_reported_as_unused()
@export()
var foo = 'foo'
""",
new Options(OnCompileErrors.IncludeErrors, FeatureOverrides: new(CompileTimeImportsEnabled: true)));
new Options(OnCompileErrors.IncludeErrors));
}

[DataRow(@"
Expand Down
3 changes: 0 additions & 3 deletions src/Bicep.Core.UnitTests/Features/FeatureProviderOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public record FeatureProviderOverrides(
bool? AssertsEnabled = default,
bool? DynamicTypeLoadingEnabled = default,
bool? ProviderRegistry = default,
bool? CompileTimeImportsEnabled = default,
bool? MicrosoftGraphPreviewEnabled = default,
bool? PublishSourceEnabled = default,
bool? OptionalModuleNamesEnabled = default,
Expand All @@ -41,7 +40,6 @@ public FeatureProviderOverrides(
bool? AssertsEnabled = default,
bool? DynamicTypeLoadingEnabled = default,
bool? ProviderRegistry = default,
bool? CompileTimeImportsEnabled = default,
bool? MicrosoftGraphPreviewEnabled = default,
bool? PublishSourceEnabled = default,
bool? OptionalModuleNamesEnabled = default,
Expand All @@ -61,7 +59,6 @@ public FeatureProviderOverrides(
AssertsEnabled,
DynamicTypeLoadingEnabled,
ProviderRegistry,
CompileTimeImportsEnabled,
MicrosoftGraphPreviewEnabled,
PublishSourceEnabled,
OptionalModuleNamesEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public OverriddenFeatureProvider(IFeatureProvider features, FeatureProviderOverr

public bool ProviderRegistryEnabled => overrides.ProviderRegistry ?? features.ProviderRegistryEnabled;

public bool CompileTimeImportsEnabled => overrides.CompileTimeImportsEnabled ?? features.CompileTimeImportsEnabled;

public bool MicrosoftGraphPreviewEnabled => overrides.MicrosoftGraphPreviewEnabled ?? features.MicrosoftGraphPreviewEnabled;

public bool PublishSourceEnabled => overrides.PublishSourceEnabled ?? features.PublishSourceEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public record ExperimentalFeaturesEnabled(
bool DynamicTypeLoading,
bool ProviderRegistry,
bool MicrosoftGraphPreview,
bool CompileTimeImports,
bool PublishSource,
bool OptionalModuleNames,
bool ResourceDerivedTypes)
Expand Down
5 changes: 0 additions & 5 deletions src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1966,11 +1966,6 @@ public ErrorDiagnostic RuntimeValueNotAllowedInFunctionDeclaration(string? acces
"BCP356",
"Expected a valid namespace identifier at this location.");

public ErrorDiagnostic CompileTimeImportsNotSupported() => new(
TextSpan,
"BCP357",
$@"Using compile-time import statements requires enabling EXPERIMENTAL feature ""{nameof(ExperimentalFeaturesEnabled.CompileTimeImports)}"".");

public ErrorDiagnostic PathHasNotBeenSpecified() => new(
TextSpan,
"BCP358",
Expand Down
2 changes: 0 additions & 2 deletions src/Bicep.Core/Features/FeatureProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public FeatureProvider(RootConfiguration configuration)

public bool AssertsEnabled => configuration.ExperimentalFeaturesEnabled.Assertions;

public bool CompileTimeImportsEnabled => configuration.ExperimentalFeaturesEnabled.CompileTimeImports;

public bool MicrosoftGraphPreviewEnabled => this.configuration.ExperimentalFeaturesEnabled.MicrosoftGraphPreview;

public static bool TracingEnabled => ReadBooleanEnvVar("BICEP_TRACING_ENABLED", defaultValue: false);
Expand Down
3 changes: 0 additions & 3 deletions src/Bicep.Core/Features/IFeatureProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public interface IFeatureProvider

bool AssertsEnabled { get; }

bool CompileTimeImportsEnabled { get; }

bool MicrosoftGraphPreviewEnabled { get; }

bool PublishSourceEnabled { get; }
Expand All @@ -57,7 +55,6 @@ public interface IFeatureProvider
(PrettyPrintingEnabled, CoreResources.ExperimentalFeatureNames_PrettyPrinting, false, false),
(TestFrameworkEnabled, CoreResources.ExperimentalFeatureNames_TestFramework, false, false),
(AssertsEnabled, CoreResources.ExperimentalFeatureNames_Asserts, true, true),
(CompileTimeImportsEnabled, CoreResources.ExperimentalFeatureNames_CompileTimeImports, true, false),
(MicrosoftGraphPreviewEnabled, CoreResources.ExperimentalFeatureNames_MicrosoftGraphPreview, true, true),
(PublishSourceEnabled, CoreResources.ExperimentalFeatureNames_PublishSource, false, false),
(OptionalModuleNamesEnabled, CoreResources.ExperimentalFeatureNames_OptionalModuleNames, true, false),
Expand Down
5 changes: 0 additions & 5 deletions src/Bicep.Core/Semantics/DeclarationVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,6 @@ public override void VisitCompileTimeImportDeclarationSyntax(CompileTimeImportDe

private Result<ISemanticModel, ErrorDiagnostic> GetImportSourceModel(CompileTimeImportDeclarationSyntax syntax)
{
if (!features.CompileTimeImportsEnabled)
{
return new(DiagnosticBuilder.ForPosition(syntax).CompileTimeImportsNotSupported());
}

if (!SemanticModelHelper.TryGetModelForArtifactReference(artifactFileLookup, syntax, modelLookup).IsSuccess(out var model, out var modelLoadError))
{
return new(modelLoadError);
Expand Down
1 change: 1 addition & 0 deletions src/Bicep.Core/Semantics/Decorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Bicep.Core.Syntax;
using Bicep.Core.TypeSystem;
using Bicep.Core.TypeSystem.Types;
using Bicep.Core.Workspaces;

namespace Bicep.Core.Semantics
{
Expand Down
Loading

0 comments on commit 817ad76

Please sign in to comment.