Warnings are too easy to ignore. Consider treating all warnings as errors by setting the TreatWarningsAsErrors property to true in … Continue reading How to treat all warnings as compile errors in .NET
Share settings across multiple projects using a Directory.Build.props file
To set properties for every project in a directory in a centralized location create a Directory.Build.props file in your solution … Continue reading Share settings across multiple projects using a Directory.Build.props file
Use Target Typed New Expressions to infer type on the right in C# 9 +
In C# 9 Target Typed New Expressions were introduced. They allow us to infer type on the right, whereas var … Continue reading Use Target Typed New Expressions to infer type on the right in C# 9 +
Poll Results : What .NET mocking library do you use?
I was wondering recently which .NET mocking library is most popular. I suspected Moq but ran a poll to find … Continue reading Poll Results : What .NET mocking library do you use?
Use params keyword in C# to accept a variable number of arguments of the same type
Do you know about the PARAMS keyword in C# ? The params keyword allows us to create methods that accept … Continue reading Use params keyword in C# to accept a variable number of arguments of the same type
How to create Parameterized Tests with xUnit
I love parameterized tests. Instead of many different test methods with different inputs set in the method body we have … Continue reading How to create Parameterized Tests with xUnit
Moq, NSubstitute and FakeItEasy mocking library syntax comparison
Which .NET mocking library syntax do you prefer from the below test examples? Moq?NSubstitute?FakeItEasy? … and which library do you … Continue reading Moq, NSubstitute and FakeItEasy mocking library syntax comparison
Poll Results : Does TDD improve code quality over writing tests after code?
It’s always a divisive topic but in your experience, does Test-Driven Development (TDD) improve code quality more than writing tests … Continue reading Poll Results : Does TDD improve code quality over writing tests after code?
Using IEntityTypeConfiguration config classes to configure Entity Framework entity mappings
When using Entity Framework, storing mapping configurations inline directly in OnModelCreating can make our DbContext class cumbersome and less readable … Continue reading Using IEntityTypeConfiguration config classes to configure Entity Framework entity mappings
.NET 8 simple string concatenation benchmarks
Just for fun, I took benchmarks using BenchmarkDotNet to see what’s the fastest out of common ways used to concatenate … Continue reading .NET 8 simple string concatenation benchmarks
C# 11 list pattern examples
Beginning with C# 11, we can use list patterns to match elements of a list or array. Some examples of different types … Continue reading C# 11 list pattern examples
String.Equals with OrdinalIgnoreCase compared to ToLower / ToUpper for string insensitive comparisons in C#
In C#, when checking if strings are equal in a case insensitive way prefer string.Equals with OrdinalIgnoreCase over using ToLower() … Continue reading String.Equals with OrdinalIgnoreCase compared to ToLower / ToUpper for string insensitive comparisons in C#
String.Equals with OrdinalIgnoreCase faster in .NET 8 compared with .NET 7
There’s some awesome string comparison OrdinalIgnoreCase improvements coming in .NET 8, although I did see one regression too. Click on … Continue reading String.Equals with OrdinalIgnoreCase faster in .NET 8 compared with .NET 7
How to validate all benchmarked methods return the same value with BenchmarkDotNet
Instead of calling your benchmark methods outside the context of BenchmarkDotNet to validate they all return the same value, let … Continue reading How to validate all benchmarked methods return the same value with BenchmarkDotNet
How to order BenchmarkDotNet results from fastest to slowest
By default BenchmarkDotNet outputs the results of benchmarks as they are coded in the benchmark class file. If you wish … Continue reading How to order BenchmarkDotNet results from fastest to slowest
How to enable split queries globally in Entity Framework
The AsSplitQuery() method in Entity Framework is useful as it allows us to avoid cartesian explosion which can cause performance … Continue reading How to enable split queries globally in Entity Framework
Improved ASP.Net debugging in Visual Studio in .NET 8
.NET 8 Preview 5 was recently released and it includes improvements to ASP.NET debugging in Visual Studio. It looks like … Continue reading Improved ASP.Net debugging in Visual Studio in .NET 8
.NET 8 FrozenDictionary benchmarks
For those that don’t know Microsoft have introduced new FrozenDictionary and FrozenSet collections in .NET 8 (from Preview 1). These collections … Continue reading .NET 8 FrozenDictionary benchmarks
Creating pull requests directly in Visual Studio now supported
From Visual Studio 2022 17.7 Preview 2+ it’s now possible to CREATE PULL REQUESTS directly from within the IDE ❤ … Continue reading Creating pull requests directly in Visual Studio now supported
Consider C# 8 switch expressions to improve readability of existing switch statements
I generally don’t like too much ‘sugar’ being added to C# but Switch Expressions from C# 8 really can improve readability … Continue reading Consider C# 8 switch expressions to improve readability of existing switch statements
SOLID principles are not laws
I cringe every time I hear a dev say something is a ‘violation’ of one of the SOLID principles as … Continue reading SOLID principles are not laws
Use local functions in C# to encapsulate logic to a single calling method
💡 – Did you know we can use local functions in C# to scope logic only to their containing methods? … Continue reading Use local functions in C# to encapsulate logic to a single calling method
Use LINQ Intersect method to find common items in two collections in .NET
C# Tip 💡 ->Did you know LINQ Intersect can be used to find common items between two collections in .NET? … Continue reading Use LINQ Intersect method to find common items in two collections in .NET
Debug localhost APIs via remote URLs with Visual Studio Dev Tunnels
Have you used Dev Tunnels in Visual Studio yet? Devs tunnels allow us to expose (and debug) our localhost APIs … Continue reading Debug localhost APIs via remote URLs with Visual Studio Dev Tunnels
New Guard Clauses coming in .NET 8
New Guard Clauses coming in .NET 8 👇🏻 … .NET 6 and .NET 7 introduced a couple of Guard Clauses … Continue reading New Guard Clauses coming in .NET 8