Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# 対応 #401

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
test:
Expand All @@ -25,6 +26,15 @@ jobs:
- name: Install dependencies
run: pip install .[dev]

# required only if you want to verify C# with SourceExpander
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
6.0.x
- name: Install dependencies (C#)
run: dotnet tool install -g SourceExpander.Console

- name: Run tests
run: |
unset GITHUB_ACTION
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ jobs:
- name: Install dependencies (C#)
run: dotnet tool install --global dotnet-script --version 1.4.0

# required only if you want to verify C# with SourceExpander
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
6.0.x
- name: Install dependencies (C#)
run: dotnet tool install -g SourceExpander.Console

# required only if you want to verify Go code
- name: Install dependencies (Go)
uses: actions/setup-go@v4
Expand Down
24 changes: 23 additions & 1 deletion .verify-helper/docs/static/document.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
|---|---|---|---|---|---|
| C++ | `.cpp` `.hpp` | `.test.cpp` | `#define [KEY] [VALUE]` | :heavy_check_mark: / :heavy_check_mark: / :heavy_check_mark: | [segment_tree.range_sum_query.test.cpp](https://github.com/online-judge-tools/verification-helper/blob/master/examples/segment_tree.range_sum_query.test.cpp) |
| C# script | `.csx` | `.test.csx` | `// verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [segment_tree.range_sum_query.test.csx](https://github.com/online-judge-tools/verification-helper/blob/master/examples/csharpscript/segment_tree.range_sum_query.test.csx) |
| C# | `.cs` | `.test.cs` | `// verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :heavy_check_mark: / :heavy_check_mark: | [segment_tree.range_sum_query.test.csx](https://github.com/online-judge-tools/verification-helper/blob/master/examples/csharpsx/Verifier/segment_tree.range_sum_query.test.csx) |
| Nim | `.nim` | `_test.nim` | `# verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [union_find_tree_yosupo_test.nim](https://github.com/online-judge-tools/verification-helper/blob/master/examples/nim/union_find_tree_yosupo_test.nim) |
| Python 3 | `.py` | `.test.py` | `# verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [union_find_yosupo.test.py](https://github.com/online-judge-tools/verification-helper/blob/master/examples/python/union_find_yosupo.test.py) |
| Haskell | `.hs` | `.test.hs` | `-- verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :warning: | [HelloWorld.test.hs](https://github.com/online-judge-tools/verification-helper/blob/master/Examples2/Haskell/HelloWorld.test.hs) |
Expand Down Expand Up @@ -40,7 +41,28 @@ CXXFLAGS = ["-std=c++17", "-Wall", "-g", "-fsanitize=undefined", "-D_GLIBCXX_DEB
設定項目はありません。
コンパイラには .NET Core が使われます。

- いまのところ `.cs` という拡張子が認識されないことに注意してください ([#248](https://github.com/online-judge-tools/verification-helper/issues/248))。
### C# の設定

[SourceExpander](https://github.com/kzrnm/SourceExpander) を使用して各種機能を実現します。

必須設定
- ライブラリのターゲットに関わらず、.NET 6 以上の SDK をインストールする。
- Library と Test は別のプロジェクトとして作成する。
- Libraryプロジェクトには `SourceExpander.Embedder` を参照に追加する。

具体的な設定は [examples/csharpsx](https://github.com/online-judge-tools/verification-helper/tree/master/examples/csharpsx) を参照。


`.verify-helper/config.toml` というファイルを作って以下のように設定を書くと各種設定ができます。

- static_embedding: `dotnet-source-expand` の `--static-embedding` オプション
- csproj_template: テストファイルのコンパイル時に使われる csproj を指定します。

``` toml
[[languages.csharp]]
static_embedding = "// embed"
csproj_template = ".verify-helper/csproj.template"
```

### Nim の設定

Expand Down
25 changes: 23 additions & 2 deletions .verify-helper/docs/static/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Summary:
|---|---|---|---|---|---|
| C++ | `.cpp` `.hpp` | `.test.cpp` | `#define [KEY] [VALUE]` | :heavy_check_mark: / :heavy_check_mark: / :heavy_check_mark: | [segment_tree.range_sum_query.test.cpp](https://github.com/online-judge-tools/verification-helper/blob/master/examples/segment_tree.range_sum_query.test.cpp) |
| C# script | `.csx` | `.test.csx` | `// verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [segment_tree.range_sum_query.test.csx](https://github.com/online-judge-tools/verification-helper/blob/master/examples/csharpscript/segment_tree.range_sum_query.test.csx) |
| C# | `.cs` | `.test.cs` | `// verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :heavy_check_mark: / :heavy_check_mark: | [segment_tree.range_sum_query.test.csx](https://github.com/online-judge-tools/verification-helper/blob/master/examples/csharpsx/Verifier/segment_tree.range_sum_query.test.csx) |
| Nim | `.nim` | `_test.nim` | `# verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [union_find_tree_yosupo_test.nim](https://github.com/online-judge-tools/verification-helper/blob/master/examples/nim/union_find_tree_yosupo_test.nim) |
| Python 3 | `.py` | `.test.py` | `# verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :heavy_check_mark: | [union_find_yosupo.test.py](https://github.com/online-judge-tools/verification-helper/blob/master/examples/python/union_find_yosupo.test.py) |
| Haskell | `.hs` | `.test.hs` | `-- verification-helper: [KEY] [VALUE]` | :heavy_check_mark: / :x: / :warning: | [HelloWorld.test.hs](https://github.com/online-judge-tools/verification-helper/blob/master/Examples2/Haskell/HelloWorld.test.hs) |
Expand All @@ -35,12 +36,32 @@ CXXFLAGS = ["-std=c++17", "-Wall", "-g", "-fsanitize=undefined", "-D_GLIBCXX_DEB
- If you use environments which [`ulimit`](https://linux.die.net/man/3/ulimit) doesn't work on, and if you want to set `CXXFLAGS` by yourself, please be careful about the stack size.
- The supported extensions are `.cpp`, `.hpp`, `.cc`, and `.h`. Please note that files with other extensions like `.c` `.h++` and files without extensions are not recognized.

### Settings for C#
### Settings for C# script

There is no config now.
.NET Core is used as the compiler.

- Note that currently the `.cs` extension is not recognized ([#248](https://github.com/online-judge-tools/verification-helper/issues/248)).
### Settings for C#

`oj-verify` and `oj-bundle` work with [SourceExpander](https://github.com/kzrnm/SourceExpander).

Requied settings
- Install .NET 6 or newer SDK regardless of target framework of library.
- Create Library project and Test project as different projects.
- Add `SourceExpander.Embedder` reference to Library project.

For the details refer to [examples/csharpsx](https://github.com/online-judge-tools/verification-helper/tree/master/examples/csharpsx).

You can specify compilers and options with writing `.verify-helper/config.toml` as below.

- static_embedding: `dotnet-source-expand` with `--static-embedding` option.
- csproj_template: test file will be compiled with this csproj file.

``` toml
[[languages.csharp]]
static_embedding = "// embed"
csproj_template = ".verify-helper/csproj.template"
```

### Settings for Nim

Expand Down
5 changes: 5 additions & 0 deletions examples/csharpsx/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.cs]

# IDE1006: �����X�^�C��
dotnet_diagnostic.IDE1006.severity = silent
dotnet_diagnostic.IDE0044.severity = silent
Loading