WckdRzr.CSharpExporter
0.1.4
dotnet add package WckdRzr.CSharpExporter --version 0.1.4
NuGet\Install-Package WckdRzr.CSharpExporter -Version 0.1.4
<PackageReference Include="WckdRzr.CSharpExporter" Version="0.1.4" />
paket add WckdRzr.CSharpExporter --version 0.1.4
#r "nuget: WckdRzr.CSharpExporter, 0.1.4"
// Install WckdRzr.CSharpExporter as a Cake Addin
#addin nuget:?package=WckdRzr.CSharpExporter&version=0.1.4
// Install WckdRzr.CSharpExporter as a Cake Tool
#tool nuget:?package=WckdRzr.CSharpExporter&version=0.1.4
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
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Glob.cs (>= 5.1.766)
- Microsoft.Build.Framework (>= 17.2.0)
- Microsoft.Build.Utilities.Core (>= 17.2.0)
- Microsoft.CodeAnalysis (>= 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 |
---|