Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/Bicep.Cli.IntegrationTests/DecompileCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task Decompile_EmptyTemplate_ShouldSucceed()
[TestMethod]
public async Task Decompile_BicepGeneratedTemplate_ShouldShowBicepGeneratedWarning()
{
var (jsonPath, _) = Setup(TestContext);
var (jsonPath, _) = Setup(TestContext);

var (output, error, result) = await Bicep("decompile", "--force", jsonPath);

Expand Down
4 changes: 2 additions & 2 deletions src/Bicep.Cli/Commands/ConsoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ private string GetPrefix(StringBuilder buffer)
// referenced from how NodeJS REPL handles jumping between words for MacOS:
// https://github.com/nodejs/node/blob/0e2126d8b1c0eb93b105ac53c0939908392cbb42/lib/internal/readline/interface.js#L1435-L1445
// Option key in MacOS maps to Alt
case (ConsoleModifiers.Control, RightArrow) or (ConsoleModifiers.Alt, F):
case (ConsoleModifiers.Control, RightArrow) or (ConsoleModifiers.Alt, F):
editor.MoveToWordBoundary(+1);
break;

case (_, RightArrow):
editor.MoveRight();
break;
Expand Down
4 changes: 2 additions & 2 deletions src/Bicep.Cli/Helpers/Deploy/DeploymentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static void AppendError(StringBuilder sb, ExtendedErrorInfo error, int depth)

private static string? GetError(DeploymentOperationDefinition operation)
{
if (operation.Properties.StatusMessage?.TryFromJToken<ErrorResponseMessage>() is not {} errorResponse ||
if (operation.Properties.StatusMessage?.TryFromJToken<ErrorResponseMessage>() is not { } errorResponse ||
errorResponse.Error is not { } error)
{
return null;
Expand Down Expand Up @@ -540,4 +540,4 @@ public static DeploymentView GetDeploymentView(LocalDeploymentResult result)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public async Task TryGetModulesAsync()
new("br:registry.contoso.io/test/module1:v2", "param p12 string", WithSource: false),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var modules = await provider.TryGetModulesAsync();

modules.Should().HaveCount(2);
Expand All @@ -81,10 +81,10 @@ public async Task GetCachedModules()
new("br:registry.contoso.io/test/module1:v2", "param p12 string", WithSource: false),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

provider.GetCachedModules().Should().HaveCount(0);

Expand All @@ -108,10 +108,10 @@ public async Task TryGetModulesAsync_ShouldCacheResult()
new("br:registry.contoso.io/test/module1:v2", "param p12 string", WithSource: false),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var modules = await provider.TryGetModulesAsync();
modules.Should().HaveCount(2);
Expand All @@ -134,10 +134,10 @@ public async Task GetDetails_ShouldBeCached()
new("br:registry.contoso.io/test/module1:v2", "metadata description = 'this is module 1 version 2'\nparam p12 string", WithSource: false, DocumentationUri: "http://contoso.com/help12"),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
provider.GetCachedModules().Should().BeEmpty();

var module = await provider.TryGetModuleAsync("test/module1");
Expand Down Expand Up @@ -172,10 +172,10 @@ public async Task GetVersions_ShouldBeCached()
new("br:registry.contoso.io/test/module1:v2", "metadata description = 'this is module 1 version 2'\nparam p12 string", WithSource: false, DocumentationUri: "http://contoso.com/help12"),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/module1");
module.Should().NotBeNull();
Expand Down Expand Up @@ -209,10 +209,10 @@ public async Task GetDetails_ShouldAlsoCacheVersions_BecauseGettingModuleDetails
new("br:registry.contoso.io/test/module1:v2", "metadata description = 'this is module 1 version 2'\nparam p12 string", WithSource: false, DocumentationUri: "http://contoso.com/help12"),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/module1");
module.Should().NotBeNull();
Expand All @@ -239,10 +239,10 @@ public async Task Module_WithNoVersionsHavingDetails()
new("br:registry.contoso.io/test/module1:v2", "metadata hello = 'this is module 1 version 2'\nparam p12 string", WithSource: false),
]);

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/module1");
module.Should().NotBeNull();
Expand Down Expand Up @@ -275,10 +275,10 @@ public async Task NoVersionsWhichAreValidBicepModules()
await RegistryHelper.PublishExtensionToRegistryAsync(services.Build(), "br:registry.contoso.io/test/repo1:v1", new BinaryData(""));
await RegistryHelper.PublishExtensionToRegistryAsync(services.Build(), "br:registry.contoso.io/test/repo1:v2", new BinaryData(""));

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/repo1");
module.Should().NotBeNull();
Expand Down Expand Up @@ -314,10 +314,10 @@ public async Task IgnoreVersionsWhichAreNotValidBicepModules()
await RegistryHelper.PublishModuleToRegistryAsync(services, clientFactory, fileSystem, new ModuleToPublish("br:registry.contoso.io/test/repo1:v2", "metadata description = 'this is module 1 version 2'", WithSource: true, "https://docs/m1v2"));
await RegistryHelper.PublishExtensionToRegistryAsync(services.Build(), "br:registry.contoso.io/test/repo1:v3", new BinaryData(""));

var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/repo1");
module.Should().NotBeNull();
Expand Down Expand Up @@ -362,10 +362,10 @@ public async Task GetCachedVersions_ShouldNotThrowOnErrors()
new("br:registry.contoso.io/test/module1:v1", "metadata description = 'this is module 1 version 1'\nparam p1 bool", WithSource: true, DocumentationUri: "http://contoso.com/help11"),
]);

