Skip to content

Commit 27441b1

Browse files
authored
Feature/dotnet format ci (#46)
* switch to dotnet format * format
1 parent 7b86fc7 commit 27441b1

7 files changed

Lines changed: 52 additions & 32 deletions

File tree

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ indent_size = 2
3737
[*{_AssemblyInfo.cs,.notsupported.cs,*/obj/*/External/**/*,*/obj/dotnet-new.IntegrationTests/*/TemplatePackagesPaths.cs}]
3838
generated_code = true
3939

40+
# Thrift generated code
41+
[src/Apache.IoTDB/Rpc/Generated/**]
42+
generated_code = true
43+
4044
# C# files
4145
[*.cs]
4246
# New line preferences

.github/workflows/pre-commit-format.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ on:
77
- "**"
88
merge_group:
99
branches: [main]
10-
# schedule:
11-
# - cron: "0 0 * * *"
1210

1311
concurrency:
1412
group: ${{ github.workflow }}-${{ github.ref }}
1513
cancel-in-progress: true
1614

1715
jobs:
18-
formatting-checks:
16+
dotnet-format:
1917
runs-on: ubuntu-22.04
2018
env:
2119
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
@@ -29,27 +27,9 @@ jobs:
2927
with:
3028
dotnet-version: "9.0.x"
3129

32-
- name: Setup Python environment (for pre-commit)
33-
uses: actions/setup-python@v5
34-
with:
35-
python-version: "3.10"
36-
37-
- name: Clean dotnet temporary folder
38-
run: |
39-
sudo rm -rf /tmp/.dotnet
40-
mkdir -p ${{ runner.temp }}/dotnet-home
41-
mkdir -p ${{ runner.temp }}/xdg-runtime
42-
43-
- name: Install pre-commit and dependencies
44-
run: |
45-
pip install pre-commit
46-
pre-commit install-hooks
30+
- name: Restore dependencies
31+
run: dotnet restore
4732

48-
- name: Run pre-commit checks
49-
env:
50-
TMPDIR: ${{ runner.temp }}
51-
DOTNET_CLI_HOME: ${{ runner.temp }}/dotnet-home
52-
XDG_RUNTIME_DIR: ${{ runner.temp }}/xdg-runtime
53-
NUGET_PACKAGES: ${{ runner. temp }}/nuget-packages
33+
- name: Check formatting
5434
run: |
55-
pre-commit run --all-files
35+
dotnet format --verify-no-changes --verbosity diagnostic

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,23 @@ NLog >= 4.7.9
8282
* dotnet CLI
8383
* Thrift
8484

85+
## Code Formatting
86+
87+
This project uses `dotnet format` to enforce consistent code style based on the [.editorconfig](.editorconfig) rules.
88+
89+
### Check formatting locally
90+
91+
```bash
92+
dotnet format --verify-no-changes
93+
```
94+
95+
### Auto-fix formatting issues
96+
97+
```bash
98+
dotnet format
99+
```
100+
101+
The CI pipeline will automatically check code formatting on all pull requests. Please ensure your code is properly formatted before submitting a PR.
102+
85103
## Publish your own client on nuget.org
86104
You can find out how to publish from this [doc](./PUBLISH.md).

README_ZH.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,23 @@ NLog >= 4.7.9
8181
* dotnet CLI
8282
* Thrift
8383

84+
## 代码格式化
85+
86+
本项目使用 `dotnet format` 基于 [.editorconfig](.editorconfig) 规则来强制执行一致的代码风格。
87+
88+
### 本地检查格式
89+
90+
```bash
91+
dotnet format --verify-no-changes
92+
```
93+
94+
### 自动修复格式问题
95+
96+
```bash
97+
dotnet format
98+
```
99+
100+
CI 流水线会在所有 Pull Request 上自动检查代码格式。请确保在提交 PR 之前代码格式正确。
101+
84102
## 在 nuget.org 上发布你自己的客户端
85103
你可以在这个[文档](./PUBLISH.md)中找到如何发布

src/Apache.IoTDB/PoolHealthMetrics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void ResetAllCounters()
4646
}
4747

4848
public int GetReconnectionFailureTally() => Volatile.Read(ref _reconnectionFailureTally);
49-
49+
5050
public int GetConfiguredMaxSize() => _configuredMaxSize;
5151
}
5252
}

src/Apache.IoTDB/Rpc/TSStatusCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,4 @@ public static string ToString(TSStatusCode statusCode)
285285
}
286286
}
287287

288-
}
288+
}

src/Apache.IoTDB/SessionPool.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
using System.Collections.Generic;
2222
using System.IO;
2323
using System.Linq;
24+
using System.Security.Cryptography.X509Certificates;
2425
using System.Threading;
2526
using System.Threading.Tasks;
26-
using System.Security.Cryptography.X509Certificates;
2727
using Apache.IoTDB.DataStructure;
2828
using Microsoft.Extensions.Logging;
2929
using Thrift;
@@ -64,19 +64,19 @@ public partial class SessionPool : IDisposable, IPoolDiagnosticReporter
6464
private ConcurrentClientQueue _clients;
6565
private ILogger _logger;
6666
private PoolHealthMetrics _healthMetrics;
67-
67+
6868
public delegate Task<TResult> AsyncOperation<TResult>(Client client);
69-
69+
7070
/// <summary>
7171
/// Retrieves current count of idle clients ready for operations.
7272
/// </summary>
7373
public int AvailableClients => _clients?.ClientQueue.Count ?? 0;
74-
74+
7575
/// <summary>
7676
/// Retrieves the configured maximum capacity of the session pool.
7777
/// </summary>
7878
public int TotalPoolSize => _healthMetrics?.GetConfiguredMaxSize() ?? _poolSize;
79-
79+
8080
/// <summary>
8181
/// Retrieves cumulative tally of reconnection failures since pool was opened.
8282
/// </summary>

0 commit comments

Comments
 (0)