This is the third article in our C# 9 series. In the previous articles, we covered top-level programs and target-typed expressions and new features for pattern matching. In this article, we’ll look at new features for methods, anonymous functions, and local functions.
Continue reading C# 9 new features for methods and functions
The previous article in our C# 9 series looked at top-level programs and target-typed expressions. In this article, we’ll cover new features for pattern matching. You can find an overview of the syntax offered by previous versions of C# in C# 8 pattern matching.
Continue reading C# 9 pattern matching
.NET 5 (released in November 2020) includes support for C# 9, a major new version of the C# programming language. This series of articles explores the new features in .NET’s main programming language. In this first article, we’ll look at top-level statements and target-typed new and conditional expressions. These features make C# less verbose and can be used in everyday programs.
Continue reading C# 9 top-level programs and target-typed expressions
One of the most important early decisions when building a Linux distribution is the scope of supported hardware. The distribution’s default compiler flags are significant for hardware-platform compatibility. Programs that use newer CPU instructions might not run on older CPUs. In this article, I discuss a new approach to building the x86-64 variant of Red Hat Enterprise Linux (RHEL) 9 and share Red Hat’s recommendation for that build.
Continue reading Building Red Hat Enterprise Linux 9 for the x86-64-v2 microarchitecture level
Have you ever wanted to set up continuous integration (CI) for .NET Core in a cloud-native way, but you didn’t know where to start? This article provides an overview, examples, and suggestions for developers who want to get started setting up a functioning cloud-native CI system for .NET Core.
We will use the new Red Hat OpenShift Pipelines feature to implement .NET Core CI. OpenShift Pipelines are based on the open source Tekton project. OpenShift Pipelines provide a cloud-native way to define a pipeline to build, test, deploy, and roll out your applications in a continuous integration workflow.
In this article, you will learn how to:
- Set up a simple .NET Core application.
- Install OpenShift Pipelines on Red Hat OpenShift.
- Create a simple pipeline manually.
- Create a Source-to-Image (S2I)-based pipeline.
Continue reading “Set up continuous integration for .NET Core with OpenShift Pipelines”
In this article, we’ll look at using OpenAPI with .NET Core. OpenAPI is a specification for describing RESTful APIs. First, I’ll show you how to use OpenAPI to describe the APIs provided by an ASP.NET Core service. Then, we’ll use the API description to generate a strongly-typed client to use the web service with C#.
Writing OpenAPI descriptions
Developers use the OpenAPI specification to describe RESTful APIs. We can then use OpenAPI descriptions to generate a strongly-typed client library that is capable of accessing the APIs.
Note: Swagger is sometimes used synonymously with OpenAPI. It refers to a widely used toolset for working with the OpenAPI specification.
Continue reading “Using OpenAPI with .NET Core”
Well, it finally happened. Despite the added assurances of working with containers and Kubernetes, the old “It works on my machine” scenario reared its ugly head in my .NET Core (C#) code. The image that I created worked fine on my local PC—a Fedora 32 machine—but it crashed when I tried running it in my Red Hat OpenShift cluster.
The error was “Unable to obtain lock file access on /tmp/NuGetScratch.” Let’s take a quick look at what happened, and then I’ll explain how I fixed it.
After a lot of web searching and a discussion with a Red Hat .NET Core engineer, I discovered the underlying problem. It turns out that within a container, the identity used to initially run the program (using the
dotnet run command) must be the same for subsequent users.
The problem might be easy to understand, but what’s the solution?
Continue reading “How to fix .NET Core’s ‘Unable to obtain lock file access’ error on Red Hat OpenShift”
In previous articles, we covered C# 8 asynchronous streams, C# 8 pattern matching, C# 8 default interface methods, and C# 8 nullable reference types. In this final article, we’ll look at
static local functions, indices and ranges, and
Continue reading Some more C# 8
In the previous article, we discussed C# 8 default interface methods. In this article, we’ll look at C# 8 nullable reference types. Reference types refer to an object that is on the heap. When there is no object to refer to, the value is
null is an acceptable value, but often it is an illegal value that leads to
C# 8 finally gives us the ability to express whether a variable shouldn’t be
null, and when it can be
null. Based on these annotations, the compiler will warn you when you are potentially using a
null reference, or passing a
null reference to a function that won’t accept it.
Continue reading “C# 8 nullable reference types”