var provider = new PrivateAcrModuleMetadataProviderThatThrows(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider = new PrivateAcrModuleMetadataProviderThatThrows(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));

var module = await provider.TryGetModuleAsync("test/module1");
module.Should().NotBeNull();
Expand All @@ -374,10 +374,10 @@ public async Task GetCachedVersions_ShouldNotThrowOnErrors()
(await module!.TryGetVersionsAsync()).Should().BeEmpty();
module.GetCachedVersions().Should().BeEmpty();

var provider2NoThrow = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var provider2NoThrow = new PrivateAcrModuleMetadataProvider(
BicepTestConstants.BuiltInConfiguration.Cloud,
"registry.contoso.io",
CreateTransportFactory(clientFactory));
var module2 = await provider2NoThrow.TryGetModuleAsync("test/module1");

module2!.GetCachedVersions().Should().BeEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
using Bicep.Core.Syntax;
using Bicep.Core.Text;
using Bicep.Core.UnitTests.Assertions;
using Bicep.Core.UnitTests.Features;
using Bicep.Core.UnitTests.FileSystem;
using Bicep.Core.UnitTests.Mock;
using Bicep.Core.UnitTests.Features;
using Bicep.Core.UnitTests.Utils;
using Bicep.IO.Abstraction;
using Bicep.Testing.Assertions;
Expand Down
10 changes: 5 additions & 5 deletions src/Bicep.Core.UnitTests/Utils/OciRegistryHelper.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.IO.Abstractions.TestingHelpers;
using Bicep.Core.Configuration;
using Bicep.Core.Features;
using Bicep.Core.Modules;
using Bicep.Core.Registry;
using Bicep.Core.Registry.Catalog;
using Bicep.Core.Registry.Azure;
using Bicep.Core.Registry.Catalog;
using Bicep.Core.Registry.Oci;
using Bicep.Core.Registry.Oci.Oras;
using Bicep.Core.Registry.Sessions;
using Bicep.Core.SourceGraph;
using Bicep.Core.Utils;
using System.IO.Abstractions.TestingHelpers;
using Bicep.Core.UnitTests.Mock;
using Bicep.Core.UnitTests.Registry;
using Bicep.Core.Utils;
using Bicep.IO.Abstraction;
using Bicep.IO.FileSystem;
using FluentAssertions;
Expand Down Expand Up @@ -120,7 +120,7 @@ await containerRegistryManager.PushArtifactAsync(
);

