/BlogCode

Code from my blog - https://conradakunga.com/blog

Primary LanguageHTML

Blog

Code for the examples on my blog - https://conradakunga.com/blog

April 2023

6 April 2024 Using Inheritance With FluentValidation - How to leverage inheritance to write less, and more powerful, validation code.

August 2023

18 Aug 2023 Defining Relationships With Enum Attributes For Enum Values In C# - How to use attributes to enforce relationships between Enums

8 Aug 2023 Tip - Using JsonSerializationOptions With Refit - how to control the serialization and deserialization of objects when using Refit

July 2023

21 Jul Tip - Adding x-request-id to a HTTP request without changing case - a workaround around a problem where the HttpClient changes the case of this particular header when it is added.

May 2023

3 May 2023 Writing Maintainable, Testable Code That Depends On The Current Time - how to use interfaces to mock implementations that can be used to improve testing, maintainability and composability of components.

March 2023

28 Mar - How To Use C# List Pattern Matching Practically - How to use List Patterns for the elegant solution of common problems.

February 2023

14 Feb - Building Directory Paths In C# - How to use Path.Combine for better manipulation and building of file system paths.

November 2022

26 Nov - Indexing SQL Server NVARCHAR(MAX) Columns - How to get around restrictions around the indexing of NVARCHAR(MAX) SQL Server database columns.

21 Nov - Deserializing Null Values From JSON - How to do custom deserialization of values in JSON payloads.

12 Nov - The Required Keyword in C# 11 & .NET 7 - How to use the required keyboard to write terser, more maintainable code.

October 2022

24 Oct - Constructing Dates In SQL - SQL Server parse strings in various date formats into valid dates.

15 Oct - Microsecond Precision In .NET - How to handle microsecond precision in .NET and an improved way to do it in .NET 7

14 Oct - How To Order Classes And Records In C# - Using Comparers by implementing the IComparer interface to allow for flexible sorting of collections of classes and records.

13 Oct - Tip - Simpler LINQ Ordering In .NET 7

3 Oct - Tip - Using LINQ To Filter A List Of Strings Containing Words In Another List

2 Oct - Tip - Grouping Using LINQ In VB.NET - A gotcha in the syntax of how to correctly group using VB.NET

August 2022

15 Aug - A better way to build and maintain URLs

1 Aug - Using HttpClient To Post JSON In C# & .NET

May 2022

25 May - Mapping Inherited Immutable Classes Using Dapper

April 2022

28 April - Adding Multiple Items To A HashSet In C#

March 2022

29 Mar - Cleaner Code With Switch Expressions In C#

December 2021

21 December - 30 Days Of .NET 6 - Day 30 - Simplified Argument Null Checks - How to simplify code that does checks for null arguments.

6 December - 30 Days Of .NET 6 - Day 29 - Writing Raw JSON Using Utf8JsonWriter - How to customize Json serliazation

November 2021

29 November - 30 Days Of .NET 6 - Day 28 - JSON Serialization To & From Streams - How to serialize JSON to a stream and to deserialize JSON from a stream.

19 November - 30 Days Of .NET 6 - Day 27 - Extended Property Patterns - Using extended property patterns to simplify filtering.

4 November - 30 Days Of .NET 6 - Day 23 - Nullable References - How nullable references help catch potential bugs at compile time.

October 2021

27 October - 30 Days Of .NET 6 - Json Property Ordering - How to control the order of the serialization of Json attributes

21 October - Saving Collections Of Primitives In Entity Framework Core - How to persist collections of primitive in Entity Framework Core 21 October - 30 Days Of .NET 6 - Day 19 - Record Structs - .NET 6 has a new record struct construct where record execution is applied to structs.

12 October - 30 Days Of .NET 6 - Day 17 - New Timer - PeriodicTimer - .NET 6 has a new timer for use in async contexts - the PeriodicTimer

7 October - 30 Days Of .NET 6 - Day 16 - HTTP/3 Support - .NET 6 now supports HTTP/3

5 October - 30 Days Of .NET 15 - Day 10 - SOCKS Proxy Support - You can now connect using SOCKS 4 and 5 proxy servers

September 2021

29 September - 30 Days Of .NET 6 - Day 13 - LINQ Improvements - Chunk - You can use the new Chunk method to partition collections into multiple collections of a specified size.

