Skip to content

Commit a35d527

Browse files
authored
Merge pull request #310 from nenoNaninu/update_readme_20251006
update README
2 parents 89cbb4b + 17edb62 commit a35d527

File tree

1 file changed

+64
-10
lines changed

1 file changed

+64
-10
lines changed

README.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TypedSignalR.Client.TypeScript is a library/CLI tool that analyzes SignalR hub a
1111
- [Packages](#packages)
1212
- [Install Using .NET Tool](#install-using-net-tool)
1313
- [Usage](#usage)
14+
- [Transpile the Types Contained in Referenced Assemblies](#transpile-the-types-contained-in-referenced-assemblies)
1415
- [Supported Types](#supported-types)
1516
- [Built-in Supported Types](#built-in-supported-types)
1617
- [User Defined Types](#user-defined-types)
@@ -20,6 +21,8 @@ TypedSignalR.Client.TypeScript is a library/CLI tool that analyzes SignalR hub a
2021
- [MessagePack Hub Protocol Support](#messagepack-hub-protocol-support)
2122
- [Default Configuration in ASP.NET Core](#default-configuration-in-aspnet-core)
2223
- [Recommended Configuration](#recommended-configuration)
24+
- [GitHub Actions Integration](#github-actions-integration)
25+
- [MSBuild Integration](#msbuild-integration)
2326
- [Related Work](#related-work)
2427

2528
## Why TypedSignalR.Client.TypeScript?
@@ -148,7 +151,7 @@ Then, annotate `HubAttribute` and `ReceiverAttribute` to each interface definiti
148151
Also, annotate `TranspilationSourceAttribute` to user-defined types used in the interface definition of Hub and Receiver.
149152
Adding this attribute is relatively easy if you add the [TypedSignalR.Client.TypeScript.Analyzer](#analyzer) to your project.
150153

151-
> Make sure that all your hubs, receivers and models are within a namespace, otherwise the generator will not work.
154+
> Make sure that all your types to be transpiled are within a namespace.
152155
153156
```cs
154157
using Tapper;
@@ -181,15 +184,7 @@ Finally, enter the following command.
181184
This command analyzes C# and generates TypeScript code.
182185

183186
```bash
184-
$ dotnet tsrts --project path/to/Project.csproj --output generated --asm true
185-
```
186-
187-
Or add it to your build steps in your csproj.
188-
189-
```xml
190-
<Target Name="SignalRClient" AfterTargets="PostBuildEvent" Condition=" '$(Configuration)'!='Release'">
191-
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tsrts --project path/to/Project.csproj --output generated --asm true" ContinueOnError="WarnAndContinue" />
192-
</Target>
187+
$ dotnet tsrts --project path/to/Project.csproj --output generated
193188
```
194189

195190
The generated code can be used as follows.
@@ -233,6 +228,14 @@ const participants = await hubProxy.getParticipants()
233228
// ...
234229
```
235230

231+
## Transpile the Types Contained in Referenced Assemblies
232+
233+
By default, only types defined in the project specified by the --project option are targeted for transpiling. By passing the --asm true option, types contained in project/package reference assemblies will also be targeted for transpiling.
234+
235+
```bash
236+
$ dotnet tsrts --project path/to/Project.csproj --output generated -asm true
237+
```
238+
236239
## Supported Types
237240

238241
TypedSignalR.Client.TypeScript uses a library named [nenoNaninu/Tapper](https://github.com/nenoNaninu/Tapper) to convert C# types to TypeScript types.
@@ -429,6 +432,57 @@ If you set up the above configuration, use the following command
429432
$ dotnet tsrts --project path/to/Project.csproj --output generated --serializer MessagePack --naming-style none
430433
```
431434

435+
## GitHub Actions Integration
436+
437+
```yaml
438+
name: typedsignalr-typescript-code-generator
439+
440+
on:
441+
push:
442+
branches: [main]
443+
workflow_dispatch:
444+
445+
env:
446+
DOTNET_VERSION: "9.0.x"
447+
DOTNET_NOLOGO: true
448+
449+
jobs:
450+
typedsignalr-typescript-code-generator:
451+
name: typedsignalr-typescript-code-generator
452+
runs-on: ubuntu-latest
453+
steps:
454+
- uses: actions/checkout@v4
455+
- name: Setup .NET
456+
uses: actions/setup-dotnet@v4
457+
with:
458+
dotnet-version: ${{ env.DOTNET_VERSION }}
459+
460+
- name: Restore dependencies
461+
run: dotnet restore
462+
463+
- name: Build All
464+
run: dotnet build --no-restore
465+
466+
- run: dotnet tool install --global TypedSignalR.Client.TypeScript.Generator
467+
468+
- run: dotnet tsrts --project ./xxx/yyyy/zzz.csproj --output ${{ github.workspace }}/generated
469+
470+
- uses: actions/upload-artifact@v4
471+
with:
472+
name: generated
473+
path: ${{ github.workspace }}/generated
474+
```
475+
476+
## MSBuild Integration
477+
478+
Add it to your build steps in your csproj.
479+
480+
```xml
481+
<Target Name="SignalRClient" AfterTargets="PostBuildEvent" Condition=" '$(Configuration)'!='Release'">
482+
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tsrts --project path/to/Project.csproj --output generated --asm true" ContinueOnError="WarnAndContinue" />
483+
</Target>
484+
```
485+
432486
## Related Work
433487

434488
- [nenoNaninu/TypedSignalR.Client](https://github.com/nenoNaninu/TypedSignalR.Client)

0 commit comments

Comments
 (0)