From 002cf227e449f4f35d4fbc62145859fa1f106d03 Mon Sep 17 00:00:00 2001 From: n0099 Date: Thu, 2 May 2024 08:38:17 +0800 Subject: [PATCH] * add `using Sdcb.PaddleOCR` @ GlobalUsings.cs @ imagePipeline + GlobalUsings.cs * using file scoped namespace @ ByteArrayEqualityComparer.cs @ shared @ c# * fix `NU1004: The project reference tbm.shared has changed` @ c#.yml @ .github/workflows --- .github/workflows/c#.yml | 2 +- c#/imagePipeline/src/GlobalUsings.cs | 1 + c#/imagePipeline/src/Ocr/PaddleOcrProvider.cs | 1 - .../src/Ocr/PaddleOcrRecognizer.cs | 2 -- c#/shared/src/BaseEntryPoint.cs | 4 ---- c#/shared/src/ByteArrayEqualityComparer.cs | 21 +++++++++---------- c#/shared/src/ErrorableWorker.cs | 3 --- c#/shared/src/ExtensionMethods.cs | 2 -- c#/shared/src/GlobalUsings.cs | 6 ++++++ .../src/NpgsqlCamelCaseNameTranslator.cs | 1 - c#/shared/src/TbmDbContext.cs | 4 ---- 11 files changed, 18 insertions(+), 29 deletions(-) create mode 100644 c#/shared/src/GlobalUsings.cs diff --git a/.github/workflows/c#.yml b/.github/workflows/c#.yml index 04e66017..1f77c901 100644 --- a/.github/workflows/c#.yml +++ b/.github/workflows/c#.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/c# - - run: dotnet build --no-restore -c Release ${{ matrix.project }} + - run: dotnet build -c Release ${{ matrix.project }} ReSharper: runs-on: ubuntu-latest diff --git a/c#/imagePipeline/src/GlobalUsings.cs b/c#/imagePipeline/src/GlobalUsings.cs index 2afe376b..e7974209 100644 --- a/c#/imagePipeline/src/GlobalUsings.cs +++ b/c#/imagePipeline/src/GlobalUsings.cs @@ -19,6 +19,7 @@ global using Polly; global using Polly.Extensions.Http; global using Polly.Registry; +global using Sdcb.PaddleOCR; global using SixLabors.ImageSharp; global using SixLabors.ImageSharp.Formats.Bmp; global using SixLabors.ImageSharp.Formats.Gif; diff --git a/c#/imagePipeline/src/Ocr/PaddleOcrProvider.cs b/c#/imagePipeline/src/Ocr/PaddleOcrProvider.cs index 61a47e6a..e340ea74 100644 --- a/c#/imagePipeline/src/Ocr/PaddleOcrProvider.cs +++ b/c#/imagePipeline/src/Ocr/PaddleOcrProvider.cs @@ -1,5 +1,4 @@ using Sdcb.PaddleInference; -using Sdcb.PaddleOCR; using Sdcb.PaddleOCR.Models.Online; using static tbm.ImagePipeline.Ocr.PaddleOcrDetector; diff --git a/c#/imagePipeline/src/Ocr/PaddleOcrRecognizer.cs b/c#/imagePipeline/src/Ocr/PaddleOcrRecognizer.cs index 96b62308..0c7a348f 100644 --- a/c#/imagePipeline/src/Ocr/PaddleOcrRecognizer.cs +++ b/c#/imagePipeline/src/Ocr/PaddleOcrRecognizer.cs @@ -1,5 +1,3 @@ -using Sdcb.PaddleOCR; - namespace tbm.ImagePipeline.Ocr; public class PaddleOcrRecognizer(PaddleOcrAll ocr) diff --git a/c#/shared/src/BaseEntryPoint.cs b/c#/shared/src/BaseEntryPoint.cs index 6b6a3a5f..c8019904 100644 --- a/c#/shared/src/BaseEntryPoint.cs +++ b/c#/shared/src/BaseEntryPoint.cs @@ -1,10 +1,6 @@ -using Autofac; using Autofac.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using NLog; -using NLog.Extensions.Logging; namespace tbm.Shared; diff --git a/c#/shared/src/ByteArrayEqualityComparer.cs b/c#/shared/src/ByteArrayEqualityComparer.cs index 9516c069..67e84874 100644 --- a/c#/shared/src/ByteArrayEqualityComparer.cs +++ b/c#/shared/src/ByteArrayEqualityComparer.cs @@ -1,15 +1,14 @@ -namespace tbm.Shared +namespace tbm.Shared; + +public class ByteArrayEqualityComparer : EqualityComparer { - public class ByteArrayEqualityComparer : EqualityComparer - { - public override bool Equals(byte[]? x, byte[]? y) => - x == y || (x != null && y != null && x.AsSpan().SequenceEqual(y.AsSpan())); + public override bool Equals(byte[]? x, byte[]? y) => + x == y || (x != null && y != null && x.AsSpan().SequenceEqual(y.AsSpan())); - public override int GetHashCode(byte[] obj) - { - var hash = default(HashCode); - hash.AddBytes(obj); - return hash.ToHashCode(); - } + public override int GetHashCode(byte[] obj) + { + var hash = default(HashCode); + hash.AddBytes(obj); + return hash.ToHashCode(); } } diff --git a/c#/shared/src/ErrorableWorker.cs b/c#/shared/src/ErrorableWorker.cs index 82ace6cf..aafb4043 100644 --- a/c#/shared/src/ErrorableWorker.cs +++ b/c#/shared/src/ErrorableWorker.cs @@ -1,6 +1,3 @@ -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - namespace tbm.Shared; #pragma warning disable AV1564 // Parameter in public or internal member is of type bool or bool? diff --git a/c#/shared/src/ExtensionMethods.cs b/c#/shared/src/ExtensionMethods.cs index 16ed8f39..1815cfc9 100644 --- a/c#/shared/src/ExtensionMethods.cs +++ b/c#/shared/src/ExtensionMethods.cs @@ -1,6 +1,4 @@ using System.Reflection; -using Autofac; -using Microsoft.EntityFrameworkCore; namespace tbm.Shared; diff --git a/c#/shared/src/GlobalUsings.cs b/c#/shared/src/GlobalUsings.cs new file mode 100644 index 00000000..b2c62225 --- /dev/null +++ b/c#/shared/src/GlobalUsings.cs @@ -0,0 +1,6 @@ +global using Autofac; +global using Microsoft.EntityFrameworkCore; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Logging; +global using NLog.Extensions.Logging; +global using Npgsql; diff --git a/c#/shared/src/NpgsqlCamelCaseNameTranslator.cs b/c#/shared/src/NpgsqlCamelCaseNameTranslator.cs index b0993e91..77197bdb 100644 --- a/c#/shared/src/NpgsqlCamelCaseNameTranslator.cs +++ b/c#/shared/src/NpgsqlCamelCaseNameTranslator.cs @@ -1,5 +1,4 @@ using System.Globalization; -using Npgsql; namespace tbm.Shared; diff --git a/c#/shared/src/TbmDbContext.cs b/c#/shared/src/TbmDbContext.cs index 9b7cedf2..500f9bf6 100644 --- a/c#/shared/src/TbmDbContext.cs +++ b/c#/shared/src/TbmDbContext.cs @@ -1,13 +1,9 @@ using System.Data; using System.Data.Common; using System.Diagnostics.CodeAnalysis; -using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; -using Npgsql; using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; using LogLevel = Microsoft.Extensions.Logging.LogLevel;