WckdRzr.CSharpExporter
0.4.0
dotnet add package WckdRzr.CSharpExporter --version 0.4.0
NuGet\Install-Package WckdRzr.CSharpExporter -Version 0.4.0
<PackageReference Include="WckdRzr.CSharpExporter" Version="0.4.0" />
paket add WckdRzr.CSharpExporter --version 0.4.0
#r "nuget: WckdRzr.CSharpExporter, 0.4.0"
// Install WckdRzr.CSharpExporter as a Cake Addin
#addin nuget:?package=WckdRzr.CSharpExporter&version=0.4.0
// Install WckdRzr.CSharpExporter as a Cake Tool
#tool nuget:?package=WckdRzr.CSharpExporter&version=0.4.0
C# Exporter
This is a tool that consumes your C# domain models, types and controllers and exports them for other services and languages to consume. Your C# models are available in TypeScript and your controller endpoints are available to TypeScript and other C# services, removing the need to hard code variable names and urls.
It's built from Jonathan Svenheden's C# models to TypeScript project which makes use of the Roslyn (the .NET compiler platform) to parse the source files, which removes the need to create and maintain our own parser.
Supported Conversions
C# Models and Types | C# Controllers | |
---|---|---|
Export to TypeScript | ✅ | |
Export to Angular | ✅ | ✅ |
Export to Ocelot Config | ✅ | |
Export to C# | ✅ |
Dependencies
Install
Install from NuGet: https://www.nuget.org/packages/WckdRzr.CSharpExporter/
How to use
- Add a config file to your project named
csharp-exporter.config
that contains for example (See/Models/Configuration.cs
for the full config model)...
{
"Models": {
"Include": [
"./Models/**/*.cs",
"./Enums/**/*.cs"
],
"Exclude": [
"./Models/foo/bar.cs"
],
"Output": [{
"Type": "TypeScript",
"Location": "./api.d.ts"
},{
"Type": "CSharp",
"Location": "./ServiceComms/Api.cs"
}],
"CamelCaseEnums": false,
"NumericEnums": true,
"StringLiteralTypesInsteadOfEnums": false
},
"Controllers": {
"Include": [
"./Controllers/**/*.cs",
],
"Exclude": [],
"Output": [{
"Type": "Angular",
"Location": "./service.ts",
"ModelPath": "./api.d"
}],
"Gateway": "api",
"ServiceName": "all"
},
"OnlyWhenAttributed": "FrontEnd",
"CustomTypeTranslations": {
"ProductName": "string",
"ProductNumber": "string"
}
}
Add a NuGet script to your project.
Build. The output files will be created.
License
MIT © Wckd Rzr
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
-
net5.0
- Glob.cs (>= 5.1.766)
- Microsoft.Build.Framework (>= 17.2.0)
- Microsoft.Build.Utilities.Core (>= 17.2.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.4.0 | 372 | 6/14/2022 | |
0.3.0 | 449 | 6/14/2022 | |
0.2.0 | 380 | 6/13/2022 | |
0.1.25 | 362 | 6/13/2022 | |
0.1.24 | 368 | 6/13/2022 | |
0.1.23 | 359 | 6/13/2022 | |
0.1.22 | 359 | 6/13/2022 | |
0.1.21 | 360 | 6/13/2022 | |
0.1.20 | 369 | 6/13/2022 | |
0.1.19 | 357 | 6/13/2022 | |
0.1.18 | 357 | 6/13/2022 | |
0.1.17 | 356 | 6/13/2022 | |
0.1.16 | 364 | 6/10/2022 | |
0.1.15 | 365 | 6/10/2022 | |
0.1.14 | 360 | 6/10/2022 | |
0.1.13 | 299 | 6/9/2022 | |
0.1.12 | 291 | 6/9/2022 | |
0.1.11 | 303 | 6/9/2022 | |
0.1.10 | 294 | 6/9/2022 | |
0.1.9 | 308 | 6/8/2022 | |
0.1.8 | 306 | 6/8/2022 | |
0.1.7 | 309 | 6/8/2022 | |
0.1.6 | 304 | 6/8/2022 | |
0.1.5 | 304 | 6/8/2022 | |
0.1.4 | 300 | 6/7/2022 | |
0.1.3 | 295 | 6/7/2022 | |
0.1.2 | 303 | 6/7/2022 | |
0.1.1 | 305 | 6/7/2022 | |
0.1.0 | 303 | 6/7/2022 |