Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ Allows the ARM template layer to use a new schema to represent resources as an o
### `testFramework`

Should be enabled in tandem with `assertions` experimental feature flag for expected functionality. Allows you to author client-side, offline unit-test test blocks that reference Bicep files and mock deployment parameters in a separate `test.bicep` file using the new `test` keyword. Test blocks can be run with the command *bicep test <filepath_to_file_with_test_blocks>* which runs all `assert` statements in the Bicep files referenced by the test blocks. For more information, see [Bicep Experimental Test Framework](https://github.com/Azure/bicep/issues/11967).
### `thisNamespace`

Enables the `this` namespace for accessing the current resource instance. The `this` namespace is only discoverable in resource bodies. Currently, `this.exists()` and `this.existingResource()` are available for usage. `this.exists()` returns a bool indicating the existence of the current resource. `this.existingResource()` returns null if the resource does not exist and returns the full resource if the resource exists. (Note: This feature will not work until the backend service support has been deployed)
```
resource usingThis 'Microsoft...' = {
name: 'example'
location: 'eastus'
properties: {
property1: this.exists() ? 'resource exists' : 'resource does not exist'
property2: this.existingResource().?properties.?property2
property3: this.existingResource().?tags
}
}
```

### `userDefinedConstraints`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public void GetBuiltInConfiguration_NoParameter_ReturnsBuiltInConfigurationWithA
"desiredStateConfiguration": false,
"userDefinedConstraints": false,
"deployCommands": false,
"multilineStringInterpolation": false
"multilineStringInterpolation": false,
"thisNamespace": false
},
"formatting": {
"indentKind": "Space",
Expand Down Expand Up @@ -197,7 +198,8 @@ public void GetBuiltInConfiguration_DisableAllAnalyzers_ReturnsBuiltInConfigurat
"desiredStateConfiguration": false,
"userDefinedConstraints": false,
"deployCommands": false,
"multilineStringInterpolation": false
"multilineStringInterpolation": false,
"thisNamespace": false
},
"formatting": {
"indentKind": "Space",
Expand Down Expand Up @@ -303,7 +305,8 @@ public void GetBuiltInConfiguration_DisableAnalyzers_ReturnsBuiltInConfiguration
"desiredStateConfiguration": false,
"userDefinedConstraints": false,
"deployCommands": false,
"multilineStringInterpolation": false
"multilineStringInterpolation": false,
"thisNamespace": false
},
"formatting": {
"indentKind": "Space",
Expand Down Expand Up @@ -390,7 +393,8 @@ public void GetBuiltInConfiguration_EnableExperimentalFeature_ReturnsBuiltInConf
DesiredStateConfiguration: false,
UserDefinedConstraints: false,
DeployCommands: false,
MultilineStringInterpolation: false);
MultilineStringInterpolation: false,
ThisNamespace: false);

configuration.WithExperimentalFeaturesEnabled(experimentalFeaturesEnabled).Should().HaveContents(/*lang=json,strict*/ """
{
Expand Down Expand Up @@ -475,7 +479,8 @@ public void GetBuiltInConfiguration_EnableExperimentalFeature_ReturnsBuiltInConf
"desiredStateConfiguration": false,
"userDefinedConstraints": false,
"deployCommands": false,
"multilineStringInterpolation": false
"multilineStringInterpolation": false,
"thisNamespace": false
},
"formatting": {
"indentKind": "Space",
Expand Down Expand Up @@ -827,7 +832,8 @@ public void GetConfiguration_ValidCustomConfiguration_OverridesBuiltInConfigurat
"desiredStateConfiguration": false,
"userDefinedConstraints": false,
"deployCommands": false,
"multilineStringInterpolation": false
"multilineStringInterpolation": false,
"thisNamespace": false
},
"formatting": {
"indentKind": "Space",
Expand Down
9 changes: 6 additions & 3 deletions src/Bicep.Core.UnitTests/Features/FeatureProviderOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public record FeatureProviderOverrides(
bool? DesiredStateConfigurationEnabled = default,
bool? UserDefinedConstraintsEnabled = default,
bool? DeployCommandsEnabled = default,
bool? MultilineStringInterpolationEnabled = default)
bool? MultilineStringInterpolationEnabled = default,
bool? ThisNamespaceEnabled = default)
{
public FeatureProviderOverrides(
TestContext testContext,
Expand All @@ -47,7 +48,8 @@ public FeatureProviderOverrides(
bool? DesiredStateConfigurationEnabled = default,
bool? UserDefinedConstraintsEnabled = default,
bool? DeployCommandsEnabled = default,
bool? MultilineStringInterpolationEnabled = default) : this(
bool? MultilineStringInterpolationEnabled = default,
bool? ThisNamespaceEnabled = default) : this(
FileHelper.GetCacheRootDirectory(testContext),
RegistryEnabled,
SymbolicNameCodegenEnabled,
Expand All @@ -66,6 +68,7 @@ public FeatureProviderOverrides(
DesiredStateConfigurationEnabled,
UserDefinedConstraintsEnabled,
DeployCommandsEnabled,
MultilineStringInterpolationEnabled)
MultilineStringInterpolationEnabled,
ThisNamespaceEnabled)
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public OverriddenFeatureProvider(IFeatureProvider features, FeatureProviderOverr
public bool DeployCommandsEnabled => overrides.DeployCommandsEnabled ?? features.DeployCommandsEnabled;

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

public bool ThisNamespaceEnabled => overrides.ThisNamespaceEnabled ?? features.ThisNamespaceEnabled;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Bicep.Core.Diagnostics;
using Bicep.Core.Semantics;
using Bicep.Core.Semantics.Namespaces;
using Bicep.Core.TypeSystem;
using Bicep.Core.TypeSystem.Types;
using Bicep.Core.UnitTests.Assertions;
using Bicep.Core.UnitTests.Utils;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Bicep.Core.UnitTests.Semantics.Namespaces
Expand Down
Loading
Loading