Skip to content

Commit

Permalink
Reformat code (#13565)
Browse files Browse the repository at this point in the history
Update code to match the house style 馃槑

Co-authored-by: Bicep Automation <bicep@noreply.github.com>
  • Loading branch information
microsoft-github-policy-service[bot] and Bicep Automation committed Mar 11, 2024
1 parent a019cb7 commit e7c4db3
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/Bicep.Core.IntegrationTests/ExtensibilityTests.cs
Expand Up @@ -485,7 +485,7 @@ public void LegacyProvider_codefix_works()
result.Should().HaveDiagnostics(new[] {
("BCP395", DiagnosticLevel.Warning, "Declaring provider namespaces using the '<providerName>@<version>' expression has been deprecated. Please use an identifier instead."),
});

var diagnostic = result.Diagnostics.OfType<IFixable>().Single();
var fix = diagnostic.Fixes.Single();

Expand Down
4 changes: 2 additions & 2 deletions src/Bicep.Core.IntegrationTests/SourceArchiveTests.cs
Expand Up @@ -119,7 +119,7 @@ private SourceArchive CreateSourceArchive(IModuleDispatcher moduleDispatcher, So
.UnwrapOrThrow();
}

#endregion
#endregion

[TestMethod]
public async Task SourceArtifactId_ForLocalModules_ShouldBeNull()
Expand Down Expand Up @@ -313,7 +313,7 @@ public async Task SourceArtifactId_ShouldIgnoreModuleRefsWithErrors()
result.Should().OnlyContainDiagnostic("BCP192", Diagnostics.DiagnosticLevel.Error, "Unable to restore the artifact with reference \"br:mockregistry.io/test/module2:v1\"*");

// act
var sourceArchive = CreateSourceArchive(moduleDispatcher,result);
var sourceArchive = CreateSourceArchive(moduleDispatcher, result);

sourceArchive.SourceFiles.Select(sf => (sf.Path, sf.SourceArtifact?.FullyQualifiedReference))
.Should().BeEquivalentTo(new[] {
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core.UnitTests/Utils/OciRegistryHelper.cs
Expand Up @@ -19,7 +19,7 @@ namespace Bicep.Core.UnitTests.Utils
public static class OciRegistryHelper
{
public static OciArtifactReference CreateModuleReferenceMock(string registry, string repository, Uri parentModuleUri, string? digest, string? tag)
=> new (ArtifactType.Module, registry, repository, tag, digest, parentModuleUri);
=> new(ArtifactType.Module, registry, repository, tag, digest, parentModuleUri);


public static OciArtifactReference ParseModuleReference(string moduleId /* with or without br: */, Uri? parentModuleUri = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/BicepCompiler.cs
Expand Up @@ -115,7 +115,7 @@ static IEnumerable<(BicepSourceFile, IDiagnostic)> GetDiagnosticsForModulesToRes
{
foreach (var artifact in originalArtifactsToRestore)
{
if (artifact.Syntax is {} &&
if (artifact.Syntax is { } &&
DiagnosticForModule(grouping, artifact.Syntax) is { } diagnostic)
{
yield return (artifact.Origin, diagnostic);
Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Core/Configuration/ProvidersConfiguration.cs
Expand Up @@ -16,7 +16,7 @@ public record ProviderConfigEntry

public string Path { get; }

public string Scheme {get;}
public string Scheme { get; }

public ProviderConfigEntry(string providerConfigEntry)
{
Expand All @@ -29,7 +29,7 @@ public ProviderConfigEntry(string providerConfigEntry)

public override string ToString()
{
return $"{this.Scheme}:{this.Path}";
return $"{this.Scheme}:{this.Path}";
}
}

Expand Down Expand Up @@ -66,4 +66,4 @@ public override void WriteTo(Utf8JsonWriter writer)

public bool IsSysOrBuiltIn(string providerName)
=> providerName == SystemNamespaceType.BuiltInName || this.Data.TryGetValue(providerName)?.BuiltIn == true;
}
}
42 changes: 21 additions & 21 deletions src/Bicep.Core/Emit/PlaceholderParametersJsonWriter.cs
Expand Up @@ -95,28 +95,28 @@ private JToken GenerateTemplate(string contentVersion)

foreach (var parameterSymbol in filteredParameterDeclarations)
{
jsonWriter.WritePropertyName(parameterSymbol.Name);
jsonWriter.WritePropertyName(parameterSymbol.Name);

jsonWriter.WriteStartObject();
switch (parameterSymbol.Type.Name)
{
case "string":
emitter.EmitProperty("value", "");
break;
case "int":
emitter.EmitProperty("value", () => jsonWriter.WriteValue(0));
break;
case "bool":
emitter.EmitProperty("value", () => jsonWriter.WriteValue(false));
break;
case "object":
emitter.EmitProperty("value", () => { jsonWriter.WriteStartObject(); jsonWriter.WriteEndObject(); });
break;
case "array":
emitter.EmitProperty("value", () => { jsonWriter.WriteStartArray(); jsonWriter.WriteEndArray(); });
break;
}
jsonWriter.WriteEndObject();
jsonWriter.WriteStartObject();
switch (parameterSymbol.Type.Name)
{
case "string":
emitter.EmitProperty("value", "");
break;
case "int":
emitter.EmitProperty("value", () => jsonWriter.WriteValue(0));
break;
case "bool":
emitter.EmitProperty("value", () => jsonWriter.WriteValue(false));
break;
case "object":
emitter.EmitProperty("value", () => { jsonWriter.WriteStartObject(); jsonWriter.WriteEndObject(); });
break;
case "array":
emitter.EmitProperty("value", () => { jsonWriter.WriteStartArray(); jsonWriter.WriteEndArray(); });
break;
}
jsonWriter.WriteEndObject();
}

jsonWriter.WriteEndObject();
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/Registry/ArtifactRegistry.cs
Expand Up @@ -58,7 +58,7 @@ public Task PublishProvider(ArtifactReference reference, BinaryData typesTgz)

public string? GetDocumentationUri(ArtifactReference reference) => this.TryGetDocumentationUri(ConvertReference(reference));

public async Task<string?> TryGetModuleDescription(ModuleSymbol module, ArtifactReference reference) =>
public async Task<string?> TryGetModuleDescription(ModuleSymbol module, ArtifactReference reference) =>
await this.TryGetModuleDescription(module, ConvertReference(reference));

public ResultWithException<SourceArchive> TryGetSource(ArtifactReference reference) => this.TryGetSource(ConvertReference(reference));
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/Registry/LocalModuleRegistry.cs
Expand Up @@ -83,7 +83,7 @@ public override Task PublishProvider(LocalModuleReference reference, BinaryData

public override Task<string?> TryGetModuleDescription(ModuleSymbol module, LocalModuleReference moduleReference)
{
if (module.TryGetSemanticModel().TryUnwrap() is {} model)
if (module.TryGetSemanticModel().TryUnwrap() is { } model)
{
return Task.FromResult(DescriptionHelper.TryGetFromSemanticModel(model));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/Registry/TemplateSpecModuleRegistry.cs
Expand Up @@ -133,7 +133,7 @@ public override ResultWithDiagnostic<Uri> TryGetLocalArtifactEntryPointUri(Templ

public override Task<string?> TryGetModuleDescription(ModuleSymbol module, TemplateSpecModuleReference moduleReference)
{
if (module.TryGetSemanticModel().TryUnwrap() is {} model)
if (module.TryGetSemanticModel().TryUnwrap() is { } model)
{
return Task.FromResult(DescriptionHelper.TryGetFromSemanticModel(model));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/Semantics/DeclarationVisitor.cs
Expand Up @@ -486,7 +486,7 @@ private ResultWithDiagnostic<ResourceTypesProviderDescriptor> TryGetProviderDesc
return new(x => x.ExpectedProviderSpecification());
}

if (syntax.Specification is ConfigurationManagedProviderSpecification configSpec &&
if (syntax.Specification is ConfigurationManagedProviderSpecification configSpec &&
configuration.ProvidersConfig.IsSysOrBuiltIn(configSpec.NamespaceIdentifier))
{
return new(ResourceTypesProviderDescriptor.CreateBuiltInProviderDescriptor(
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/SourceCode/SourceCodeDocumentLinkHelper.cs
Expand Up @@ -39,7 +39,7 @@ public static class SourceCodeDocumentLinkHelper

foreach (var artifact in grouping)
{
if (artifact.Syntax is {} syntax &&
if (artifact.Syntax is { } syntax &&
syntax.Path is { } &&
artifact.Result.IsSuccess(out var uri))
{
Expand Down
Expand Up @@ -38,4 +38,4 @@ public record ProviderSpecificationTrivia(TextSpan Span) : IProviderSpecificatio
public string NamespaceIdentifier => LanguageConstants.ErrorName;
public bool IsValid => false;
public string? Version => null;
}
}
8 changes: 5 additions & 3 deletions src/Bicep.Core/Workspaces/SourceFileGroupingBuilder.cs
Expand Up @@ -75,7 +75,7 @@ public static SourceFileGrouping Rebuild(IFileResolver fileResolver, IFeaturePro
var sourceFilesToRebuild = artifactsToRestore
.Select(artifact =>
{
if (artifact.Syntax is {})
if (artifact.Syntax is { })
{
builder.artifactLookup.Remove(artifact.Syntax);
}
Expand Down Expand Up @@ -177,7 +177,8 @@ private void PopulateRecursive(BicepSourceFile file, IFeatureProviderFactory fea
{
if (restorable is ProviderDeclarationSyntax providerDeclaration)
{
var isBuiltInProvider = providerDeclaration.Specification switch {
var isBuiltInProvider = providerDeclaration.Specification switch
{
LegacyProviderSpecification => true,
ConfigurationManagedProviderSpecification configSpec => config.ProvidersConfig.IsSysOrBuiltIn(configSpec.NamespaceIdentifier),
_ => false,
Expand Down Expand Up @@ -303,7 +304,8 @@ private ArtifactResolutionInfo GetArtifactRestoreResult(BicepSourceFile sourceFi
fileResultByUri[fileUri].IsSuccess(out var sourceFile) &&
cycles.TryGetValue(sourceFile, out var cycle))
{
ResultWithDiagnostic<Uri> result = cycle switch {
ResultWithDiagnostic<Uri> result = cycle switch
{
{ Length: 1 } when cycle[0] is BicepParamFile paramFile => new(x => x.CyclicParametersSelfReference()),
{ Length: 1 } => new(x => x.CyclicModuleSelfReference()),
// the error message is generic so it should work for either bicep module or params
Expand Down
Expand Up @@ -317,7 +317,7 @@ public async Task RestoredValidModule_WithSource_RequestingBicepFile_ShouldRetur
var bicepSource = "metadata hi = 'This is the bicep source file'";
var bicepUri = PathHelper.FilePathToFileUrl(Root("foo/bar/entrypoint.bicep"));
var sourceArchive = new SourceArchiveBuilder().WithBicepFile(bicepUri, bicepSource).Build();
dispatcher.Setup(m => m.TryGetModuleSources(moduleReference!)).Returns(new ResultWithException<SourceArchive>(sourceArchive ));
dispatcher.Setup(m => m.TryGetModuleSources(moduleReference!)).Returns(new ResultWithException<SourceArchive>(sourceArchive));

var resolver = StrictMock.Of<IFileResolver>();
resolver.Setup(m => m.TryRead(compiledJsonUri)).Returns(ResultHelper.Create(compiledJsonContents, nullBuilder));
Expand Down
Expand Up @@ -170,14 +170,14 @@ public async Task<DocumentLink<ExternalSourceDocumentLinkData>> ResolveDocumentL
}

return request with
{
Target = new ExternalSourceReference(targetArtifactReference, sourceArchive).ToUri().ToString()
};
{
Target = new ExternalSourceReference(targetArtifactReference, sourceArchive).ToUri().ToString()
};

DocumentLink<ExternalSourceDocumentLinkData> GetAlternateLink() => request with
{
Target = data.CompiledJsonLink
};
{
Target = data.CompiledJsonLink
};
}

private void ShowMessage(string message)
Expand Down
Expand Up @@ -60,14 +60,14 @@ public Task<BicepExternalSourceResponse> Handle(BicepExternalSourceParams reques
if (!moduleReference.IsExternal)
{
telemetryProvider.PostEvent(ExternalSourceRequestFailure("localNotSupported"));
return Task.FromResult(new BicepExternalSourceResponse(null,
return Task.FromResult(new BicepExternalSourceResponse(null,
$"The specified module reference '{request.Target}' refers to a local module which is not supported by {BicepExternalSourceLspMethodName} requests."));
}

if (!moduleDispatcher.TryGetLocalArtifactEntryPointUri(moduleReference).IsSuccess(out var compiledJsonUri))
{
telemetryProvider.PostEvent(ExternalSourceRequestFailure(nameof(moduleDispatcher.TryGetLocalArtifactEntryPointUri)));
return Task.FromResult(new BicepExternalSourceResponse(null,
return Task.FromResult(new BicepExternalSourceResponse(null,
$"Unable to obtain the entry point URI for module '{moduleReference.FullyQualifiedReference}'."));
}

Expand Down

0 comments on commit e7c4db3

Please sign in to comment.