28 September - 30 Days Of .NET 6 - Day 12 - Collection Count Performance Check - TryGetNonEnumeratedCount - a new method intended to allow you to check if you can cheaply determine the size of a collection.

27 September - 30 Days Of .NET 6 - Day 11 - LINQ Improvements - Support For Ranges - LINQ now allows you to use indexes and ranges in expressions.

22 September - 30 Days Of .NET 6 - Day 9 - LINQ Improvements - DistinctBy - The DistinctBy extension method.

21 September - 30 Days Of .NET 6 - Day 8 - Control Of Serialization Of Object Cycles - You have additional control of how circular objects are serialized with the System.Text.Json serializer

14 September - 30 Days Of .NET 6 - Day 7 - Simpler Web Application Development - it is now simpler to write web applications using the minimal API feature set.

13 September - 30 Days Of .NET 6 - Day 6 Priority Queue - the new PriorityQueue class

10 September - 30 Days Of .NET 6 - Day 5 - Math API Additions - there have been some additions to the Math class.

9 September - 30 Days Of .NET 6 - Day 4 - LINQ Improvements - MaxBy & MinBy - LINQ improvements - the MaxBy and MinBy extension methods

8 September - 30 Days Of .NET 6 - Day 3 - TimeOnly - A look at the new TimeOnly type.

6 September - 30 Days Of .NET 6 - Day 1 - DateOnly - A look at the new DateOnly type.

July 2021

29 July - Reducing Bugs Through Better Domain Design - How to reduce bugs and improve re-usability and maintainability from better domain design.

25 July - Better Assertion Testing With FluentAssertons - Write cleaner, easier to understand tests that can be read by users of other testing frameworks

2 July - F# Doesn't Support C# Types Using Init Modifiers - Interop from C# fails when you use the init property modifier.

June 2021

11 June - Tip - TimeSpan Minutes vs TotalMinutes - The difference between Minutes and TotalMinutes when subtracting TimeSpans is very subtle.

May 2021

24 May -About Default Interfaces - Application of C# default interface methods

March 2021

24 Mar - Using System.Text.Json To Enforce API Logic - How use System.Text.Json To Enforce API Logic

9 Mar - Handling Nulls & Empty Strings With System.Text.Json - Your options when it comes to handling nulls & empty strings with the System.Text.Json engine.

6 Mar - Inheritance In Business Logic Is Likely A Code Smell - Part 1 - If you are using class inheritance to solve business problems, you are likely doing something wrong.

February 2021

2 Feb - Using Regex MatchEvaluators - how to use regular expression match evaluators to solve interesting problems

December 2020

30 December 2020 - What Do You Actually Agree To When You Accept Cookies - the implications of data collection and the potential organizations with access to it.

21 December 2020 - Improving HttpClient Requests - improving http redirection management with the HttpClient

14 December 2020 - HTTP Header Validation - potential problems that can be caused from failing to set HTTP Headers

November 2020

23 November 2020 - HTTP Redirects using HttpClient - a closer look at how http redirects are handled by the HttpClient

21 November 2020 - Refactoring With Records - Refactoring code to use the record construct introduced in C# 9

12 November 2020 - Conditional Logic In MSBuild - using MSBuild to control the build process and output notifications

9 November 2020 - Getting Now Playing Information From WQXR In .NET - Reverse engineering getting the now playing information from the WXQR radio station using the API

June 2020

25 June - Joining Strings - Part 3 - Joining strings using the StringBuilder

15 June - Joining Strings - Part 2 - Joining strings using String.Concat

May 2020

28 May - Joining strings - part 1 Concatenation with the + operator

19 May - Using curl in PowerShell - how to use the curl utility without clashing with the PowerShell alias

16 May - Touch In PowerShell - Implementing the Touch command in PowerShell

April 2020

25 April - Extracting Bytes From a F# String - A quick way to extract the bytes from a string

14 April - Count vs Length vs Any–Checking Collection Emptiness - The various ways of checking a collection is empty and bench-marking their performance

10 April - Properties Under The Hood - what does the compiler do when it finds properties in your code?

5 April - Argument Handling Across Paradigms - How arguments are handled in C# vs Lisp, and how to get the same effect

1 April - Fizz Buzz In F# - An initial attempt at FizzBuzz and subsequent refinements

March 2020

29 March - Using Nuget In F# Scripts - With F# 4.7 you can use Nuget packages in your scripts

22 March - Fun With Tuples In C# 7 & Above - What tuples are and a clever way to use them in constructors