Teemablogi sissekanded


New expression bodied members in C# 7.0

Although expression bodied members have been supported in C# few years there were still room for some new ones. C# 7. 0 introduces expression bodied constructors, destructors, getters and setters. This blog post goes through all these new expression bodied members and shows how to use them. Also a little peek behind the compilator curtains is made. 10:16 23.01.2018 kanalilt DT blogi 2


Internals of tuple literals

My last post about tuple literals gave brief introduction to these. This post goes to internals of tuple literals, peeks behind the compiler and shows what happens with tuple literals internally. This post is for developers who are new to tuple literals and want to gain more deep understanding of these. Tuple literals after compiling Let’s write a simple piece of code, compile it and then decompile it without PDB-file available. 09:54 22.01.2018 kanalilt DT blogi 2


Refactoring: Improving the Design of Existing Code

Although I bought refactoring book by Martin Fowler years ago it is still valid. I call it one of the timeless books about coding and I consider it as a mandatory reading specially for novice programmers who are entering the field. Of course it is also useful handbook for those already in business. 21:02 12.01.2018 kanalilt DT blogi 2


Performance of compiled queries in Entity Framework Core 2.

Before applying any optimizations to our code we have to ask one question: what is the cost of improvement and is it really improvement? Compiled queries in Entity Framework 2. 0 are categorized as high-availability feature but before making any decisions we need to know what is the actual win. This blog post introduces the measurements I made with simple database context to compare compiled and uncompiled queries in Entity Framework Core 2. 10:02 10.01.2018 kanalilt DT blogi 2


Compiled queries in Entity Framework Core

Entity Framework Core 2. 0 introduces explicitly compiled queries. These are LINQ queries that are compiled in advance to be ready for execution as soon as application asks for data. This blog post demonstrates how compiled queries work and how to use them. How queries are executed? Suppose we have database context class with method to return category by id. 10:39 09.01.2018 kanalilt DT blogi 2


Writing IL code on Visual Studio

Microsoft Intermedia Language (MSIL) is . NET assembly language that is standardized under name Common Intermediate Language (CIL). All . NET compilers turn source code to this language. Although we hardly have a situation where we have to write intermedia language (IL) code directly it is still good to know how it works and how it is supported on Visual Studio. This blog post fills the gap and shows how to write IL code on Visual Studio. 10:02 08.01.2018 kanalilt DT blogi 2


Real-time talk between Windows 10 IoT Core background task and ASP.

My previous blog post introduced how to make ASP. NET Core 2 web application run on Windows 10 IoT Core. It was default web application created on Visual Studio and published as an executable. But this is not enough for IoT scenarios. When we build web application that runs on IoT board we need this application to do something. Be it displaying sensor data or controlling some hardware. 10:28 02.01.2018 kanalilt DT blogi 2


How to avoid overlapping timer calls?

Timers are useful . NET feature. With timers we can execute code with specified interval. With real scenarios we can easily face situations where timer calls its callback again but previous call is not finished yet. It may end up with loading some external system too much. It may also end up by making unexpected parallel data processing that distorts the results. This post introduces some options to avoid overlapping timer calls. 10:12 18.12.2017 kanalilt DT blogi 2


Are lock and Monitor the same in C#?

Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock. 10:37 15.12.2017 kanalilt DT blogi 2


Who messed up Visual Studio tab indent level?

After one of latest Visual Studio 2017 I noticed that tab length is incorrect in C# editor. I went through options and confirmed that tab size for C# was set to four spaces. But still for some reason editor used two as tab size. There have been some small changes how Visual Studio 2017 prioritizes settings and here is how to solve the mess. New kid on the block – . editorconfig file As it turns out there is something called . editorconfig file and from now on it overrides what is set in options dialog. 09:07 12.12.2017 kanalilt DT blogi 2


Running ASP. NET Core 2 applications on Windows 10 IoT Core.

