-
Notifications
You must be signed in to change notification settings - Fork 6
C#: implement C# loader plugin #98
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e224f58
feat: init proj
Kybxd 77863b5
feat: add GitHub Actions workflows for release and testing of C# loader
Kybxd 2609033
fix: format shell scripts
Kybxd 3a0a7ea
fix: make generated code compliant with Unity 2022.3 LTS (C# 9)
wenchy d6eead2
test(csharp): implement ActivityConf logic in Program.cs
wenchy 16c12ea
fix(csharp): add missing using System.Collections.Generic and System.…
wenchy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Release C# | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release cmd/protoc-gen-csharp-tableau-loader | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.event.release.tag_name, 'cmd/protoc-gen-csharp-tableau-loader/') | ||
| strategy: | ||
| matrix: | ||
| goos: [linux, darwin, windows] | ||
| goarch: [amd64, arm64] | ||
| exclude: | ||
| - goos: linux | ||
| goarch: arm64 | ||
| - goos: windows | ||
| goarch: arm64 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: "1.21.x" | ||
|
|
||
| - name: Download dependencies | ||
| run: | | ||
| cd cmd/protoc-gen-csharp-tableau-loader | ||
| go mod download | ||
| - name: Prepare build directory | ||
| run: | | ||
| mkdir -p build/ | ||
| cp README.md build/ | ||
| cp LICENSE build/ | ||
| - name: Build | ||
| env: | ||
| GOOS: ${{ matrix.goos }} | ||
| GOARCH: ${{ matrix.goarch }} | ||
| run: | | ||
| cd cmd/protoc-gen-csharp-tableau-loader | ||
| go build -trimpath -o $GITHUB_WORKSPACE/build | ||
| - name: Create package | ||
| id: package | ||
| run: | | ||
| PACKAGE_NAME=protoc-gen-csharp-tableau-loader.${GITHUB_REF#refs/tags/cmd/protoc-gen-csharp-tableau-loader/}.${{ matrix.goos }}.${{ matrix.goarch }}.tar.gz | ||
| tar -czvf $PACKAGE_NAME -C build . | ||
| echo ::set-output name=name::${PACKAGE_NAME} | ||
| - name: Upload asset | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: ./${{ steps.package.outputs.name }} | ||
| asset_name: ${{ steps.package.outputs.name }} | ||
| asset_content_type: application/gzip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Testing C# | ||
|
|
||
| # Trigger on pushes, PRs (excluding documentation changes), and nightly. | ||
| on: | ||
| push: | ||
| branches: [master, main] | ||
| pull_request: | ||
| schedule: | ||
| - cron: 0 0 * * * # daily at 00:00 | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| gen_script: bash gen.sh | ||
| - os: windows-latest | ||
| gen_script: cmd /c gen.bat | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Install Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: 1.21.x | ||
| cache: true | ||
|
|
||
| - name: Install .NET SDK | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: "8.0.x" | ||
|
|
||
| - name: Install dependencies (Ubuntu) | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y cmake ninja-build | ||
|
|
||
| - name: Install dependencies (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install cmake ninja -y | ||
|
|
||
| - name: Setup MSVC (Windows) | ||
| if: runner.os == 'Windows' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
|
|
||
| - name: Init submodules and build protobuf | ||
| shell: bash | ||
| run: bash init.sh | ||
|
|
||
| - name: Generate protoconf | ||
| working-directory: test/csharp-tableau-loader | ||
| run: ${{ matrix.gen_script }} | ||
|
|
||
| - name: Build | ||
| working-directory: test/csharp-tableau-loader | ||
| run: dotnet build | ||
|
|
||
| - name: Run loader | ||
| working-directory: test/csharp-tableau-loader | ||
| run: dotnet run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,20 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau). | |
|
|
||
| - [Protocol Buffers Go Reference](https://protobuf.dev/reference/go/) | ||
|
|
||
| ## C# | ||
|
|
||
| ### Requirements | ||
|
|
||
| - Unity 2022.3 LTS (C# 9) | ||
| - dotnet-sdk-8.0 | ||
|
|
||
| ### Test | ||
|
|
||
| - Install: **dotnet-sdk-8.0** | ||
| - Change dir: `cd test/csharp-tableau-loader` | ||
| - Generate protoconf: `sh gen.sh` | ||
| - Test: `dotnet run` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the C# code style, which we should obey: |
||
|
|
||
| ## TypeScript | ||
|
|
||
| ### Requirements | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "embed" | ||
| "path" | ||
|
|
||
| "github.com/tableauio/loader/cmd/protoc-gen-csharp-tableau-loader/helper" | ||
| "google.golang.org/protobuf/compiler/protogen" | ||
| ) | ||
|
|
||
| //go:embed embed/* | ||
| var efs embed.FS | ||
|
|
||
| // generateEmbed generates related registry files. | ||
| func generateEmbed(gen *protogen.Plugin) { | ||
| entries, err := efs.ReadDir("embed") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| for _, entry := range entries { | ||
| if entry.IsDir() { | ||
| continue | ||
| } | ||
|
|
||
| g := gen.NewGeneratedFile(entry.Name(), "") | ||
| helper.GenerateFileHeader(gen, nil, g, version) | ||
| // refer: [embed: embed path on different OS cannot open file](https://github.com/golang/go/issues/45230) | ||
| content, err := efs.ReadFile(path.Join("embed", entry.Name())) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| g.P(string(content)) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About C# language version, compiler version, and runtime version:
We should constrain them accurately.