Blog: Code Generation

Use T4 TextTemplatingFilePreprocessor in .NET Standard or PCL libraries

April 25, 2017, Software Development

For my projects NJsonSchema and NSwag I wanted to use T4 templates to programmatically generate code generating code (TextTemplatingFilePreprocessor). Adding the .tt file with its generated C# class works, even if the files are added to a PCL (Portable Class Library) or .NET Standard 1.0 project. The problem is, that the produced code does not compile because the used PCL Profile 259 (same as .NET Standard 1.0) is missing some required classes and reflection methods. To fix the compiler errors, you have to provide the missing types and methods in your assembly. To avoid name collisions with potential client assemblies […] Read more...

Tags: , , , ,

NSwag Tutorial: Generate an Angular 2 TypeScript client from an existing ASP.NET Web API web assembly

October 1, 2016, (updated on February 28, 2017), 6 comments, Software Development

This tutorial shows how to automatically generate an Angular 2 TypeScript client with the NSwag Swagger toolchain. You can use this client in your Angular 2 SPA (single-page application) to consume the web services of an existing Web API project. The metadata for the client generator will be loaded from an existing .NET assembly which contains your Web API controller classes. The NSwag project provides many other TypeScript templates (for targeting other JS frameworks) and also a C# client generator. Introduction video: For ASP.NET Core projects, I recommend to use the middleware to generate the Swagger spec (there are some […] Read more...

Tags: , , , , ,

NSwag Tutorial: Integrate the NSwag toolchain into your ASP.NET Web API project

September 30, 2016, (updated on October 1, 2016), Software Development

This tutorial shows how to integrate NSwag (Swagger toolchain for .NET) so that you can access your Web API actions with the Swagger UI and a generated C# client library. The toolchain can be integrated into the following three types of Web API projects: Global.asax-based Web projects (full .NET Framework) OWIN-based Web projects (full .NET Framework) ASP.NET Core based projects (full .NET Framework or .NET Core) For each project, the integration is a little bit different, but this tutorial will provide links to all supported ways. Just follow the steps. 1. Create and setup a new Web API project First […] Read more...

Tags: , , , , , , ,


  Page 1 of 1