From 370bc948d26f2b05ce4c8044bc9cf2f854201d9b Mon Sep 17 00:00:00 2001 From: zpc Date: Tue, 25 Jun 2024 20:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CodeRelease/.editorconfig | 38 +++++++++++++++++++ src/CodeRelease/CodeRelease.sln | 7 +++- .../Controllers/PublishController.cs | 3 -- .../CodeRelease/Model/GiteaWebhook.cs | 4 -- src/CodeRelease/CodeRelease/Program.cs | 2 - .../Utile/GiteaWebhookConfigMiddleware.cs | 6 +-- .../CodeRelease/Utile/ZipExtractor.cs | 4 +- 7 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 src/CodeRelease/.editorconfig diff --git a/src/CodeRelease/.editorconfig b/src/CodeRelease/.editorconfig new file mode 100644 index 0000000..eceed73 --- /dev/null +++ b/src/CodeRelease/.editorconfig @@ -0,0 +1,38 @@ + +root = true + +# 全部文件 +[*] +indent_style = space #指定缩进风格,可以是tab(制表符)或space(空格) + +# Xml files +[*.xml] +indent_size = 2 #定义一个缩进级别的大小。 + +[*.cs] +end_of_line = lf #指定换行符的类型,可以是lf(Unix/Linux)、crlf(Windows)或cr(老式的Mac OS)。 +indent_style = space #指定缩进风格,可以是tab(制表符)或space(空格) +charset = utf-8 #设置文件字符集为utf-8,在 Linux 系统中,通常推荐使用 UTF-8 而不是 UTF-8 with BOM。添加 BOM 可能会干扰那些不期望在文件开头出现非 ASCII 字节的软件对 UTF-8 的使用。 +trim_trailing_whitespace = true #指定是否删除行尾的空白字符。 +insert_final_newline = true #指定文件末尾是否应该插入一个空白行。 +indent_size = 4 +# 模式匹配的偏好设置 +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion # 推荐使用模式匹配而非 is 与类型转换检查 +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion # 推荐使用模式匹配而非 as 与 null 检查 + +# 空检查的偏好设置 +csharp_style_throw_expression = true:suggestion # 推荐使用 throw 表达式 +csharp_style_conditional_delegate_call = true:suggestion # 推荐使用条件委托调用 + +# 修饰符的偏好设置 +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion # 修饰符的推荐顺序 + +# 表达式级别的偏好设置 +csharp_prefer_braces = true:silent # 推荐使用大括号,即使在可能省略的情况下 +csharp_style_deconstructed_variable_declaration = true:suggestion # 推荐使用解构变量声明 +csharp_prefer_simple_default_expression = true:suggestion # 推荐使用简化的默认值表达式 +csharp_style_prefer_local_over_anonymous_function = true:suggestion # 推荐使用本地函数而非匿名函数 +csharp_style_inlined_variable_declaration = true:suggestion # 推荐内联变量声明 +# 首选顶层语句的偏好设置 +csharp_style_prefer_top_level_statements = true:silent # 推荐使用顶层语句,不强制要求 + diff --git a/src/CodeRelease/CodeRelease.sln b/src/CodeRelease/CodeRelease.sln index 29d5533..bd64026 100644 --- a/src/CodeRelease/CodeRelease.sln +++ b/src/CodeRelease/CodeRelease.sln @@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.10.34916.146 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeRelease", "CodeRelease\CodeRelease.csproj", "{C58D2D43-B90B-4CEA-810F-99027F8F865A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeRelease", "CodeRelease\CodeRelease.csproj", "{C58D2D43-B90B-4CEA-810F-99027F8F865A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{74FD82FD-055B-45E9-AE81-0CAFDF083ECB}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/CodeRelease/CodeRelease/Controllers/PublishController.cs b/src/CodeRelease/CodeRelease/Controllers/PublishController.cs index c423398..37bb606 100644 --- a/src/CodeRelease/CodeRelease/Controllers/PublishController.cs +++ b/src/CodeRelease/CodeRelease/Controllers/PublishController.cs @@ -2,15 +2,12 @@ using CodeRelease.Model; using CodeRelease.Utile; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; -using System; - namespace CodeRelease.Controllers diff --git a/src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs b/src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs index 38ff44a..2e247f1 100644 --- a/src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs +++ b/src/CodeRelease/CodeRelease/Model/GiteaWebhook.cs @@ -1,8 +1,4 @@ using Newtonsoft.Json; - -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; namespace CodeRelease.Model { /// diff --git a/src/CodeRelease/CodeRelease/Program.cs b/src/CodeRelease/CodeRelease/Program.cs index 6f26f9d..13bccb3 100644 --- a/src/CodeRelease/CodeRelease/Program.cs +++ b/src/CodeRelease/CodeRelease/Program.cs @@ -1,8 +1,6 @@ using CodeRelease.Model; using CodeRelease.Utile; -using Microsoft.Extensions.Configuration; - var builder = WebApplication.CreateBuilder(args); // Add services to the container. diff --git a/src/CodeRelease/CodeRelease/Utile/GiteaWebhookConfigMiddleware.cs b/src/CodeRelease/CodeRelease/Utile/GiteaWebhookConfigMiddleware.cs index 3c4fc7c..edd7d7f 100644 --- a/src/CodeRelease/CodeRelease/Utile/GiteaWebhookConfigMiddleware.cs +++ b/src/CodeRelease/CodeRelease/Utile/GiteaWebhookConfigMiddleware.cs @@ -1,9 +1,5 @@ using CodeRelease.Model; -using Newtonsoft.Json; - -using static System.Net.Mime.MediaTypeNames; - namespace CodeRelease.Utile { /// @@ -27,7 +23,7 @@ namespace CodeRelease.Utile var key = authorization.ToString(); if (!string.IsNullOrEmpty(key)) { - var tempgiteaWebhookConfig = giteaWebhookConfigModels.FirstOrDefault(it => it.Name == key); + var tempgiteaWebhookConfig = giteaWebhookConfigModels.FirstOrDefault(it => it.Name == key); if (tempgiteaWebhookConfig == null) { if (giteaWebhookConfigModels.Count > 0) diff --git a/src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs b/src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs index bd9eb85..cb23232 100644 --- a/src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs +++ b/src/CodeRelease/CodeRelease/Utile/ZipExtractor.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.IO.Compression; +using System.IO.Compression; namespace CodeRelease.Utile { ///