When XUnit run a test method, it’s going to create a new object of our test class for each and everyone of our test method. This can create a problem when the creation of the object is expensive and slow our tests down. But there’s a solution to it, we can use IClassFixture to share …
.Net
.NET is a large collection of a bunch of different things really; including compilers, runtimes, programming languages and a bunch of different tools and technologies.
It provides a lot of common functionality that can be tapped into rather than recreating it from scratch.
C# is one language that can be used on .NET. It get compiled initially by Roslyn and can get additional compilation at runtime by RyuJIT. Other languages include F#, which can all be compiled and run against its runtimes.
This works because it’s generally not compiled to a particularly low level language but rather to an Intermediate Language that can be executed by a .NET runtime. The runtime then does the appropriate translations to actual system/hardware calls allowing you to not have to worry about it.
When you create at least C# projects, you have to specify what runtime you’re targeting so that it can be compiled appropriately to work; not just whether it’s Framework or Core, but also the version number since functionality of the same thing may be different.
One of the goals with .NET 5+ is to reduce the confusion by bringing many of the parts together under one umbrella, but it’s going to be a while before that replaced enough existing software to really get rid of the confusion (especially since .NET 5 isn’t going to have Long Term Support).
Asynchronous Programming Series
Recently I wrote a series of posts regarding asynchronous programming. You can find the links to this series down below. In these series of posts I started from the definition of concurrency and how it’s different with parallelism. Then I moved on deeper into the subject by each post. My 10th post in this series …
Thread Safety
There a lot of things that can go wrong in our code. But when we introduce concurrency or parallelism in our code, we potentially could experience different set of bugs. These are race conditions, deadlocks and data corruption to name a few. This happens because there might be a share piece of data between different …
Dependency Injection: Conditional Resolving of Multiple Implementation of Interface
Sometimes we need to resolve a dependency but not with one implementation, but with multiple. There are couple of scenarios that calls for conditional resolving of types. Such as when using a generic class and methods with a dependency on another class. Now imagine the aforementioned class is an abstract one, and we need to …
What Is SynchronizationContext
SynchronizationContext is one of those topics that deserves a better understanding if we want to fully know how asynchorony works in .Net. It’s true that most of these concerns handled behind the scene. But we can benefit by understanding what exactly happens when we offload a task to a worker thread or release the thread …
Exception Handling In Asynchronous Code
It is important to know how exceptions are handled in an asynchronous program. Partly because these subtle points can sometime become a headache. When exception are thrown in a code that runs inside a task, all the exceptions are placed on the task object and returned to the calling thread. When exceptions happen, all the …
NDepend 2018 Review: A Flexible Static Analyzer
NDepend is an static analyzer which can provide various useful information about the quality of the code base. With its built in rules, it calculates how much technical debt the project is in, and estimate how many hours it takes to pay them. For the first time users, the UI might be a little overwhelming, …
Task.Run Vs TaskCompletionSource Vs Task.Factory.FromAsync
There’s a lot of small intricate details that one can miss when we deal asynchronous programs. Even though these days far more superior APIs exist that make things a lot easier. For example a lot of people think if we want to call any synchronous code asynchronously, we just simply wrap it in Task.Run. It’s …
Build UI Tree With Recursive Asp.Net Core View Component
Previous version of Asp.Net MVC had the concept of local view helpers that could contain HTML too. You see an example of this here. But this feature is removed in Asp.Net Core, but we have a better tool to do it. There might be a lot of other replacement solution for using @helper, but in …
How Functional Programming Helps With Asynchronous And Parallel Code
There is a lot of scenarios that a functional code can introduce benefits. But asynchronous and parallel programming is one of those that fit with functional programming perfectly. I’m going use one example of this in particular. That is when we write asynchronous or parallel code, we need to consciously think about how we access …