Rico Suter's blog.
 

Articles

Automatically migrate your Entity Framework Core managed database on ASP.NET Core application start

If you use Entity Framework Core with migrations in your ASP.NET Core application and want to ensure that the database structure always matches the currently running application, you can simply migrate the database on application startup. This way you just have to redeploy your application and everything like migrating the data, change the schemas, etc. is done when the application is restarted.
Read More ›

Advanced Newtonsoft.Json: Dynamically rename or ignore properties without changing the serialized class

This article describes how to implement a custom contract resolver, so that you can ignore or rename serialized JSON properties where the serialization happens and without changing the serialized classes.
Read More ›

NSwag Tutorial: Implement a custom operation processor to define ReDoc code samples

With NSwag you can implement custom operation processors and apply them to ASP.NET Core MVC or Web API controller operations. These processors then get picked up by NSwag and are applied to the given operation in the Swagger specification.
Read More ›

How to instantiate a generic type in TypeScript

This article shows how to instantiate a generic type in TypeScript.
Read More ›

Use T4 TextTemplatingFilePreprocessor in .NET Standard or PCL libraries

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 you need to declare all these extensions as internal and as a consequence the generated class too (this may be a deal-breaker).
Read More ›

Aurelia JS: Detect dirty checked properties during development

I am currently working on new single-page web application based on the Aurelia framework. To avoid performance problems, we want to completely avoid dirty checked properties and method calls. Bindings are dirty checked whenever the framework cannot use another mechanismn than regularly polling for changes. It is important to detect dirty checked properties as early as possible so that they can direcly be avoided and not too many depenencies have to be changed.
Read More ›

Implement custom MSBuild tasks and distribute them via NuGet

In this article describes how to implement MSBuild tasks with inline C# or in an external .NET assembly. After doing so, we will bundle these tasks in a NuGet package, so that they can easily be distributed and updated via NuGet and executed as part of the MSBuild compilation process. This is a powerfull technique to share and manage MSBuild tasks (e.g. build scripts, code generators, etc.) in bigger environments (enterprises, open-source libraries, common/shared tasks).
Read More ›

Aurelia JS: Implement a dialog service which renders Bootstrap UI dialogs

I’m currently working on an SPA (single-page application) which uses the Aurelia JavaScript client framework and Bootstrap UI CSS framework. In the application I need to show various custom dialogs. This is why I implemented a reusable dialog service class which simplifies the creation of Bootstrap based dialogs. In this article I’d like to share and explain the code of this dialog service and the required helper classes. The sample code is written in TypeScript but it can easily be converted to ES6 JavaScript.
Read More ›

.NET Core: Missing mscorlib after installing a Portable Class Library (PCL) or .NET Standard library

.NET Core projects can reference Portable Class Libraries if one of the .NET Standard compliant profiles is used (e.g. the profile 259).
Read More ›

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

This tutorial shows how to generate an Angular 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.
Read More ›