Posts
All the articles I've posted.
-
Running Large Language Models locally – Your own ChatGPT-like AI in C#
For the past few months, a lot of news in tech as well as mainstream media has been around ChatGPT, an Artificial Intelligence (AI) product by the folks at OpenAI. ChatGPT is a Large Language Model (LLM) that is fine-tuned for conversation. While undervaluing the technology with this statement, it’s a smart-looking chat bot that you can ask questions about a variety of domains.
-
Getting rid of warnings with nullable reference types and JSON object models in C#
In my blog series, Nullable reference types in C# - Migrating to nullable reference types, we discussed the benefits of enabling nullable reference types in your C# code, and annotating your code so the compiler and IDE can give you more reliable hints about whether a particular variable or property may need to be checked for being null before using it. We ended the series with a curious case: how to annotate classes to deserialize JSON.
-
Mastodon on your own domain without hosting a server
Like many in the past week, I have been having a serious look at Mastodon as an alternative to Twitter. Mastodon is a social network that is distributed across many servers that have their own smaller communities, and federate with other servers to provide a more “global” social network. There are many servers out there that you can choose from. Alternatively, you can also self-host your Mastodon server, or use one of many hosted instances, “Mastodon as a service”.
-
Rate limiting in web applications - Concepts and approaches
Your web application is running fine, and your users are behaving as expected. Life is good! Is it, though…? Users are probably using your application in ways you did not expect. Crazy usage patterns resulting in more requests than expected, request bursts when users come back to the office after the weekend, and more!
-
ASP.NET Core rate limiting middleware in .NET 7
Rate limiting is a way to control the amount of traffic that a web application or API receives, by limiting the number of requests that can be made in a given period of time. This can help to improve the performance of the site or application, and to prevent it from becoming unresponsive. Starting with .NET 7, ASP.NET Core includes a built-in rate limiting middleware, which can be used to rate limit web applications and APIs. In this blog post, we’ll take a look at how to configure and use the rate limiting middleware in ASP.NET Core.
-
How to test ASP.NET Core Minimal APIs
How do you test that your ASP.NET Core Minimal API behaves as expected? Do you need to deploy your application? Can you write tests with frameworks like xUnit, NUnit, or MSTest? In this post, you will learn the basics of testing ASP.NET Core Minimal APIs. You’ll get started with testing a “hello world” endpoint, and then test a more complex API that returns JSON data. You’ll finish with customizing the ASP.NET Core service collection, so you can customize services for your unit tests and integration tests.
-
Techniques and tools to update your C# project - Migrating to nullable reference types - Part 4
Previously, we saw how you can help the compiler’s flow analysis understand your code, by annotating your code for nullability. In this final post of our series, we’ll have a look at the techniques and tools that are available to migrate to using nullable reference types in an existing code base. In this series: As we have seen in a previous post, it can be an overwhelming experience to go all-in and enable the nullable annotation context for all projects in your solution.
-
Annotating your C# code - Migrating to nullable reference types - Part 3
In the previous post, we looked at some internals of C# nullable reference types, and the nullable annotation context. Today, let’s look at the many options for annotating your code and various ways to help the flow analysis understand your code. As a result, you (and anyone consuming your libraries) will get better and more reliable hints from the IDE and the C# compiler. In this series: So far, we’ve only been annotating our code with ? to inform flow analysis that a reference type can be null when nullable annotations are enabled. This one annotation may not be enough for all scenarios…
-
Internals of C# nullable reference types - Migrating to nullable reference types - Part 2
In the previous post, we saw that with nullable reference types enabled, you get better static flow analysis when working on your code. While nullable reference types don’t give you runtime safety, the design-time and compile-time help is priceless! In this post, we’ll look at some internals of how C# nullable reference types work, and how the C# compiler and IDE use the nullable annotation context. In this series: We’ve already seen there is a difference between nullability for value types and reference types.
-
Nullable reference types in C# - Migrating to nullable reference types - Part 1
The C# nullability features introduced in C#8 help you minimize the likelihood of encountering that dreaded System.NullReferenceException. Nullability syntax and annotations give hints on whether a type can be nullable or not. Better static analysis is available to catch unhandled nulls while developing your code. What’s not to like? Introducing explicit nullability into an existing code base is quite an effort. There’s much more to it than just sprinkling some ? and ! throughout your code. It’s not a silver bullet either: you’ll still need to check non-nullable variables for null.