Skip to main content

Posts

Azure DevOps Server–Move collections–Detach/Attach

One of the basic building blocks of Azure DevOps Server is a “Project collection”. The documentation describes it like this: The primary organizational unit for all data in Azure DevOps Server. Collections determine the resources available to the projects added to them.   From a technical standpoint, a project collection is a separate database. It is possible to move project collection between different database instances but be aware that just backing up a collection on one database server and restoring it on another database server is not sufficient. Instead you should do this through a detach/attach operation: Detach a collection Before you move a collection, you need to detach it. You can do this from the Azure DevOps Administration console: When detaching, all jobs and services are stopped, and then the collection database is stopped. In addition, the detach process copies over the collection-specific data from the configuration database and saves it as pa...

C# 9–Use Record types in .NET Standard 2.0

I created a small Record type in C#: However the compiler didn’t like it: Why? Because I was adding this code to a .NET Standard 2.0 library that doesn’t support C# 9 features. As a reminder, a small overview: Target framework Version C# Language Version .NET 5 C# 9.0 .NET Core 3.x C# 8.0 .NET Core 2.x C# 7.3 .NET Standard 2.1 C# 8.0 .NET Standard 2.0 C# 7.3 I didn’t want to upgrade to .NET 5 so what are my options? Turns out, that you can work around this with a small compiler hack… Let’s try it: First you need to override the language version in the csproj file: Then you should add the following code to get rid of the compiler error:

Combining Autofac and Microsoft DI in unit tests

I had to write a test where I need to inject a configuration dependency through IOptions<> .  So far I had been using Autofac in my tests, so I wouldn’t go through all the trouble to get IOptions<> working inside Autofac (especially when Microsoft DI offers the convenient AddOptions<> and Configure<> methods). Luckily it is not that hard to bring the 2 DI containers together. Here is the code I used inside my tests:

C# 9–Module Initializer

Yesterday I blogged about an issue I had with Telerik . I needed to initialize some code before I could call the PDF conversion functionality: The question is where should I put this logic? Perfect case to try out a new C# 9 feature: Module initializers . Module initializers allow you to do eager, one-time initialization when a module is loaded, with minimal overhead and without the user needing to explicitly call anything. Creating a module initializer is easy. Just add the ModuleInitializerAttribute on top of a method. Some requirements are imposed on the method targeted with this attribute: The method must be static . The method must be parameterless. The method must return void . The method must not be generic or be contained in a generic type. The method must be accessible from the containing module.

Telerik Document Processing–InvalidOperationException

When trying to convert a Word document to PDF through the Telerik Document Processing libraries I got the error message below when I tried to convert a Word document containing a high-res image: System.InvalidOperationException   HResult=0x80131509   Message=FixedExtensibilityManager.JpegImageConverter cannot be null. The .NET Standard does not define APIs for converting images or scaling their quality. In order to export images different than Jpeg and Jpeg2000 or ImageQuality different than High you will need to reference the Telerik.Documents.ImageUtils assembly/NuGet in your project and to set its basic implementation to the FixedExtensibilityManager.JpegImageConverter property or to create a custom one inheriting the JpegImageConverterBase class. For more information go to: https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform   Source=Telerik.Documents.Fixed   StackTrace:    at Telerik...

HotChocolate– GraphQL Schema Stitching Introduction

If you are new to GraphQL Schema Stitching, I can recommend the On.NET show with Michael Staib, one of the creators of Hot Chocolate . With Schema stitching, developers can create a unified GraphQL schema from multiple underlying GraphQL APIs. This gives us the benefit of reducing multiple data queries for our data in a single request from one schema. In this episode, Jeremy chats with the author of Hot Chocolate, Michael Staib, about how .NET developers can implement GraphQL schema stitching with Hot Chocolate.

ASP.NET Core–Performance tip

Question: What is wrong with the following ASP.NET Core controller: No idea? Take a look at the return type... Returning IEnumerable from an action results in synchronous collection iteration by the serializer. The result is the blocking of calls and a potential for thread pool starvation. One possible way to avoid this is by explicitly invoking ToListAsync before returning the result: Starting from ASP.NET Core 3.0 you can also use   IAsyncEnumerable<T> . This no longer results in synchronous iteration and is as efficient as returning IEnumerable<T> . Let’s rewrite the example above to use IAsyncEnumerable<T> : REMARK: If we take a look at the original example again, it will not be an issue in ASP.NET Core 3.0 or higher. Why? Because we allow the framework to choose how to handle the IQueryable<T> we get back from the Where() clause. In the situation we are using ASP.NET Core 3.0 or higher the results will be buffered and correctly pro...