stream:// .net core


October 19, 2020
  23
This tutorial introduces several architectural and design patterns that can be used to implement common scenarios in .NET desktop and mobile applications.
October 16, 2020
  26
Memory problems in a big .NET application are a silent killer of sorts. Kind of like high blood pressure. You can eat junk food for a long time ignoring it until one day you face a serious problem. In the case of a .NET program, that serious problem can be high memory consumption, major performance issues, and outright crashes. In this post, you'll see how to keep our application's blood pressure at healthy levels.
October 14, 2020
  40
The Null Object Pattern is a pattern that uses objects with null behavior instead of performing null checks throughout the codebase. ILogger and ILoggerFactory are dependencies that often require a lot of null checking, so they are perfect candidates for the null object pattern. Suppose your classes take ILogger or ILoggerFactory as a dependency, and you are not using the null object pattern. In that case, you will probably find that your code is either subject to NullReferenceExceptions, or forcing implementors to supply loggers as arguments. Use the null object pattern to avoid both these problems. This article teaches you how in C#. Null object might be confusing for some people because it seems to imply that the object reference might be null. However, the opposite is true. The object will never be a null reference. Null refers to the behavior of the object - not the reference itself. I think that a better name for the pattern would be Dummy Object Pattern since the objects you will use are shells with no behavior.  Why Use the Null Object Pattern? If you inject dependencies into your classes, you need to validate against null or perform null checking throughout your code. The null conditional operator ?. helps, but it is still very easy to miss one. Every single missed question mark is a bug in the code. The null object pattern gives you a third option of using a dummy object instead. This reduces the number of code paths and therefore decreases the chance of NullReferenceExceptions while still allowing the implementor to instantiate the class without creating an instance of the dependency. In the case of ILogger, it is quite onerous to create an implementation. Simply put, you shouldn't do it. If you want to implement logging, you should use an existing logging library. It becomes even more onerous if the dependency is ILoggerFactory. The implementor needs to pull in external dependencies or create a cascading set of classes that they may have no idea how to implement. It gets much worse when you try to mock ILogger or ILoggerFactory dependencies. Although it is still important to verify that logging gets called. You can read about that here.  The Basics The good news is that the Microsoft.Extensions.Logging.Abstractions namespace comes with null objects right out of the box. All you need to do is use NullLogger.Instance and NullLoggerFactory.Instance as default instances in your constructor. That's it. Your class can now depend on these instances, as though there is a real instance.  This example guarantees that the logger will never be null without forcing the code to supply a logger. The readonly modifier ensures that the instance cannot be set to null after construction. The code does not throw a NullReferenceException: using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System; namespace ConsoleApp { class Program { static void Main(string[] args) { new Example().Print(Hello World!); } } public class Example { readonly ILogger _logger; public Example(ILogger logger = null) { _logger = logger ?? NullLogger.Instance; } public void Print(string message) { _logger.LogTrace(Logged message: {message}, message); Console.WriteLine(message); } } } In some cases, your class should take an ILoggerFactory instance because it may need to pass loggers to child dependencies in the future. You can use the same approach. namespace ConsoleApp { class Program { static void Main(string[] args) { new Example().Print(Hello World!); } } public class Example { readonly ILogger _logger; readonly ILoggerFactory _loggerFactory; public Example(ILoggerFactory loggerFactory = null) { _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; _logger = _loggerFactory.CreateLogger<Example>(); } public void Print(string message) { _logger.LogTrace(Logged message: {message}, message); Console.WriteLine(message); } } } Notice that we use the static property instance of both classes. We could create new instances of these objects in each case, but this would consume extra memory CPU to construct. The static instances only instantiate once i...
October 13, 2020
  37
Sometimes Blazor needs a nudge to render
October 12, 2020
  40
Launching .NET for game development that runs on a wide variety of platform using purpose built gaming engines. Develop games on Windows, Linux, or mcaOS.
October 06, 2020
  56
The post describes JetBrains Rider as an alternate to Visual Studio and how Rider can help mitigate some of the Visual Studio pain-points.
October 05, 2020
  53
I have been a developer for the past 7 years. I’ve gone through a lot of code reviews during that time. I have devoted my time to learn good software engineering practices through C#. Last ye…
October 04, 2020
  63
Microsoft's .NET Core team admits it needs to be better at supporting contributors to its open-source projects.
October 01, 2020
  54
How to use System.IO.Pipelines and System.Threading.Channels APIs to speed up processing
September 29, 2020
  72
C# 8 will ship soon with .Net Core 5, and one of the most exciting features is Source Generators, a great new addition to the .Net ecosystem.

Hot Vacancies

Backend Developer

Oneview Healthcare
.NET Core

Oneview Healthcare is a global company, working with hospitals and senior care facilities around the world.

Senior .NET Developer

.NET Core

We are looking for Senior .Net Developer to join Kiev team. You will be part of a team of strong, result-oriented professionals developing new generation tasks management, people management, learning platform.

C# developer

Wallit SRO
.NET Core

A Hybrid exchange (HEX) is the link that will unite the advantages of a centralized exchange, such as cooperation with large investors and the trust of many users with the advantages of a decentralized exchange. Ping Exchange is a hybrid-decentralized exchange with a specific focus on a user-friendly, trading platform which also provides the ability for peer-to-peer, community barter trades. Trading on the Ping Exchange platform with our broker software is exceptionally fast, once again in line with our global design objectives.

Middle .Net developer

Levi9
.NET Core

We are looking for Middle .Net developer. Our client is a company that serves the terminals around the world!

Backend developer

Healthcare
.NET Core

We are an Irish product company “OneView Healthcare” and we are looking for backend developer!