From a968ff213232f15453648a632fd8ba3a85f759ed Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sat, 23 Apr 2022 17:04:57 +0000 Subject: [PATCH 01/18] Update dependency Google.Protobuf to v3.20.1 --- src/INetMock.Client/INetMock.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index bbc7b67..eebf28e 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -9,7 +9,7 @@ - + -- 2.45.2 From 122487ea6d1145790be4657b697cf91870349d2d Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Tue, 26 Apr 2022 17:55:31 +0000 Subject: [PATCH 02/18] Add LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..536fca6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 inetmock + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. -- 2.45.2 From 59e6b93cc7184f1c30ccad8aee639646943cf2a2 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 2 Jun 2022 19:47:13 +0000 Subject: [PATCH 03/18] Update dependency Grpc.Net.Client to v2.46.0 --- src/INetMock.Client/INetMock.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index eebf28e..6e13f0b 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -10,7 +10,7 @@ - + all -- 2.45.2 From dab0bc9b59063a40f4ea5ef99b400b2aadb77cf9 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 2 Jun 2022 19:56:17 +0000 Subject: [PATCH 04/18] Update dependency Nuke.Common to v6.0.3 --- build/_build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/_build.csproj b/build/_build.csproj index 3439e83..c4263d3 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -13,7 +13,7 @@ - + -- 2.45.2 From d6293800bea9fe685e0ed8f56b962241d6d2b61b Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 2 Jun 2022 20:13:36 +0000 Subject: [PATCH 05/18] Update dependency Grpc.Tools to v2.46.3 --- src/INetMock.Client/INetMock.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index 6e13f0b..64e8306 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive -- 2.45.2 From c60378be9b6075465560f23ba88e9ac113eb7072 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 2 Jun 2022 19:56:20 +0000 Subject: [PATCH 06/18] Update dependency nuke.globaltool to v6.0.3 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e6479fe..a2cd149 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "nuke.globaltool": { - "version": "6.0.2", + "version": "6.0.3", "commands": [ "nuke" ] -- 2.45.2 From 37e5e4c66b2a51388090d1e8c2d70b524d86bfed Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 2 Jun 2022 20:13:32 +0000 Subject: [PATCH 07/18] Update dependency Grpc.Net.ClientFactory to v2.46.0 --- src/INetMock.Client/INetMock.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index 64e8306..bfe120a 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive -- 2.45.2 From d9c26f788d213ffccd802552b54b88a807e734fe Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sat, 4 Jun 2022 11:04:50 +0000 Subject: [PATCH 08/18] Update dependency dotnet-grpc to v2.46.0 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a2cd149..5d8c576 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-grpc": { - "version": "2.45.0", + "version": "2.46.0", "commands": [ "dotnet-grpc" ] -- 2.45.2 From 6778e7f8a8e7a11bcba4f7e1086c2eb1702a1dc6 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sat, 4 Jun 2022 12:04:13 +0000 Subject: [PATCH 09/18] Update dependency Google.Protobuf to v3.21.1 --- src/INetMock.Client/INetMock.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index bfe120a..1051980 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -9,7 +9,7 @@ - + -- 2.45.2 From a4812683bb07d2f33a3935036cf7c9cc81e7409f Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 26 Sep 2022 15:15:26 +0200 Subject: [PATCH 10/18] chore(ci): add Agola CI config --- .agola/config.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .agola/config.yml diff --git a/.agola/config.yml b/.agola/config.yml new file mode 100644 index 0000000..237db17 --- /dev/null +++ b/.agola/config.yml @@ -0,0 +1,52 @@ +version: v0 +runs: + - name: Lint + tasks: + - name: Checkout code + runtime: + containers: + - image: docker.io/alpine/git + steps: + - clone: + - save_to_workspace: + contents: + - source_dir: . + dest_dir: . + paths: + - '**' + + - name: Run .NET tests + runtime: + containers: + - image: mcr.microsoft.com/dotnet/sdk:6.0 + environment: + DOCKER_HOST: tcp://127.0.0.1:2375 + INETMOCK_SOCKET: http://127.0.0.1:6767 + - image: code.icb4dc0.de/prskr/ci-images/dind:latest + privileged: true + steps: + - restore_workspace: + dest_dir: . + - run: + name: .NET tests + command: |- + dotnet tool restore + dotnet nuke Test + depends: + - Checkout code + + - name: Lint protobuf + runtime: + containers: + - image: docker.io/bufbuild/buf:latest + steps: + - restore_workspace: + dest_dir: . + - run: + name: buf lint + command: |- + buf ls-files + buf lint + working_dir: ~/project/api/proto + depends: + - Checkout code \ No newline at end of file -- 2.45.2 From d8143ffd3aa5d9b072766fbe611452e994ffba01 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 26 Sep 2022 16:15:57 +0200 Subject: [PATCH 11/18] fix(tests): start container as part of test fixture --- .agola/config.yml | 1 + .../INetMock.Client.IntegrationTest.csproj | 1 + .../INetMockFixture.cs | 51 ++++++++++++++++--- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.agola/config.yml b/.agola/config.yml index 237db17..4ae7e78 100644 --- a/.agola/config.yml +++ b/.agola/config.yml @@ -22,6 +22,7 @@ runs: environment: DOCKER_HOST: tcp://127.0.0.1:2375 INETMOCK_SOCKET: http://127.0.0.1:6767 + TESTCONTAINERS_RYUK_DISABLED: "true" - image: code.icb4dc0.de/prskr/ci-images/dind:latest privileged: true steps: diff --git a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj index 7df0678..fd30480 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj +++ b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj @@ -12,6 +12,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs index f4c6120..7379ce2 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs +++ b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs @@ -1,19 +1,56 @@ using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using DotNet.Testcontainers.Builders; +using DotNet.Testcontainers.Containers; +using Xunit; namespace INetMock.Client.IntegrationTest; -public class INetMockFixture +public class INetMockFixture : IAsyncLifetime { private const string DefaultINetMockSocketPath = "unix:///var/run/inetmock/inetmock.sock"; + private readonly ITestcontainersContainer _inetmockContainer; + + private readonly Stream _memStream = new MemoryStream(); + public INetMockFixture() { - INetMockSocketPath = Environment.GetEnvironmentVariable("INETMOCK_SOCKET") ?? DefaultINetMockSocketPath; - if (INetMockSocketPath.StartsWith("http:")) - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - } + AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); + + + _inetmockContainer = new TestcontainersBuilder() + .WithPrivileged(true) + .WithExposedPort(6767) + .WithPortBinding(6767, true) + .WithCreateContainerParametersModifier(parameters => { parameters.User = "root"; }) + .WithEnvironment("INETMOCK_API_LISTEN", "tcp://0.0.0.0:6767") + .WithImage("registry.gitlab.com/inetmock/inetmock:latest") + .WithName("inetmock") + .WithWaitStrategy(Wait.ForUnixContainer().UntilOperationIsSucceeded(() => + { + Thread.Sleep(5000); + return true; + }, 1)) + .Build(); } - public string INetMockSocketPath { get; } + public string INetMockSocketPath { get; private set; } = DefaultINetMockSocketPath; + + public async Task InitializeAsync() + { + await using (_memStream) + { + await _inetmockContainer.StartAsync(); + } + + INetMockSocketPath = $"http://{_inetmockContainer.Hostname}:{_inetmockContainer.GetMappedPublicPort(6767)}"; + } + + public async Task DisposeAsync() + { + await _inetmockContainer.StopAsync(); + } } -- 2.45.2 From d26b7ff041378838128f1d621ab0afbff6e7232e Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 26 Sep 2022 16:41:39 +0200 Subject: [PATCH 12/18] fix(ci): add GitVersion tool --- .config/dotnet-tools.json | 6 ++++++ build/Build.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5d8c576..5f7646a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,6 +13,12 @@ "commands": [ "nuke" ] + }, + "gitversion.tool": { + "version": "5.10.3", + "commands": [ + "dotnet-gitversion" + ] } } } \ No newline at end of file diff --git a/build/Build.cs b/build/Build.cs index c691524..aa34697 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -25,7 +25,7 @@ class Build : NukeBuild [Solution] readonly Solution? Solution; [GitRepository] readonly GitRepository? GitRepository; - [GitVersion(NoFetch = true, Framework = "net6.0")] readonly GitVersion? GitVersion; + [GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion; GitLab? CI => GitLab.Instance; @@ -90,7 +90,7 @@ class Build : NukeBuild .SetProject(csproj) .SetConfiguration(Configuration) .SetOutputDirectory(ArtifactsDirectory) - .SetVersion(GitVersion?.FullSemVer ?? SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString()) + .SetVersion(GitVersion?.NuGetVersionV2 ?? SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString()) .EnableIncludeSource() .EnableIncludeSymbols() .EnableNoRestore() -- 2.45.2 From 2c45a41a0db5b964fd22caa14c699d9d71858f89 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sun, 3 Jul 2022 07:04:22 +0000 Subject: [PATCH 13/18] Update dependency Nuke.Common to v6.1.2 --- build/_build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/_build.csproj b/build/_build.csproj index c4263d3..398c479 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -13,7 +13,7 @@ - + -- 2.45.2 From 25ae369e6e2388f55dfa54370d99d3fa5daac8e8 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sun, 3 Jul 2022 07:04:24 +0000 Subject: [PATCH 14/18] Update dependency nuke.globaltool to v6.1.2 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5f7646a..cb895fd 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "nuke.globaltool": { - "version": "6.0.3", + "version": "6.1.2", "commands": [ "nuke" ] -- 2.45.2 From 222715b077169a11eff7c20c2835285d806c5ef8 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 26 Sep 2022 17:03:28 +0200 Subject: [PATCH 15/18] chore(deps): update to latest versions --- build/_build.csproj | 2 +- src/INetMock.Client/INetMock.Client.csproj | 8 ++++---- .../INetMock.Client.IntegrationTest.csproj | 6 +++--- tests/INetMock.Client.Test/INetMock.Client.Test.csproj | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build/_build.csproj b/build/_build.csproj index 398c479..ec393a2 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index 1051980..04aedeb 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -9,10 +9,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj index fd30480..c03d1b0 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj +++ b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj @@ -11,10 +11,10 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj index 0d144c1..c03c65a 100644 --- a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj +++ b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj @@ -8,9 +8,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive -- 2.45.2 From 2061f6f684f28dc757f7db85bf6072a0afd77db8 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Fri, 15 Sep 2023 19:01:48 +0200 Subject: [PATCH 16/18] chore: update deps --- .editorconfig | 10 +++++++ .gitlab-ci.yml | 8 ++--- build/Build.cs | 13 ++++---- build/Configuration.cs | 5 +--- build/_build.csproj | 30 +++++++++---------- src/INetMock.Client/Audit/Event.cs | 1 - src/INetMock.Client/Audit/IEventReader.cs | 2 -- .../Audit/IProtoEventReader.cs | 1 - .../Audit/Serialization/ProtoReader.cs | 2 +- .../Audit/Serialization/TypedReader.cs | 12 ++++++-- src/INetMock.Client/INetMock.Client.csproj | 16 +++++----- .../PCAP/Client/PcapApiClient.cs | 18 +++++++++-- .../Audit/Serialization/TypedReaderTest.cs | 10 +++++-- .../INetMock.Client.IntegrationTest.csproj | 18 +++++------ .../INetMockFixture.cs | 7 ++--- .../PCAP/Client/PcapApiClientTests.cs | 4 +-- .../Audit/Serialization/GenericReaderTest.cs | 10 +++++-- .../Audit/Serialization/TypedReaderTest.cs | 10 +++++-- .../INetMock.Client.Test.csproj | 20 ++++++------- 19 files changed, 116 insertions(+), 81 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2a559ae..0202480 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,16 @@ indent_size = 4 indent_size = 4 csharp_style_namespace_declarations = file_scoped:warning csharp_prefer_braces = true:warning +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning +dotnet_style_require_accessibility_modifiers = never:warning + +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_properties = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_accessors = true:warning [*.json] indent_size = 2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d648e81..4de04ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,10 +34,10 @@ test: done; after_script: - docker stop inetmock - variables: + variables: PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/docker INETMOCK_SOCKET: http://docker:6767 - script: + script: - dotnet tool restore - dotnet nuke Test @@ -45,7 +45,7 @@ protobuf-lint: stage: test image: name: docker.io/bufbuild/buf:latest - entrypoint: [""] + entrypoint: [ "" ] script: - cd api/proto/ - buf ls-files @@ -56,6 +56,6 @@ nuget-publish: only: refs: - tags - script: + script: - dotnet tool restore - dotnet nuke NuGetPush diff --git a/build/Build.cs b/build/Build.cs index aa34697..79f920f 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -2,7 +2,6 @@ using NuGet.Versioning; using Nuke.Common; using Nuke.Common.CI; using Nuke.Common.CI.GitLab; -using Nuke.Common.Execution; using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -13,20 +12,19 @@ using Nuke.Common.Utilities.Collections; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; -[CheckBuildProjectConfigurations] [ShutdownDotNetAfterServerBuild] class Build : NukeBuild { - private const string NuGetSourceName = "GitLab"; - public static int Main() => Execute(x => x.Test); + const string NuGetSourceName = "GitLab"; [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - [Solution] readonly Solution? Solution; [GitRepository] readonly GitRepository? GitRepository; [GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion; + [Solution] readonly Solution? Solution; + GitLab? CI => GitLab.Instance; @@ -90,7 +88,8 @@ class Build : NukeBuild .SetProject(csproj) .SetConfiguration(Configuration) .SetOutputDirectory(ArtifactsDirectory) - .SetVersion(GitVersion?.NuGetVersionV2 ?? SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString()) + .SetVersion(GitVersion?.NuGetVersionV2 ?? + SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString()) .EnableIncludeSource() .EnableIncludeSymbols() .EnableNoRestore() @@ -117,4 +116,6 @@ class Build : NukeBuild .SetSource(NuGetSourceName) .SetTargetPath(nupkg) .EnableProcessLogOutput()))); + + public static int Main() => Execute(x => x.Test); } diff --git a/build/Configuration.cs b/build/Configuration.cs index 78049f7..97663e9 100644 --- a/build/Configuration.cs +++ b/build/Configuration.cs @@ -7,8 +7,5 @@ public class Configuration : Enumeration public static Configuration Debug = new() { Value = nameof(Debug) }; public static Configuration Release = new() { Value = nameof(Release) }; - public static implicit operator string(Configuration configuration) - { - return configuration.Value; - } + public static implicit operator string(Configuration configuration) => configuration.Value; } diff --git a/build/_build.csproj b/build/_build.csproj index ec393a2..0dbad78 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -1,20 +1,20 @@ - - Exe - - CS0649;CS0169 - .. - .. - net6.0 - latest - 1 - enable - + + Exe + + CS0649;CS0169 + .. + .. + net6.0 + latest + 1 + enable + - - - - + + + + diff --git a/src/INetMock.Client/Audit/Event.cs b/src/INetMock.Client/Audit/Event.cs index 646d892..04a0b92 100644 --- a/src/INetMock.Client/Audit/Event.cs +++ b/src/INetMock.Client/Audit/Event.cs @@ -71,7 +71,6 @@ public record Event : EventBase where T : EventDetails, new() { public Event() { - } public Event(EventEntity entity) : base(entity) diff --git a/src/INetMock.Client/Audit/IEventReader.cs b/src/INetMock.Client/Audit/IEventReader.cs index 1e347f3..1bb5534 100644 --- a/src/INetMock.Client/Audit/IEventReader.cs +++ b/src/INetMock.Client/Audit/IEventReader.cs @@ -10,7 +10,6 @@ public interface IEventReader : IDisposable, IAsyncDisposable IAsyncEnumerable ReadAllAsync(CancellationToken token = default); /// - /// /// /// /// @@ -25,7 +24,6 @@ public interface IEventReader : IDisposable, IAsyncDisposable where T : Event IAsyncEnumerable> ReadAllAsync(CancellationToken token = default); /// - /// /// /// /// diff --git a/src/INetMock.Client/Audit/IProtoEventReader.cs b/src/INetMock.Client/Audit/IProtoEventReader.cs index 93d0cd9..4bb6edd 100644 --- a/src/INetMock.Client/Audit/IProtoEventReader.cs +++ b/src/INetMock.Client/Audit/IProtoEventReader.cs @@ -1,7 +1,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using Inetmock.Audit.V1; namespace INetMock.Client.Audit; diff --git a/src/INetMock.Client/Audit/Serialization/ProtoReader.cs b/src/INetMock.Client/Audit/Serialization/ProtoReader.cs index c6728cf..d58c90d 100644 --- a/src/INetMock.Client/Audit/Serialization/ProtoReader.cs +++ b/src/INetMock.Client/Audit/Serialization/ProtoReader.cs @@ -9,9 +9,9 @@ namespace INetMock.Client.Audit.Serialization; public sealed class ProtoReader : IProtoEventReader { + private readonly bool _keepStreamOpen; private readonly MemoryPool _memoryPool; private readonly Stream _sourceStream; - private readonly bool _keepStreamOpen; public ProtoReader(Stream sourceStream, bool keepStreamOpen = false) { diff --git a/src/INetMock.Client/Audit/Serialization/TypedReader.cs b/src/INetMock.Client/Audit/Serialization/TypedReader.cs index 4c0127f..70da03d 100644 --- a/src/INetMock.Client/Audit/Serialization/TypedReader.cs +++ b/src/INetMock.Client/Audit/Serialization/TypedReader.cs @@ -27,8 +27,8 @@ public enum DropMode public sealed class TypedReader : IEventReader where T : EventDetails, new() { - private readonly IProtoEventReader _reader; private readonly DropMode _dropMode; + private readonly IProtoEventReader _reader; public TypedReader(IProtoEventReader reader, DropMode dropMode = DropMode.DropDetails) { @@ -76,7 +76,13 @@ public sealed class TypedReader : IEventReader where T : EventDetails, new } while (true); } - public void Dispose() => _reader.Dispose(); + public void Dispose() + { + _reader.Dispose(); + } - public ValueTask DisposeAsync() => _reader.DisposeAsync(); + public ValueTask DisposeAsync() + { + return _reader.DisposeAsync(); + } } diff --git a/src/INetMock.Client/INetMock.Client.csproj b/src/INetMock.Client/INetMock.Client.csproj index 04aedeb..30164b6 100644 --- a/src/INetMock.Client/INetMock.Client.csproj +++ b/src/INetMock.Client/INetMock.Client.csproj @@ -5,20 +5,20 @@ latest - - + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/INetMock.Client/PCAP/Client/PcapApiClient.cs b/src/INetMock.Client/PCAP/Client/PcapApiClient.cs index 38f7344..544fd98 100644 --- a/src/INetMock.Client/PCAP/Client/PcapApiClient.cs +++ b/src/INetMock.Client/PCAP/Client/PcapApiClient.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Google.Protobuf.WellKnownTypes; using Grpc.Core; using Grpc.Net.Client; -using ChannelFactory = INetMock.Client.Grpc.ChannelFactory; +using INetMock.Client.Grpc; namespace INetMock.Client.PCAP.Client; @@ -32,7 +32,13 @@ public class PcapApiClient : IPcapApiClient public async Task> ListAvailableDevicesAsync(CancellationToken token = default) { - var devices = await _pcapServiceClient.ListAvailableDevicesAsync(new(), Metadata.Empty, null, token); + var devices = await _pcapServiceClient.ListAvailableDevicesAsync( + new ListAvailableDevicesRequest(), + Metadata.Empty, + null, + token + ); + return devices.AvailableDevices .Select(d => new RecordingDevice( d.Name, @@ -46,7 +52,13 @@ public class PcapApiClient : IPcapApiClient public async Task> ListActiveRecordingsAsync(CancellationToken token = default) { - var recordings = await _pcapServiceClient.ListActiveRecordingsAsync(new(), Metadata.Empty, null, token); + var recordings = await _pcapServiceClient.ListActiveRecordingsAsync( + new ListActiveRecordingsRequest(), + Metadata.Empty, + null, + token + ); + return recordings.Subscriptions .Select(consumerKey => new Subscription(consumerKey)) .ToList(); diff --git a/tests/INetMock.Client.IntegrationTest/Audit/Serialization/TypedReaderTest.cs b/tests/INetMock.Client.IntegrationTest/Audit/Serialization/TypedReaderTest.cs index 274bbc9..f803162 100644 --- a/tests/INetMock.Client.IntegrationTest/Audit/Serialization/TypedReaderTest.cs +++ b/tests/INetMock.Client.IntegrationTest/Audit/Serialization/TypedReaderTest.cs @@ -20,6 +20,7 @@ public class TypedReaderTest Assert.NotNull(ev); count++; } + Assert.True(count > 0); } @@ -27,7 +28,8 @@ public class TypedReaderTest public async Task Test_ReadAllAsync_DropEntity_AuditFile_HTTPEvents() { await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima")); - await using IEventReader httpReader = new TypedReader(new ProtoReader(fileStream), DropMode.DropEntity); + await using IEventReader httpReader = + new TypedReader(new ProtoReader(fileStream), DropMode.DropEntity); var count = 0; await foreach (var ev in httpReader.ReadAllAsync()) @@ -36,6 +38,7 @@ public class TypedReaderTest Assert.NotNull(ev.Details); count++; } + Assert.True(count > 0); } @@ -51,6 +54,7 @@ public class TypedReaderTest Assert.NotNull(ev); count++; } + Assert.True(count > 0); } @@ -58,7 +62,8 @@ public class TypedReaderTest public async Task Test_ReadAllAsync_DropEntity_AuditFile_DNSEvents() { await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima")); - await using IEventReader httpReader = new TypedReader(new ProtoReader(fileStream), DropMode.DropEntity); + await using IEventReader httpReader = + new TypedReader(new ProtoReader(fileStream), DropMode.DropEntity); var count = 0; await foreach (var ev in httpReader.ReadAllAsync()) @@ -66,6 +71,7 @@ public class TypedReaderTest Assert.NotNull(ev); count++; } + Assert.True(count > 0); } } diff --git a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj index c03d1b0..bc77eec 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj +++ b/tests/INetMock.Client.IntegrationTest/INetMock.Client.IntegrationTest.csproj @@ -11,27 +11,27 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - PreserveNewest - + + PreserveNewest + diff --git a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs index 7379ce2..dee07f7 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs +++ b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs @@ -11,7 +11,7 @@ namespace INetMock.Client.IntegrationTest; public class INetMockFixture : IAsyncLifetime { private const string DefaultINetMockSocketPath = "unix:///var/run/inetmock/inetmock.sock"; - private readonly ITestcontainersContainer _inetmockContainer; + private readonly IContainer _inetmockContainer; private readonly Stream _memStream = new MemoryStream(); @@ -20,12 +20,11 @@ public class INetMockFixture : IAsyncLifetime { AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - - _inetmockContainer = new TestcontainersBuilder() + _inetmockContainer = new ContainerBuilder() .WithPrivileged(true) .WithExposedPort(6767) .WithPortBinding(6767, true) - .WithCreateContainerParametersModifier(parameters => { parameters.User = "root"; }) + .WithCreateParameterModifier(parameters => { parameters.User = "root"; }) .WithEnvironment("INETMOCK_API_LISTEN", "tcp://0.0.0.0:6767") .WithImage("registry.gitlab.com/inetmock/inetmock:latest") .WithName("inetmock") diff --git a/tests/INetMock.Client.IntegrationTest/PCAP/Client/PcapApiClientTests.cs b/tests/INetMock.Client.IntegrationTest/PCAP/Client/PcapApiClientTests.cs index bf135d1..4073f7d 100644 --- a/tests/INetMock.Client.IntegrationTest/PCAP/Client/PcapApiClientTests.cs +++ b/tests/INetMock.Client.IntegrationTest/PCAP/Client/PcapApiClientTests.cs @@ -8,8 +8,8 @@ namespace INetMock.Client.IntegrationTest.PCAP.Client; public class PcapApiClientTests : IClassFixture { - private readonly ITestOutputHelper _outputHelper; private readonly IPcapApiClient _apiClient; + private readonly ITestOutputHelper _outputHelper; public PcapApiClientTests(ITestOutputHelper testOutputHelper, INetMockFixture inetMockFixture) { @@ -48,7 +48,7 @@ public class PcapApiClientTests : IClassFixture } var targetPath = $"/tmp/{recordingDevice.Name}_record.pcap"; - await _apiClient.StartPcapFileRecordingAsync(new(recordingDevice.Name, targetPath)); + await _apiClient.StartPcapFileRecordingAsync(new RecordingRequest(recordingDevice.Name, targetPath)); var subscriptions = await _apiClient.ListActiveRecordingsAsync(); Assert.Contains(subscriptions, subscription => diff --git a/tests/INetMock.Client.Test/Audit/Serialization/GenericReaderTest.cs b/tests/INetMock.Client.Test/Audit/Serialization/GenericReaderTest.cs index 80c20f3..a2dbad0 100644 --- a/tests/INetMock.Client.Test/Audit/Serialization/GenericReaderTest.cs +++ b/tests/INetMock.Client.Test/Audit/Serialization/GenericReaderTest.cs @@ -8,11 +8,15 @@ namespace INetMock.Client.Test.Audit.Serialization; public class GenericReaderTest { - private const string HttpEventPayload = "000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; - private const string DnsEventPayload = "0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d"; + private const string HttpEventPayload = + "000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; + + private const string DnsEventPayload = + "0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d"; + + private readonly byte[] _dnsEventPayloadBytes; private readonly byte[] _httpEventPayloadBytes; - private readonly byte[] _dnsEventPayloadBytes; public GenericReaderTest() { diff --git a/tests/INetMock.Client.Test/Audit/Serialization/TypedReaderTest.cs b/tests/INetMock.Client.Test/Audit/Serialization/TypedReaderTest.cs index f638ff3..2ce4ace 100644 --- a/tests/INetMock.Client.Test/Audit/Serialization/TypedReaderTest.cs +++ b/tests/INetMock.Client.Test/Audit/Serialization/TypedReaderTest.cs @@ -8,11 +8,15 @@ namespace INetMock.Client.Test.Audit.Serialization; public class TypedReaderTest { - private const string HttpEventPayload = "000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; - private const string DnsEventPayload = "0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050"; + private const string HttpEventPayload = + "000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; + + private const string DnsEventPayload = + "0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050"; + + private readonly byte[] _dnsEventPayloadBytes; private readonly byte[] _httpEventPayloadBytes; - private readonly byte[] _dnsEventPayloadBytes; public TypedReaderTest() { diff --git a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj index c03c65a..facbef4 100644 --- a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj +++ b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj @@ -8,20 +8,20 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive - + - + -- 2.45.2 From 980414b794155778559ddd51ae0c4acf7481e039 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Fri, 15 Sep 2023 19:40:34 +0200 Subject: [PATCH 17/18] ci: migrate to Drone CI --- .drone.yml | 24 ++++++++++++++++ .gitlab-ci.yml | 61 ----------------------------------------- .nuke/build.schema.json | 9 +++--- INetMock.sln | 1 - build/_build.csproj | 4 +++ 5 files changed, 33 insertions(+), 66 deletions(-) create mode 100644 .drone.yml delete mode 100644 .gitlab-ci.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..57701a7 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,24 @@ +--- +kind: pipeline +type: docker +name: default + +platform: + os: linux + arch: arm64 + +trigger: + branch: + - main + event: + - push + - pull_request + - tag + +steps: + - name: Test + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - dotnet tool restore + - dotnet restore + - dotnet nuke test diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 4de04ea..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,61 +0,0 @@ -image: mcr.microsoft.com/dotnet/sdk:6.0 - -stages: - - test - - release - -variables: - DOCKER_TLS_CERTDIR: "/certs" - DOCKER_CERT_PATH: "/certs/client" - DOCKER_TLS_VERIFY: 1 - DOCKER_HOST: 'tcp://docker:2376' - -test: - stage: test - services: - - docker:dind - before_script: - - | - curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.14.tgz | tar -xzv -C /usr/local/ - - docker run --rm -d \ - --cap-add CAP_NET_RAW \ - --cap-add CAP_NET_ADMIN \ - --cap-add CAP_NET_BIND_SERVICE \ - -u root \ - -p 6767:6767 \ - -e INETMOCK_API_LISTEN=tcp://0.0.0.0:6767 \ - --name inetmock \ - registry.gitlab.com/inetmock/inetmock:latest - - for i in `seq 1 10` - do - docker exec -i inetmock /usr/lib/inetmock/bin/imctl health container 2>&1 > /dev/null || sleep 1; - done; - after_script: - - docker stop inetmock - variables: - PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/docker - INETMOCK_SOCKET: http://docker:6767 - script: - - dotnet tool restore - - dotnet nuke Test - -protobuf-lint: - stage: test - image: - name: docker.io/bufbuild/buf:latest - entrypoint: [ "" ] - script: - - cd api/proto/ - - buf ls-files - - buf lint - -nuget-publish: - stage: release - only: - refs: - - tags - script: - - dotnet tool restore - - dotnet nuke NuGetPush diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 1828fb1..a311343 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Build Schema", "$ref": "#/definitions/build", + "title": "Build Schema", "definitions": { "build": { "type": "object", @@ -29,6 +29,7 @@ "AppVeyor", "AzurePipelines", "Bamboo", + "Bitbucket", "Bitrise", "GitHubActions", "GitLab", @@ -38,8 +39,8 @@ "TeamCity", "Terminal", "TravisCI", - "VisualStudio", - "VSCode" + "VSCode", + "VisualStudio" ] }, "NoLogo": { @@ -116,4 +117,4 @@ } } } -} \ No newline at end of file +} diff --git a/INetMock.sln b/INetMock.sln index 4f156f3..57e7881 100644 --- a/INetMock.sln +++ b/INetMock.sln @@ -7,7 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - .gitlab-ci.yml = .gitlab-ci.yml .pre-commit-config.yaml = .pre-commit-config.yaml README.md = README.md global.json = global.json diff --git a/build/_build.csproj b/build/_build.csproj index 0dbad78..18299d1 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -17,4 +17,8 @@ + + + + -- 2.45.2 From b642b7bc9bb3ab40ee2bfc1bbcfdf8f8ade97de2 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sun, 17 Sep 2023 11:12:17 +0200 Subject: [PATCH 18/18] refactor: use Husky.NET instead of pre-commit --- .config/dotnet-tools.json | 18 +++++-- .editorconfig | 3 +- .husky/pre-commit | 4 ++ .husky/task-runner.json | 34 ++++++++++++ .pre-commit-config.yaml | 13 ----- INetMock.sln | 1 - .../Audit/Client/AuditApiClient.cs | 6 +-- .../Audit/Serialization/GenericReader.cs | 5 +- .../Audit/Serialization/TypedReader.cs | 10 +--- .../INetMockFixture.cs | 5 +- tests/INetMock.Client.Test/Hex/Converter.cs | 6 +-- .../INetMock.Client.Test.csproj | 54 +++++++++---------- 12 files changed, 91 insertions(+), 68 deletions(-) create mode 100755 .husky/pre-commit create mode 100644 .husky/task-runner.json delete mode 100644 .pre-commit-config.yaml diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index cb895fd..e919e28 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,22 +3,34 @@ "isRoot": true, "tools": { "dotnet-grpc": { - "version": "2.46.0", + "version": "2.57.0", "commands": [ "dotnet-grpc" ] }, "nuke.globaltool": { - "version": "6.1.2", + "version": "7.0.5", "commands": [ "nuke" ] }, "gitversion.tool": { - "version": "5.10.3", + "version": "5.12.0", "commands": [ "dotnet-gitversion" ] + }, + "husky": { + "version": "0.6.1", + "commands": [ + "husky" + ] + }, + "jetbrains.resharper.globaltools": { + "version": "2023.2.1", + "commands": [ + "jb" + ] } } } \ No newline at end of file diff --git a/.editorconfig b/.editorconfig index 0202480..7236ae2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,6 +6,7 @@ end_of_line = lf charset = utf-8 insert_final_newline = true max_line_length = 120 +indent_size = 4 [*.xml] indent_size = 4 @@ -18,7 +19,7 @@ dotnet_style_qualification_for_field = false:warning dotnet_style_qualification_for_property = false:warning dotnet_style_qualification_for_method = false:warning dotnet_style_qualification_for_event = false:warning -dotnet_style_require_accessibility_modifiers = never:warning +dotnet_style_require_accessibility_modifiers = omit_if_default:warning csharp_style_expression_bodied_methods = true:silent csharp_style_expression_bodied_properties = true:warning diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..6937b36 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +dotnet husky run --group pre-commit diff --git a/.husky/task-runner.json b/.husky/task-runner.json new file mode 100644 index 0000000..4f173be --- /dev/null +++ b/.husky/task-runner.json @@ -0,0 +1,34 @@ +{ + "tasks": [ + { + "name": "dotnet-format", + "group": "pre-commit", + "command": "dotnet", + "args": [ + "dotnet-format", + "--include", + "${staged}" + ], + "include": [ + "**/*.cs", + "**/*.vb" + ] + }, + { + "name": "Run JB Clean Up Code", + "group": "pre-commit", + "command": "dotnet", + "pathMode": "relative", + "args": [ + "jb", + "cleanupcode", + "INetMock.sln", + "--telemetry-optout" + ], + "include": [ + "**/*.cs", + "**/*.vb" + ] + } + ] +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 9cbe814..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks -repos: - - repo: https://github.com/dotnet/format - rev: "v5.1.225507" # Specify a tag or sha here, or run "pre-commit autoupdate" - hooks: - - id: dotnet-format - args: - - "" - - --folder - - --check - - --verbosity=detailed - - --include diff --git a/INetMock.sln b/INetMock.sln index 57e7881..dca24f4 100644 --- a/INetMock.sln +++ b/INetMock.sln @@ -7,7 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - .pre-commit-config.yaml = .pre-commit-config.yaml README.md = README.md global.json = global.json EndProjectSection diff --git a/src/INetMock.Client/Audit/Client/AuditApiClient.cs b/src/INetMock.Client/Audit/Client/AuditApiClient.cs index 0d5113d..d1ecd62 100644 --- a/src/INetMock.Client/Audit/Client/AuditApiClient.cs +++ b/src/INetMock.Client/Audit/Client/AuditApiClient.cs @@ -48,9 +48,9 @@ public class AuditApiClient : IAuditApiClient public async Task RemoveFileSinkAsync(string targetPath, CancellationToken token = default) { var resp = await _auditClient.RemoveFileSinkAsync(new RemoveFileSinkRequest - { - TargetPath = targetPath - }, + { + TargetPath = targetPath + }, Metadata.Empty, null, token diff --git a/src/INetMock.Client/Audit/Serialization/GenericReader.cs b/src/INetMock.Client/Audit/Serialization/GenericReader.cs index 9682a61..110f0fb 100644 --- a/src/INetMock.Client/Audit/Serialization/GenericReader.cs +++ b/src/INetMock.Client/Audit/Serialization/GenericReader.cs @@ -37,8 +37,5 @@ public sealed class GenericReader : IEventReader public ValueTask DisposeAsync() => _reader.DisposeAsync(); - public void Dispose() - { - _reader.Dispose(); - } + public void Dispose() => _reader.Dispose(); } diff --git a/src/INetMock.Client/Audit/Serialization/TypedReader.cs b/src/INetMock.Client/Audit/Serialization/TypedReader.cs index 70da03d..1a7c080 100644 --- a/src/INetMock.Client/Audit/Serialization/TypedReader.cs +++ b/src/INetMock.Client/Audit/Serialization/TypedReader.cs @@ -76,13 +76,7 @@ public sealed class TypedReader : IEventReader where T : EventDetails, new } while (true); } - public void Dispose() - { - _reader.Dispose(); - } + public void Dispose() => _reader.Dispose(); - public ValueTask DisposeAsync() - { - return _reader.DisposeAsync(); - } + public ValueTask DisposeAsync() => _reader.DisposeAsync(); } diff --git a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs index dee07f7..11c73e4 100644 --- a/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs +++ b/tests/INetMock.Client.IntegrationTest/INetMockFixture.cs @@ -48,8 +48,5 @@ public class INetMockFixture : IAsyncLifetime INetMockSocketPath = $"http://{_inetmockContainer.Hostname}:{_inetmockContainer.GetMappedPublicPort(6767)}"; } - public async Task DisposeAsync() - { - await _inetmockContainer.StopAsync(); - } + public async Task DisposeAsync() => await _inetmockContainer.StopAsync(); } diff --git a/tests/INetMock.Client.Test/Hex/Converter.cs b/tests/INetMock.Client.Test/Hex/Converter.cs index d34abac..cd5d785 100644 --- a/tests/INetMock.Client.Test/Hex/Converter.cs +++ b/tests/INetMock.Client.Test/Hex/Converter.cs @@ -5,11 +5,9 @@ namespace INetMock.Client.Test.Hex; public static class Converter { - public static byte[] HexToByteArray(this string hex) - { - return Enumerable.Range(0, hex.Length) + public static byte[] HexToByteArray(this string hex) => + Enumerable.Range(0, hex.Length) .Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) .ToArray(); - } } diff --git a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj index facbef4..c9c1f6e 100644 --- a/tests/INetMock.Client.Test/INetMock.Client.Test.csproj +++ b/tests/INetMock.Client.Test/INetMock.Client.Test.csproj @@ -1,27 +1,27 @@ - - - - net6.0 - false - latest - enable - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + net6.0 + false + latest + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + \ No newline at end of file -- 2.45.2