return (client, clientFactory);
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ private static bool IsSecure(Semantics.Metadata.ParameterMetadata targetMetadata
return TypeHelper.IsOrContainsSecureType(targetMetadata.TypeReference.Type);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Bicep.Core/Registry/Oci/Oras/OrasRegistrySession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using OrasProject.Oras.Oci;
using OrasProject.Oras.Registry.Remote;
using OrasProject.Oras.Registry.Remote.Auth;
using OrasRepositoryClient = OrasProject.Oras.Registry.Remote.Repository;
using OrasReference = OrasProject.Oras.Registry.Reference;
using OrasRepositoryClient = OrasProject.Oras.Registry.Remote.Repository;

namespace Bicep.Core.Registry.Oci.Oras;

Expand Down
40 changes: 20 additions & 20 deletions src/Bicep.Core/Registry/OciArtifactRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
using Bicep.Core.Utils;
using Bicep.IO.Abstraction;
using Microsoft.Extensions.Logging;
using JsonSerializer = System.Text.Json.JsonSerializer;
using OrasProject.Oras.Exceptions;
using JsonSerializer = System.Text.Json.JsonSerializer;

namespace Bicep.Core.Registry
{
Expand Down Expand Up @@ -242,37 +242,37 @@ private OciManifest GetCachedManifest(OciArtifactReference ociArtifactModuleRefe
}
}

private ImmutableDictionary<string, string>? TryGetOciAnnotations(OciArtifactReference reference)
{
try
{
return GetCachedManifest(reference).Annotations;
}
catch (Exception)
private ImmutableDictionary<string, string>? TryGetOciAnnotations(OciArtifactReference reference)
{
try
{
var session = CreateSession(reference);
return GetCachedManifest(reference).Annotations;
}
catch (Exception)
{
try
{
var session = CreateSession(reference);
try
{
#pragma warning disable VSTHRD002
var (_, manifest) = session.ResolveAsync(reference, CancellationToken.None).GetAwaiter().GetResult();
var (_, manifest) = session.ResolveAsync(reference, CancellationToken.None).GetAwaiter().GetResult();
#pragma warning restore VSTHRD002
return manifest.Annotations ?? [];
}
finally
{
return manifest.Annotations ?? [];
}
finally
{
#pragma warning disable VSTHRD002
session.DisposeAsync().AsTask().GetAwaiter().GetResult();
session.DisposeAsync().AsTask().GetAwaiter().GetResult();
#pragma warning restore VSTHRD002
}
}
catch
{
return null;
}
}
catch
{
return null;
}
}
}

public override async Task OnRestoreArtifacts(bool forceRestore)
{
Expand Down
6 changes: 1 addition & 5 deletions src/vscode-bicep-ui/apps/visual-designer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ import { ModuleDeclaration, ResourceDeclaration } from "./features/visualization
import { GlobalStyle } from "./GlobalStyle";
import { Canvas, Graph, nodeConfigAtom } from "./lib/graph";
import { useFitViewToBounds } from "./lib/graph/hooks";
import {
DOCUMENT_DID_CHANGE_NOTIFICATION,
READY_NOTIFICATION,
useGraphUpdate,
} from "./lib/messaging";
import { DOCUMENT_DID_CHANGE_NOTIFICATION, READY_NOTIFICATION, useGraphUpdate } from "./lib/messaging";
import { useTheme } from "./lib/theming";

const DevAppShell = loadDevAppShell();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,6 @@ export function useApplyVisualGraph(getViewportCenter: () => Point) {
// applyGraphLayout once the server returns the computed layout. The visibility
// gate set above is preserved until then.
},
[
setEdgesAtom,
addAtomicNode,
addCompoundNode,
addEdge,
removeNodes,
setLayoutReady,
getViewportCenter,
],
[setEdgesAtom, addAtomicNode, addCompoundNode, addEdge, removeNodes, setLayoutReady, getViewportCenter],
);
}