From ee855d76b640f12a4be8cffd86458698ea0e0683 Mon Sep 17 00:00:00 2001 From: Alex Vincent Date: Thu, 21 Nov 2024 05:53:05 +0100 Subject: [PATCH] formatting and packages (#238) * formatting and packages * precommit fixes * devcontainer --- .devcontainer/devcontainer.json | 47 ++++++++++--------- .pre-commit-config.yaml | 2 +- Directory.Build.props | 4 +- Directory.Packages.props | 38 +++++++++++++++ .../CasCap.Apis.AzureDevOps.Tests.csproj | 20 ++++---- .../Tests/ApiServiceTests.cs | 1 + .../Tests/TestBase.cs | 1 + .../CasCap.Apis.AzureDevOps.csproj | 20 ++++---- .../Models/Yaml/Pipeline.cs | 1 + .../Models/Yaml/StageAzDO.cs | 1 + .../Models/Yaml/Template.cs | 1 + .../Models/Yaml/TriggerAzDO.cs | 1 + .../Services/ApiService.cs | 1 + .../Utilities/LiteralMultilineEventEmitter.cs | 1 + .../Utilities/YamlPipelineGenerator.cs | 1 + .../CasCap.DevOpsYamlizrCli.csproj | 14 +++--- .../Commands/CommandBase.cs | 1 + .../Commands/GenerateCommand.cs | 1 + src/CasCap.DevOpsYamlizrCli/Program.cs | 1 + 19 files changed, 106 insertions(+), 51 deletions(-) create mode 100644 Directory.Packages.props diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fdfe4e7..bd6b591 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,25 +1,30 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet { - "name": "C# (.NET)", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm", - // Features to add to the dev container. More info: https://containers.dev/features. - "features": { - "ghcr.io/devcontainers-contrib/features/pre-commit:2": {} - }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [5000, 5001], - // "portsAttributes": { - // "5001": { - // "protocol": "https" - // } - // } - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "sh . ./.devcontainer/postCreateCommand.sh", - "postStartCommand": "sh . ./.devcontainer/postStartCommand.sh", - // Configure tool-specific properties. - // "customizations": {}, - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + "name": "C# (.NET)", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [5000, 5001], + // "portsAttributes": { + // "5001": { + // "protocol": "https" + // } + // } + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sh . ./.devcontainer/postCreateCommand.sh", + "postStartCommand": "sh . ./.devcontainer/postStartCommand.sh", + // Configure tool-specific properties. + // "customizations": {}, + "mounts": [ + "source=${localEnv:HOME}${localEnv:USERPROFILE}/source/github,target=/workspaces,type=bind,consistency=cached", + "source=${env:HOME}${env:USERPROFILE}/.kube,target=/home/vscode/.kube,type=bind" + ] + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dfd14f2..7e031e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-xml - id: check-yaml diff --git a/Directory.Build.props b/Directory.Build.props index 893a409..f690ce4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,11 +2,11 @@ CasCap - 12.0 + 13.0 + enable b08b24aa-70ab-4ecd-aef9-cce6d49054ec - enable diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..c87d699 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,38 @@ + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CasCap.Apis.AzureDevOps.Tests/CasCap.Apis.AzureDevOps.Tests.csproj b/src/CasCap.Apis.AzureDevOps.Tests/CasCap.Apis.AzureDevOps.Tests.csproj index a39049b..bfe7e28 100644 --- a/src/CasCap.Apis.AzureDevOps.Tests/CasCap.Apis.AzureDevOps.Tests.csproj +++ b/src/CasCap.Apis.AzureDevOps.Tests/CasCap.Apis.AzureDevOps.Tests.csproj @@ -9,22 +9,22 @@ - - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/CasCap.Apis.AzureDevOps.Tests/Tests/ApiServiceTests.cs b/src/CasCap.Apis.AzureDevOps.Tests/Tests/ApiServiceTests.cs index 652d157..e34dddf 100644 --- a/src/CasCap.Apis.AzureDevOps.Tests/Tests/ApiServiceTests.cs +++ b/src/CasCap.Apis.AzureDevOps.Tests/Tests/ApiServiceTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using Xunit; using Xunit.Abstractions; + namespace CasCap.Apis.AzureDevOps.Tests; public class ApiServiceTests : TestBase diff --git a/src/CasCap.Apis.AzureDevOps.Tests/Tests/TestBase.cs b/src/CasCap.Apis.AzureDevOps.Tests/Tests/TestBase.cs index ba6ba2f..43f2292 100644 --- a/src/CasCap.Apis.AzureDevOps.Tests/Tests/TestBase.cs +++ b/src/CasCap.Apis.AzureDevOps.Tests/Tests/TestBase.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit.Abstractions; + namespace CasCap.Apis.AzureDevOps.Tests; public abstract class TestBase diff --git a/src/CasCap.Apis.AzureDevOps/CasCap.Apis.AzureDevOps.csproj b/src/CasCap.Apis.AzureDevOps/CasCap.Apis.AzureDevOps.csproj index 0c6e3e4..6ad0ed3 100644 --- a/src/CasCap.Apis.AzureDevOps/CasCap.Apis.AzureDevOps.csproj +++ b/src/CasCap.Apis.AzureDevOps/CasCap.Apis.AzureDevOps.csproj @@ -12,16 +12,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/src/CasCap.Apis.AzureDevOps/Models/Yaml/Pipeline.cs b/src/CasCap.Apis.AzureDevOps/Models/Yaml/Pipeline.cs index 8ea1a7e..450491a 100644 --- a/src/CasCap.Apis.AzureDevOps/Models/Yaml/Pipeline.cs +++ b/src/CasCap.Apis.AzureDevOps/Models/Yaml/Pipeline.cs @@ -1,6 +1,7 @@ using AzurePipelinesToGitHubActionsConverter.Core.AzurePipelines; using CasCap.Utilities; using YamlDotNet.Serialization; + namespace CasCap.Models; public class Pipeline diff --git a/src/CasCap.Apis.AzureDevOps/Models/Yaml/StageAzDO.cs b/src/CasCap.Apis.AzureDevOps/Models/Yaml/StageAzDO.cs index 3ebd790..c0c815a 100644 --- a/src/CasCap.Apis.AzureDevOps/Models/Yaml/StageAzDO.cs +++ b/src/CasCap.Apis.AzureDevOps/Models/Yaml/StageAzDO.cs @@ -1,4 +1,5 @@ using AzurePipelinesToGitHubActionsConverter.Core.AzurePipelines; + namespace CasCap.Models; public class StageAzDO// : Stage //we can't inherit from Stage here as it will mess up the order of the properties when YAMLised. diff --git a/src/CasCap.Apis.AzureDevOps/Models/Yaml/Template.cs b/src/CasCap.Apis.AzureDevOps/Models/Yaml/Template.cs index ff3423f..d14919b 100644 --- a/src/CasCap.Apis.AzureDevOps/Models/Yaml/Template.cs +++ b/src/CasCap.Apis.AzureDevOps/Models/Yaml/Template.cs @@ -1,5 +1,6 @@ using Microsoft.TeamFoundation.DistributedTask.WebApi; using YamlDotNet.Serialization; + namespace CasCap.Models; public class Template : Pipeline diff --git a/src/CasCap.Apis.AzureDevOps/Models/Yaml/TriggerAzDO.cs b/src/CasCap.Apis.AzureDevOps/Models/Yaml/TriggerAzDO.cs index 1a10951..bc1b20a 100644 --- a/src/CasCap.Apis.AzureDevOps/Models/Yaml/TriggerAzDO.cs +++ b/src/CasCap.Apis.AzureDevOps/Models/Yaml/TriggerAzDO.cs @@ -1,4 +1,5 @@ using AzurePipelinesToGitHubActionsConverter.Core.AzurePipelines; + namespace CasCap.Models; public class TriggerAzDO : Trigger diff --git a/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs b/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs index 5666b80..f48587b 100644 --- a/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs +++ b/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging; using System.Net.Http.Headers; using System.Text; + namespace CasCap.Services; public interface IApiService diff --git a/src/CasCap.Apis.AzureDevOps/Utilities/LiteralMultilineEventEmitter.cs b/src/CasCap.Apis.AzureDevOps/Utilities/LiteralMultilineEventEmitter.cs index 32f1b70..9f03c40 100644 --- a/src/CasCap.Apis.AzureDevOps/Utilities/LiteralMultilineEventEmitter.cs +++ b/src/CasCap.Apis.AzureDevOps/Utilities/LiteralMultilineEventEmitter.cs @@ -1,6 +1,7 @@ using YamlDotNet.Core; using YamlDotNet.Serialization; using YamlDotNet.Serialization.EventEmitters; + namespace CasCap.Utilities; public class LiteralMultilineEventEmitter : ChainedEventEmitter diff --git a/src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs b/src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs index b5675f3..1a6dae0 100644 --- a/src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs +++ b/src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs @@ -9,6 +9,7 @@ using System.Collections.Concurrent; using System.Text; using System.Text.RegularExpressions; + namespace CasCap.Utilities; public class YamlPipelineGenerator diff --git a/src/CasCap.DevOpsYamlizrCli/CasCap.DevOpsYamlizrCli.csproj b/src/CasCap.DevOpsYamlizrCli/CasCap.DevOpsYamlizrCli.csproj index 66c4351..a2e19fd 100644 --- a/src/CasCap.DevOpsYamlizrCli/CasCap.DevOpsYamlizrCli.csproj +++ b/src/CasCap.DevOpsYamlizrCli/CasCap.DevOpsYamlizrCli.csproj @@ -14,13 +14,13 @@ - - - - - - - + + + + + + + diff --git a/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs b/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs index 5356568..5cc1b11 100644 --- a/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs +++ b/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs @@ -10,6 +10,7 @@ using Microsoft.VisualStudio.Services.WebApi; using ShellProgressBar; using System.Diagnostics; + namespace CasCap.Commands; /// diff --git a/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs b/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs index bba7018..c3a910f 100644 --- a/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs +++ b/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs @@ -11,6 +11,7 @@ using System.Collections.Concurrent; using System.ComponentModel.DataAnnotations; using System.Diagnostics; + namespace CasCap.Commands; [Command(Description = "Generate Azure DevOps YAML pipelines from classic definitions.")] diff --git a/src/CasCap.DevOpsYamlizrCli/Program.cs b/src/CasCap.DevOpsYamlizrCli/Program.cs index 25eb4d9..76cbb98 100644 --- a/src/CasCap.DevOpsYamlizrCli/Program.cs +++ b/src/CasCap.DevOpsYamlizrCli/Program.cs @@ -2,6 +2,7 @@ using McMaster.Extensions.CommandLineUtils; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; + namespace CasCap; [Command("yamlizr")]