Using The u8 String Literal
[C#]
A number of processing APIs and modules operate on byte
arrays rather than discrete structures like strings
.
How To Work With Different Numbering Systems In C#
[C#]
When it comes to numbers, we overwhelmingly work with the decimal number system, which uses a base of 10.
Customizing Object Equality In C# & .NET
[C#, .NET, Domain Design]
Equality, at face value, seems like a very simple concept. The following, it can be agreed, are equal:
Using AggregateBy In C# & .NET 9
[C#, .NET 9, LINQ]
Aggregation is a fairly common operation when it comes to data analysis, which is catered for pretty well in LINQ.
Checking Collections Have The Same Elements
[C#]
There may be occasions when you have two collections and want to verify that they are the same.
Handing JSON Deserialization In The Wild
[C#, JSON]
Deserializing JSON is typically a very straightforward affair, and the recommended JSON Serializer, Sysem.Text.Json, typically handles this easily.
Simplified Hashing In .NET 9
[Security, .NET 9]
If you are dealing with security, no matter how peripherally, you will have dealt with hashing functions and the requirement to hash data.
Using LINQ CountBy In .NET 9
[C#, .NET 9, LINQ]
Often in the course of your regular programming, you will need to do some basic analysis of data by aggregation, and the goto method here is typically LINQ and it’s GroupBy.
Determining The Number Of Days In A Year In C#
[C#]
Suppose we need to determine the number of days in a year, say this year (2024).
Configuring Docker Compose RabbitMQ Settings For A Docker Container
[Docker, RabbitMQ]
If you require a message queueing solution, RabbitMQ is hard to beat. Not only is it an excellent piece of software, but it is also cross-platform and available as a docker image.
Loading & Using Application Settings In .NET
[C#, .NET, Configuration]
In the course of your .NET application you will invariably require to access and use settings in the course of your application’s operations to configure services that your application is going to require in the course of the running of your application.
LinqPad For OSX Beta Is Out
[.NET, OSX, LinqPad]
I have been using a MacBook Pro (M3) as my primary development machine for almost 6 months. I use JetBrains Rider as my primary IDE, and occasionally, I use VS Code.
Writing Minimal APIs For HEAD Requests
[C#, ASP.NET, Minimal API]
Using Minimal APIs it is usually pretty straightforward to build API end points to tackle most scenarios.
Sending & Receiving JSON With A HttpClient In C#
[C#, HttpClient]
In my previous post, Sending a HTTP HEAD Request With A HttpClient In C#, I talked about how to send various requests using a HttpClient.
Sending a HTTP HEAD Request With A HttpClient In C#
[C#, HttpClient]
It is very simple to send GET, POST, PUT, PATCH and DELETE requests using a HttpClient.
Required Properties vs Constructors In Domain Objects
[C#, Design, Art Of Software]
One of the realities of writing software is dealing with objects, and how to communicate intent and help developers fall into the pit of success. This is especially an issue when you are writing software or code that is meant to be used by other developers, perhaps in an SDK or some sort of API.
Ordered Dictionary Improvements In .NET 9
[C#, .NET 9]
The dictionary class is a workhorse of the developer. It is a data structure that allows you to store a value
of any kind with an associated key
to look up the said value. The key must be unique, and attempting to insert a duplicate throws an exception
Removing Items From A Priority Queue
[C#, .NET 9]
.NET 6 introduced the PriorityQueue, a data structure that is a queue that allows you to attach a weight, or a priority, to enqueued items to affect the dequeuing behaviour.
Using LINQ Index
[C#, LINQ, .NET 9]
Here is a possible problem - you have a list of athletes and you would like to interate through them and generate an index for each.
Random Sampling In F#
[F#]
Suppose you need to write a program to randomly sample a number of items from a list of numbers from 0 to 99
Choosing From A Collection In F#
[F#]
Suppose you were writing a program to simulate the throwing of two dice. The minimum result you can have is 2 1 + 1
and the maximum result you can have is 12 6 + 6
.
How Old Is Your Programming Language (2024 Edition)
[Epiphanies, Languages]
This is an update to a post I wrote 4 years ago, which I will now be updating annually
Improved Collection Shuffling In F#
[F#]
Suppose you needed to shuffle the numbers 0 to 9 in F#, perhaps for a game or a data science exercise.
Truncating Numbers In C#
[C#, .NET]
If you have the following number, 123.456
, and you want to write it to the console, or anywhere for that matter to 2 decimal places, you would do it like so:
Getting Your IDE To Recognize Domain Specific Languages
[Rider, Visual Studio, Visual Studio Code]
Suppose you had a program with the following code:
Formatting Json On The Terminal / Command Line
[JSON]
In the spirit of the last post about formatting unformatted JSON there are occasions when you need to process and format JSON in a hurry on a non-developer machine.
Storing Common Application Settings For A .NET Application In MacOS OSX
[C#, .NET, OSX]
Suppose, for whatever reason, you need to store some data, such as master files, in a specific location on the file system and populate them at runtime/initialization.
Pretty Printing Unformatted Json In C#
[C#, .NET]
Occasionally, you will find yourself in a position where you have unformatted or poorly formatted JSON, and you would like to view it formatted, also known as pretty printed.
Determining The Operating System C# .NET Program Is Running Under
[C#, .NET]
Periodically, you will need to determine the operating system your code is running under in order to perform different logic. For example, you want the behaviour to be different depending on whether the code is running under Linux, Windows or OSX.
Running Multiple .NET Versions In MacOS OSX
[.NET, C#]
With .NET 9 released the other day, you might find not all your tools and libraries support .NET 9.
A Rose By Any Other Name - Short Circuiting
[C#, VB.NET]
Suppose you have the following C# program:
Using Inheritance With FluentValidation
[C#, .NET, FluentValidation]
If you are a .NET developer, you really need to be using the FluentValidation library.
Dogs Will Always Bark - Part I - You Make I Check
[The Business Of Software, Human Nature]
If you have not already, you will inevitably run into a system that has a concept of a maker and a checker.
Correctly Setting HttpClient BaseAddress
[.NET, C#, HttpClient]
To make HTTP requests in C# (or any other .NET language), you use the HttpClient class.
How Long Is A String
[Business Of Software]
Take any software in popular use:
Verifying File Hashes With PowerShell (Update)
[PowerShell, Tips]
A couple of years back, I wrote a post on how to get the hash of a file natively in PowerShell in situations where you need to verify a download, like this one:
Tip - Don't Log Exceptions With Log.Information
[C#, .NET, Tips]
When it comes to logging, many ILogger implementations allow you to log errors like this:
Did You Know - An Email Body Is Optional
[Did You Know]
The other day while working with one of our internal libraries for sending email, I ran into an error where it complained about a missing body.
Defining Relationships With Enum Attributes For Enum Values In C#
[C#]
Suppose you had the following enum
Tip - Using JsonSerializationOptions With Refit
[C#, .NET, Refit]
Refit is an excellent library that makes it very easy to call APIs are convert the responses to typed objects.
Fix - HttpClient Changes Case Of x-request-id Header
[C#, .NET, HttpClient]
When working with a HttpClient, this is how you add a request header to each request:
Projecting Named Tuples In Entity Framework Core
[Entity Framework Core, C#, .NET]
Suppose you had the following class:
Tip - Fluent Validation With Null Values
[.NET, Validation, Libraries, Tips]
There is an excellent library, FluentValidation, that is very handy when it comes to expressing validation logic, and doing it centrally.
Accessing SQL Server Configuration Manager
[SQL Server]
Once in a while you might need to access the SQL Server Configuration Manager.
Why Doesn't Windows Have A Built In Dictionary?
[Business Of Software]
“Why,” a CEO friend of mine asked one day in exasperation “doesn’t Windows have a dictionary?”
Writing Maintainable, Testable Code That Depends On The Current Time
[C#, .NET, Design, Maintainability]
Code that is conditional on time is almost something you are guaranteed to write at some point. Think:
How To Use C# List Pattern Matching Practically
[C#, .NET]
One of the more powerful features introduced in C# 11 is list pattern matching.
Building Directory Paths In C#
[C#]
Suppose you wanted to generate a folder on your desktop, say to store your incomplete proposals.
Writing A Custom DateOnly JSON Deserializer
[C#]
The versatility of JSON as a data interchange format is that it can represent almost anything, given that ultimately all attributes are strings (or numbers).
Stop Press - Running Linux GUI Applications In Windows
[Windows, Linux, WSL]
So very quietly last week a game changer was published to the Windows Appstore.
How To Index A NVarchar(MAX) Column In SQL Server
[SQL Server]
Suppose we have this table:
Handling Null And Empty Strings With System.Text.Json - Part 2
[C#, System.Text.Json]
In a previous post I talked about Handling Null And Empty Strings With System.Text.Json
Enabling TCP/IP For SQL Server
[SQL Server]
Access to the SQL Server database engine is achieved using one of three protocols.
Required Keyword In C# 11 & .NET 7
[C#, .NET]
One of the improvements in .NET was the record.
Tip - SQL Server Management Studio - Constructing Dates
[SQL Server, SQL Server Management Studio, Tips]
Working with dates is a fairly common operation when working in TSQL.
Tip - SQL Server Management Studio - Reorder Lines
[SQL Server, SQL Server Management Studio, Tips]
Most of your time when working with the SQL Server Management Studio you will be writing and modifying queries.
Tip - SQL Server Management Studio - Duplicate Tab
[SQL Server, SQL Server Management Studio, Tips]
Suppose you have this query:
Tip - SQL Server Management Studio - Server Colouring
[SQL Server, SQL Server Management Studio, Tips, RedGate]
We’ve all done it - ran a query on the server we thought was the test but was in fact the production
Tip - SQL Server Management Studio - Reorder Results
[SQL Server, SQL Server Management Studio, Tips]
Working with results is one of the most obvious use cases of SQL Server Management Studio.
Microsecond Precision In .NET
[C#, .NET 7]
The traditional way to make a DateTime is as follows:
How To Order Classes And Records In C#
[C#, .NET 7, LINQ]
When it comes to collections of primitive types, ordering is pretty straightforward.
Tip - Simpler LINQ Ordering In .NET 7
[Tips, C#, LINQ, .NET 7]
Using LINQ, you can order a collection using the OrderBy (or the OrderByDescending) extension methods.
Tip - Using LINQ To Filter A List Of Strings Containing Words In Another List
[C#, LINQ, Tips]
Suppose you have this list of snacks.
Tip - Grouping Correctly In LINQ With VB.NET
[VB.NET, LINQ, Tips]
Grouping is one of the more powerful features of LINQ.
Building URLs In C# Without Concatenation Or Interpolation
[C#, .NET]
When dealing with the web, you will often require to deal with URLs.
Using HttpClient To Post JSON In C# & .NET
[C#, .NET]
For a long time if you wanted to post JSON using a HttpClient, you would do it like this:
Punched In The Face Or In The Stomach
[Business Of Software]
Quick - would you like to be punched in the face or punched in the stomach?
Conmen, Charlatans And Software Developers
[Business Of Software]
Three of the things you will quickly discover that you need in this business are the following:
- A tough skin
- Patience
- An ability to accept an ambiguous state as a valid reality
Beware - Mapping Inherited Immutable Classes Using Dapper
[C#, Dapper]
Assume you have the following class:
Linux Tools Packaged With Windows
[Windows]
If you are running a recent build of Windows 10 (or 11) you would be surprised to learn a number of tools traditionally found in Linux are now bundled with Windows.
Fix - Python - Warning- Ignoring Invalid Distribution
[Python, Fixes]
When doing pip update
or pip list
you might get the following warning:
Fix - SSL Provider, error 0 - The certificate chain was issued by an authority that is not trusted
[C#, .NET, SQL Server, Fixes]
For many years, the provider to access SQL Server from .NET was System.Data.SqlClient.
About curl And PowerShell
[C#, .NET]
In a previous blog post I had talked about how curl
in Powershell was an alias for the Invoke-WebRequest cmdlet.
Adding Multiple Items To A HashSet In C#
[C#]
Let us take a typical object:
What Amazon AWS Local Zones Mean For ICT In Kenya
[Business Of Software, Amazon, Azure, Google]
Amazon AWS announced the other day that they were setting up an AWS zone in Nairobi.
Tip - HttpUtility.UrlEncode vs WebUtility.UrlEncode
[C#, .NET, Tips]
In this world of websites and APIs you will invariably be called upon to build URLs, either manually or through code.
Tip - Updating The Nuget Client
[Tips, .NET]
Did you know that the Nuget client (nuget.exe
) is capable of updating itself?
Cleaner Code With Switch Expressions In C#
[C#, Algorithms]
Everyone who remembers their path towards becoming a programmer, either as a hobbyist or a career software engineer, will remember the problem of writing this program - given a mark, allocate a grade according to a table like this:
Fetching Table Data From Web Pages Using Excel
[Excel, PowerUser, Office]
Microsoft Excel is like that old, dependable, reliable friend that always has a solution to your problems.
If Your Grandmother Had Wheels - She Wouldn't Be A Bicycle - Its ALWAYS Harder Than You Think
[Business Of Software]
“I have an idea!” a friend said breathlessly.
Using 'TRUE' and 'FALSE' For Bit Types In SQL Server
[SQL, SQL Server]
SQL Server, as you are no doubt aware, has a type that can be used to represent boolean states - true
and false
.
Maintainability Of Code
[C#, Design]
The problem is simple.
Standing In A Garage Doesn't Make You A Car - Why You Cant Just "Hire Developers"
[Business Of Software]
Coding Is Easy - Any Monkey Can Do It. Software, However Is Very Hard
[Business Of Software]
There is a famous question those in the software industry ask themselves:
All Sons Are Handsome; All Daughters Are Beautiful - Pitching Enterprise Software
[Business Of Software]
In my experience, parents are generally of the opinion that their sons are handsome and their daughters are beautiful.
30 Days Of .NET 6 - Day 30 - Simplified Argument Null Checks
[.NET, C#, 30 Days Of .NET 6]
One of the things you will quickly learn after doing software development for any amount of time is that you cannot assume users of your software will do the right thing.
30 Days Of .NET 6 - Day 29 - Writing Raw JSON Using Utf8JsonWriter
[.NET, C#, 30 Days Of .NET 6]
Serialization of objects to JSON, as we have seen, is easily achieved using the native Json serializer, System.Text.Json.
30 Days Of .NET 6 - Day 28 - JSON Serialization To & From Streams
[.NET, C#, 30 Days Of .NET 6]
Most of the time, when serializing JSON, you already have access to the underlying object that you are serializing.
Tip - SQL Server User Defined Table Types - Column Order Matters
[SQL Server]
User Defined Table Types are a very nifty way to pass data to a stored procedure for processing.
30 Days Of .NET 6 - Day 27 - Extended Property Patterns
[.NET, C#, 30 Days Of .NET 6]
Pattern matching is a powerful feature borrowed from functional languages that can make a whole class of problems simpler to solve.
30 Days Of .NET 6 - Day 26 - Sealed ToString() In Records
[.NET, C#, 30 Days Of .NET 6]
One of the things you get for free when using a record
is that the compiler will write for you a ToString()
method for free.
30 Days Of .NET 6 - Day 25 - Hot Reload
[.NET, C#, 30 Days Of .NET 6]
Programming has been with us for almost a century now but the cycle surprisingly has largely been the same:
.NET 6 Release
[.NET, C#]
The final release of .NET 6 is now available.
You can get the final bits here. Remember that .NET is cross platform so you can select the appropriate sections to download the bits for your operating system
30 Days Of .NET 6 - Day 24 - Parallel.ForEachAsync
[.NET, C#, 30 Days Of .NET 6]
Computing “power” over the past decades has changed from being a speed game “megahertz” to a parallelism game - multi-processor, multi-core.
30 Days Of .NET 6 - Day 23 - Nullable References
[.NET, C#, 30 Days Of .NET 6]
The great computer scientist Tony Hoare, credited with inventing the null
reference, famously confessed this to be his ‘billion dollar mistake’.
30 Days Of .NET 6 - Day 22 - LINQ Default Parameters
[.NET, C#, 30 Days Of .NET 6]
One of the things to think about when writing LINQ
filter expressions (First
, Last
, or Single
) is what happens when the thing you are looking for was not found.
30 Days Of .NET 6 - Day 21 - Constant Interpolated Strings
[.NET, C#, 30 Days Of .NET 6]
A fairly common task in day to day programming is combining strings.
30 Days Of .NET 6 - Day 20 - Json Property Ordering
[.NET, C#, 30 Days Of .NET 6]
Today we look at what might be a niche feature, but nevertheless in some use cases might actually be quite useful.
Saving Collections Of Primitives In Entity Framework Core
[C#, Entity Framework Core]
Suppose you have the following class that you wish to persist using the Entity Framework Core ORM.
30 Days Of .NET 6 - Day 19 - Record Structs
[.NET, C#, 30 Days Of .NET 6]
Today’s item, record structs
, is a bit more elaborate to explain, but I shall do my best.
.NET 6 Release Candidate 2 Out
[.NET, C#]
.NET 6 Release Candidate 2 was released last week, on the 12th.
30 Days Of .NET 6 - Day 18 - File Scoped Namespaces
[.NET, C#, 30 Days Of .NET 6]
As your codebase grows, it becomes important to organize your code. This is done using a concept called namespaces.
30 Days Of .NET 6 - Day 17 - New Timer - PeriodicTimer
[.NET, C#, 30 Days Of .NET 6]
If there is one thing that .NET has plenty of it is timers.
30 Days Of .NET 6 - Day 16 - HTTP/3 Support
[C#, .NET, 30 Days Of .NET 6]
The Hypertext Transfer Protocol is the protocol at the heart of the internet.
Installing .NET 6 On Linux
[.NET, C#]
It is again worth repeating that .NET 6, like 5, 3 and 2 before it are cross platform and can be used to build applications in Linux and OSX.
30 Days Of .NET 6 - Day 15 - SOCKS Proxy Support
[C#, .NET, 30 Days Of .NET 6]
Occasionally you will need to connect to the internet, or to another network for that matter, through a proxy.
30 Days Of .NET 6 - Day 14 - Implicit Usings
[C#, .NET, 30 Days Of .NET 6]
When developing an application, you invariably will need to use logic or functionality encapsulated elsewhere.
30 Days Of .NET 6 - Day 13 - LINQ Improvements - Chunk
[C#, .NET, 30 Days Of .NET 6]
One of the cornerstones of modern computing is that there is much less emphasis on raw power and more on distributing work.
30 Days Of .NET 6 - Day 12 - Collection Count Performance Improvement
[C#, .NET, 30 Days Of .NET 6]
UPDATE
30 Days Of .NET 6 - Day 11 - LINQ Improvements - Range Support
[C#, .NET, 30 Days Of .NET 6]
One of the most powerful features of LINQ is the ability to select a range of elements from a collection.
30 Days Of .NET 6 - Day 10 - SDK & Runtime Version Checking
[C#, .NET, 30 Days Of .NET 6]
Software is always a moving target - adding features, fixing bugs or even removing features. The same challenges fall upon the tools used to develop software.
30 Days Of .NET 6 - Day 9 - LINQ Improvements - DistinctBy
[C#, .NET, 30 Days Of .NET 6]
Another improvement that has been added to the LINQ engine is the DistinctBy method.
30 Days Of .NET 6 - Day 8 - Control Of Serialization Of Object Cycles
[C#, .NET, 30 Days Of .NET 6]
When dealing with complex object graphs in memory, it is common to have objects referencing themselves.
.NET 6 Release Candidate 1 Out
[.NET, C#]
The .NET 6 Release Candidate 1 was released last week.
30 Days Of .NET 6 - Day 7 - Simpler Web Application Development
[C#, .NET, 30 Days Of .NET 6]
The default template for a web application in .NET 5 and previous versions looks like it was done with seasoned, disciplined developers in mind. This is not a bad thing. The issue, just like with the previous console templates I’ve talked about earlier, is it is not welcoming to those new to the platform.
30 Days Of .NET 6 - Day 6 - Priority Queue
[C#, .NET, 30 Days Of .NET 6]
We are all familiar with the Queue class.
30 Days Of .NET 6 - Day 5 - Mathematics API Additions
[C#, .NET, 30 Days Of .NET 6]
It may surprise you to learn that even the Math API, which generally does not change all that much, has some additions for those who do high performance trigonometric functions.
30 Days Of .NET 6 - Day 4 - LINQ Improvements - MaxBy & MinBy
[C#, .NET, 30 Days Of .NET 6]
One of the most powerful features introduced in the .NET Framework, all the way back in 2008 in .NET 3.5 was Language Integrated Query, better known as LINQ
30 Days Of .NET 6 - Day 3 - TimeOnly Type
[C#, .NET, 30 Days Of .NET 6]
We looked at the new DateOnly Type on Day 1 of this series, and it should come as no surprise that there is a companion TimeOnly type that has been introduced to deal with only the time component of a DateTime.
30 Days Of .NET 6 - Day 2 - Friendly To Newcomers
[C#, .NET, 30 Days Of .NET 6]
One of the challenges of developing and maintaining a programming languages and its accompanying tooling is you have to be welcoming to several demographics:
- Experienced developers on your tool-set
- Experienced developers from other tool-sets
- Students
- Complete newcomers to programming & hobbyists
30 Days Of .NET 6 - DateOnly Type
[C#, .NET, 30 Days Of .NET 6]
In .NET when manipulating dates and times, you generally use the DateTime type for such purposes.
Fix - .NET 6 Not Being Recognized After Install
[.NET]
After installing the .NET 6 SDK you can confirm that it was successfully installed and recognized by running the following command:
About Software Bloat
[Business Of Software]
Occasionally you will hear somebody say, (or you yourself may say) something like:
Fix - Docker Error On Upgrade - aufs storage
[Linux, Docker]
While upgrading docker you may get the following error:
Fix - Unavailable Resource Error When Posting HTTP Request To Teams
[Teams]
I have done two posts on automating posting messages to teams.
Tip - Get Current Date In C#
[C#, Tips]
Frequently in the course of your code, you will need to get the current date.
Reducing Bugs And Improving Maintainability Through Better Domain Design
[C#, Design]
One of my favourite maxims is “measure twice so you cut once”.
Sending Teams Messages Using PowerShell
[Teams, PowerShell]
First, read this previous post that gives a primer on how to interact with Microsoft Teams.
Better Assertion Testing With FluentAssertions
[Testing, XUnit, NUnit]
In the .NET world, there are two main unit testing frameworks: XUnit and NUnit.
The Value Of Good Documentation
[Business Of Software, Documentation]
Recent developments (we are in the middle of a massive upgrade of our technology stacks) as well as strategic decisions have forced us to interface with systems and ecosystems not only at code level as we are accustomed to, but additionally at documentation level.
Beware - F# Doesn't Support C# Types Using Init Modifiers
[F#, Interop]
Our primary stack at Innova is .NET, that we principally historically implemented in C# (and some Visual Basic.NET)
On Career Progression
[Personal Development, Career, Business Of Software]
Lionel Messi is, by many accounts, the best football player in the world.
Tip - Locating Commands In The Path On Windows
[Tips]
Assume you have a command like so:
Tip - TimeSpan Minutes vs TotalMinutes
[C#, Time, Tips]
The TimeSpan object allows for the representations of a point in time (the TimeOfDay component of a DateTime).
The Cost Of Adding Features To Software
[Business Of Software]
More Features Is Good
Fix - Docker For Windows Not Running
[Fixes, Docker]
Gitlab HTTP Authentication With 2FA
[Tools, Gitlab]
If you have turned on 2 factor authentication for GitLab, you might be wondering how you can access and manipulate your repository over HTTPS.
About Default Interface Impementations
[C#]
Default interface implementations were introduced in C# 8. Essentially these are interface declarations with bodies.
The Other Integer Types
[C#]
Most developers, when requiring an integer type, use the int
type and go about their business.
Tip - Making Use Of Windows Terminal Tab Captions
[Tips, Windows Terminal]
If you’re on Windows and are not using Windows Terminal, you really should.
Fix For The string argument propertyNames cannot be empty
[Entity Framework Core, C#, Fixes]
Today I got the following error when working with Entity Framework Core against a PostgreSQL database:
Disqus Off
[Meta]
So I noticed that the Disqus comments that I’ve been had been displaying a range of scammy ads.
Using System.Text.Json To Enforce API Logic
[Design, API, System.Text.Json]
Assume you have the following type:
Deleting RabbitMQ Queues With EasyNetQ
[RabbitMQ, EasyNetQ]
I recently had to delete all the queues in my RabbitMQ instance.
Fix For Cannot use LINQ in MatchCollection Regex with .NET Standard 2
[C#, LINQ, Fixes]
I have some code where I am running a regex and using LINQ to manipulate the matches.
Handling Null And Empty Strings With System.Text.Json
[C#, System.Text.Json]
Assume we have the following class:
Inheritance In Business Logic Is Likely A Code Smell - Part 1
[C#, Design]
When you were introduced to object oriented programming (OOP), you probably used the canonical example domain of animals.
Handling Exceptions With Refit
[C#]
Refit is a very brilliant library that allows you to call REST APIs with minimal code.
Consuming REST JSON APIs From Excel
[Excel, WebAPI, REST]
So today I wanted to see if Excel could natively consume JSON APIs.
Fix - error CS8805 Program using top-level statements must be an executable
[C#, Fixes]
So today in a rather large project I began getting the following error when I ran a build:
Using Regex MatchEvaluators In C#
[Regex]
Regular expressions (Regexes
) are a powerful tool for solving certain types of problems - and in particular looking for a certain pattern of text in a larger string and (optionally) replacing it with another.
Remember To Encode QueryString Data
[Tips]
Assume you have a controller with this GET
end point
Be Clearer With TimeSpans
[Tips, Time]
Many of the .NET APIs take time intervals as their parameters, and it usually is in milliseconds.
Entity Framework Core - Unique Constraits vs Unique Indexes
[Entity Framework Core]
In your traditional database, there are two ways to enforce the restriction that “the value of this column should be unique”:
- Unique constraints
- Unique indexes
UI Fails - Oracle VirtualBox 6.1
[Fails, UI Fails]
This is the dialog I saw when I launched Oracle VM VirtualBox today.
Fix For Entity Framework Core Not Generating Indexes & Constraints
[Entity Framework Core, Fixes]
If you are using Entity Framework Core, and are configuring your models using configuration classes (as you probably should) you might run into a situation where after adding your migrations and updating your database, you find that the resulting schema does not have indexes or unique constraints.
Fix For Entity Framework Tools Error
[Entity Framework Core, Fixes]
While running the entity framework command to add a migration, I got the following error
Fix For pgAdmin Not Loading
[PostgreSQL, Fixes]
Are you attempting to open the pgAdmin web console and it appears to be loading endlessly?
What Do You Actually Agree To When You Accept All Cookies
[Business Of Software, People]
I have been writing software for exactly twenty years now. In the course of this I have learnt very many things, which I hope to journal over time.
Improving HttpClient Requests
[C#, HttpClient]
This is another improvement to the logic of making a Http
request using the HttpClient.
Beware of HttpClient Header Validations
[C#, HttpClient]
I ran into an interesting problem the other day.
Remote Debugging In VS Code
[C#, VS Code]
Today we will setup an environment where we can develop and debug code remotely on a Linux environment.
HTTP Redirects Using HttpClient
[C#, Under The Hood, HttpClient]
In a previous post I had mentioned that the HttpClient
does not automatically process HTTP redirects and you would have to write the logic yourself.
Refactoring With Records In C#
[C#, Records]
I recently had an opportunity to revisit some very old code (to the tune of almost a decade) and saw it as an opportunity to make some improvement and cleanup.
Changing The Default Shell In IntelliJ To PowerShell
[IntelliJ]
The default shell in IntelliJ (and its children IDEs) is the Windows Command Prompt.
Conditional Logic In MSBuild
[.NET, MSBuild]
The Microsoft Build Engine, MSBuild, is responsible for controlling the build process that translates source code to object code and its relevant artifacts.
Getting Now Playing Information From WQXR In .NET
[.NET, C#, API, HttpClient]
UPDATE: Updated to .NET 7 on 23 Feb 2023
Posting Messages To Microsoft Teams With Code
[C#, .NET, Microsoft Teams]
Microsoft Teams makes use of an API, the Microsoft Graph API, that is leveraged to push data into, and pull data out of various Microsoft Products, chiefly Office 365.
Disable SSL Certificate Validation In .NET
[C#]
If you are invoking a web request from your application, you may get the following error:
Querying & Extracing Data From YouTrack
[C#, YouTrack]
YouTrack is a robust web based platform for issue tracking, Sprint and Kanban management.
Chrome UI Surprises
[UI, UX]
Here is a site I am visiting on Chrome.
Joining Strings - Part 4 : String.Format
[.NET, Under The Hood]
This is Part 4 in the series of Joining stings
Joining Strings - Part 3 : StringBuilder
[.NET, Under The Hood]
This is Part 1 in the series of Joining stings
Joining Strings - Part 2 : String.Concat
[.NET, Under The Hood]
This is Part 2 in the series of Joining stings
Upgrading To WSL 2
[WSL]
Good news if you have been running on Windows Subsystem For Linux (WSL) and have wanted to upgrade to version 2 but have not been willing to join the Windows Insider Program - WSL2 is now out in the main release.
Joining Strings - Part 1 : The + Operator
[.NET, Under The Hood]
This is Part 1 in the series of Joining stings
Jekyll, Ruby & OpenSSH
[Meta, Ruby, Windows, Linux]
So like I mentioned in my last post, I have migrated from WordPress to Jekyll as my content management system.
Goodbye Wordpress
[Epiphanies]
I have been running this blog on WordPress since inception, and using WordPress in general for many years (since 2005).
Using IIS With ASP.NET Core 3.0
[ASP.NET Core]
Kestrel, the web server that powers ASP.NET Core is highly optimized for running ASP.NET Core code, and running it fast.
Using Curl In PowerShell
[PowerShell]
A useful tool to have in your toolbelt is an ability to make web requests and retrieve responses from the command line.
Touch In PowerShell
[PowerShell]
In Unix / Linux land there is a handy command to create an empty file.
How Old Is Your Language?
[Epiphanies, Languages]
Ever wonder how old your favourite language is? You might be surprised!
Decimals, Precision And Scale
[SQL Server, .NET]
The .NET framework has a decimal data type.
Extracting Bytes From A F# String
[F#, Tips]
Suppose you need to extract the byte values of a string in F#
Should all bugs be fixed?
[Epiphanies, Business Of Software]
On the surface a perfectly reasonable question.
What Is A Software Company?
[Epiphanies, Software]
A software company is an institution that converts money into software that people pay money for.
Count vs Length vs Any - Checking Collection Emptiness
[C#, Under The Hood]
When working with collections there are several ways that you can determine if a collection is empty.
Getting Your Internet IP Address
[PowerShell]
Suppose, for whatever reason, you need to know your ISP assigned IP address.
Properties Under The Hood
[Under The Hood, C#]
One of the features of C# (and the .NET platform in general) is the support of properties as a first class citizen of the runtime.
Arguments Handling Across Paradigms
[C#, F#, Lisp, Languages]
One of the interesting things about using an object oriented language (like C#) vs a functional one (like Racket) is you get an opportunity to see first hand how different things are doing in either paradigm.
FizzBuzz In F#
[F#]
The FizzBuzz problem is one of those ubiquitous industry problems that has been floating around for decades, intended to separate the sheep from the goats.
Using Nuget In F# Scripts
[F#, Nuget]
One of the brilliant improvements in F# 4.7 is the ability to make use of Nuget packages in your scripts.
Pinning Nuget Package Versions
[Nuget]
The Nuget package management system has been a godsend when it comes to managing libraries and dependencies in your projects.
Controlling Creation Of .NET Core Projects
[.NET]
Many of us create .NET Core projects in the following way:
Fun With Tuples In C# 7 & Above
[C#]
Tuples, or to use their correct name, ValueTuples
, were introduced in C#.
Verifying File Hashes With PowerShell
[PowerShell]
It is often a good idea to verify the file hashes of downloaded files, whether it is to detect that the file you download was actually the one that the developers intended (see what happened to Handbrake for OSX) or to detect corruption of a download.
AsReadOnly() May Not Be Doing What You Think!
[C#]
You have probably come across the AsReadOnly()
extension method, and have probably made liberal use of it.
Beware Of Controller Name Typos In ASP.NET Core Controllers
[ASP.NET Core]
The other day I spent the better part of an hour trying to figure out why a particular controller action was not being hit by a request.
Copy SSH Key In Windows 10
[PowerShell]
Did you know that Windows 10 has a proper SSH client, and has had one for a while?