It has been problematic to run ASP. NET Core applications on Windows 10 IoT Core as it is not officially supported scenario yet and many components we are used with are not built with Windows 10 ARM in mind. Still it easy to run web applications on Windows 10 IoT Core using ASP. NET Core 2. There are few tricks developers should know when building web applications for Windows 10 IoT Core. This blog post is short guide about ASP. 10:05 11.12.2017 kanalilt DT blogi 2


Boosting performance of Asus RT-N66U

Over time my home network has grown and years are changed also the habits of consuming media at home. When I bought Asus RT-N66U some years ago it was well performing home router. Now came the point when continuing the old way was not an option anymore as things were degraded a lot. Performance boost was needed and here is what I did to get my veteran router back on track. Asus RT-N66U home router. 05:50 08.12.2017 kanalilt DT blogi 2


Deep dive to async Main

C# 7. 1 introduces asynchronous Main method for console applications. It helps us to get rid of some ugly code to await for asynchronous methods. If Main method of console applications is application flow controller that makes multiple calls to asynchronous methods then async Main leads us to much cleaner code. This blog post is my deep dive to async Main. Suppose we have console application built on . NET Core 2. 0. 10:15 06.12.2017 kanalilt DT blogi 2


Recognizing printed text on images using Azure Computer Vision API

Microsoft Azure Cognitive Services offer us computer vision services to describe images and to detect printed or handwritten text. Text recognition provides interesting scenarios like cloud based OCR or providing automated translations for texts on images. This blog post focuses on recognizing printed text using Azure Computer Vision API. Source alert! Sample solution built on ASP. 12:30 08.11.2017 kanalilt DT blogi 2


Running ASP. NET Core applications on Windows Subsystem for Linux.

Windows 10 has something called Windows Subsystem for Linux and this something enables us to run Linux applications on Windows 10 using Linux without need for Hyper-V or other virtual machines. When building multi-platform applications like my open-source TemperatureStation solution then having Linux right there for testing comes very handy. This blog post shows how to get Linux running on Windows, how to install. 11:01 03.11.2017 kanalilt DT blogi 2


Server-side charts with ASP. NET Core, Node services and D3.

ASP. NET Core introduces Node services that allow applications to run Node scripts on server. We can send data from controller action to Node script and get back some output we can use in view. This blog post shows how to use Node services to render d3. js charts on server-side to PNG files. Why Node services Node has tons of modules available and ready for use. Before Node services there were no good way in ASP. 09:49 25.10.2017 kanalilt DT blogi 2


NotSupportedException: No data is available for encoding 1252

Another day, another surprise on . NET Core. Tried to load a file with Windows-1252 encoding and got the following exception: NotSupportedException: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding. RegisterProvider method. Here’s how to solve the problem. 08:22 05.10.2017 kanalilt DT blogi 2


ASP. NET Core and IIS: 502. 5 Process Failure 0x80004005 : 80008083.

When running ASP. NET Core on IIS one may get weird error Application ‘<IIS PATH>’ with physical root ‘<PATH TO APPLICATION>’ failed to start process with commandline ‘”dotnet” . \MyApp. dll’, ErrorCode = ‘0x80004005 : 80008083. Here is one and most probable solution for this issue. It usually comes down to fact that runtime needed for web application is not available on server. 09:24 29.09.2017 kanalilt DT blogi 2


Defensive database context for multi-tenant ASP. NET Core applications.

In multi-tenant applications where tenants share same data store cross-tenant operations must be avoided. There are many ways how bugs like this can happen. Be it hard to debug threading issue or some other complex situation, it is better when application components are ready for this kind of situations and better fail instead of going to glory end with illegal operations. 09:40 04.09.2017 kanalilt DT blogi 2


Unit testing multi-tenant database provider

My saga on supporting multiple tenants in ASP. NET Core web applications has come to point where tenants can use separate databases. It’s time now to write some tests for data context to make sure it behaves correct in unexpected situations. This post covers unit tests for data context and multi-tenancy. My previous work on multi-tenancy To get better understanding of my previous work on multi-tenancy in ASP. 10:36 29.08.2017 kanalilt DT blogi 2