Quantcast
Channel: Josef Ottosson
Browsing all 244 articles
Browse latest View live
↧

JOS.Enumeration - System.Text.Json support

The problem We want to use the same approach as we do when storing the enumeration class in the database, we only want to serialize the actual value of the enumeration. We also want to be able to only...

View Article


JOS.Enumeration - Now using source generators

Lately I've played around a bit with source generators. I wanted to see if I could improve the experience of using my JOS.Enumeration project. "Old" implementation When creating your own Enumeration...

View Article


Image may be NSFW.
Clik here to view.

Using records when implementing the builder pattern in C#

Photo by Vitolda Klein I tend to use the builder pattern quite a bit when writing my tests. It's really convinient to create a builder and have a fluent interface when creating some test data. We'll be...

View Article

Image may be NSFW.
Clik here to view.

My take on the Result class in C#

Photo by Agence Olloweb Introduction Don't use exceptions for flow control! This is a quote I stumbled on quite a bit during my first years as a programmer. Let's imagine the following scenario: We...

View Article

JOS.Enumeration - System.Text.Json support

The problem We want to use the same approach as we do when storing the enumeration class in the database, we only want to serialize the actual value of the enumeration. We also want to be able to only...

View Article


JOS.Enumeration - Now using source generators

Lately I've played around a bit with source generators. I wanted to see if I could improve the experience of using my JOS.Enumeration project. "Old" implementation When creating your own Enumeration...

View Article

Image may be NSFW.
Clik here to view.

Using records when implementing the builder pattern in C#

Photo by Vitolda Klein I tend to use the builder pattern quite a bit when writing my tests. It's really convinient to create a builder and have a fluent interface when creating some test data. We'll be...

View Article

Image may be NSFW.
Clik here to view.

My take on the Result class in C#

Photo by Agence Olloweb Introduction Don't use exceptions for flow control! This is a quote I stumbled on quite a bit during my first years as a programmer. Let's imagine the following scenario: We...

View Article


JOS.Enumeration - System.Text.Json support

The problem We want to use the same approach as we do when storing the enumeration class in the database, we only want to serialize the actual value of the enumeration. We also want to be able to only...

View Article


Image may be NSFW.
Clik here to view.

Using records when implementing the builder pattern in C#

Photo by Vitolda Klein I tend to use the builder pattern quite a bit when writing my tests. It's really convinient to create a builder and have a fluent interface when creating some test data. We'll be...

View Article

JOS.Enumeration - System.Text.Json support

The problem We want to use the same approach as we do when storing the enumeration class in the database, we only want to serialize the actual value of the enumeration. We also want to be able to only...

View Article

JOS.Enumeration - Now using source generators

Lately I've played around a bit with source generators. I wanted to see if I could improve the experience of using my JOS.Enumeration project. "Old" implementation When creating your own Enumeration...

View Article

EF Core - Add a test to ensure that you don't forget to add new migrations

Scenario We want the Hamburger enumeration class to always be up to date in our database. We configure our DbContext like this: public class MyDbContext : DbContext { public DbSet<Hamburger>...

View Article


C# - Tips and Tricks 01 - Covariant return types

The problem We have the following code: public abstract class MessageHandler { public abstract Message Poll(); } public abstract class Message { protected Message(string id, string correlationId,...

View Article

EF Core - Add a test to ensure that you don't forget to add new migrations

Scenario We want the Hamburger enumeration class to always be up to date in our database. We configure our DbContext like this: public class MyDbContext : DbContext { public DbSet<Hamburger>...

View Article


Image may be NSFW.
Clik here to view.

Creating a Roslyn Analyzer to ensure that no duplicate values are added at...

Intro We have the following enumeration class. public partial class Hamburger : IEnumeration<Hamburger> { public static readonly Hamburger Cheeseburger = new (1, "Cheeseburger"); public static...

View Article

C# - Tips and Tricks 01 - Covariant return types

The problem We have the following code: public abstract class MessageHandler { public abstract Message Poll(); } public abstract class Message { protected Message(string id, string correlationId,...

View Article


C# - Tips and Tricks 02 - Named tuples

The problem We have the following code that returns a tuple. public class UserService { public (string, string) GetUser() { var firstName = "Josef"; var country = "Sweden"; return (firstName, country);...

View Article

EF Core - Add a test to ensure that you don't forget to add new migrations

Scenario We want the Hamburger enumeration class to always be up to date in our database. We configure our DbContext like this: public class MyDbContext : DbContext { public DbSet<Hamburger>...

View Article

Image may be NSFW.
Clik here to view.

Creating a Roslyn Analyzer to ensure that no duplicate values are added at...

Intro We have the following enumeration class. public partial class Hamburger : IEnumeration<Hamburger> { public static readonly Hamburger Cheeseburger = new (1, "Cheeseburger"); public static...

View Article
Browsing all 244 articles
Browse latest View live