Blog Posts with Tag .NET
For years, I've been using open api generator or NSwag to generate HTTP clients for my projects. While this work well, there were edge cases I felt were hard to satisfy. Recently I learned about Kiota to generate API clients, and it takes a much different approach that I think is better. Generating an API Client to Chess.com I've been playing chess online this year, and so I was very interested when I found out Chess.com has a public facing API to access user data. I decided…
Happy New Year! Happy New Year! I've been taking a break for a while from my blog. I had been spending some extra time outside of work trying to push forward an initiative inside work to move my workplace forward on containers. It's just been one of those things I personally find important in technical leadership. Learn new things to level up, and share those things with others. It took a little extra effort to do that. It ate into my personal time a bit I used to blog and…
One really handy feature with .NET 7 is the ability to create containers directly from the dotnet command line. This lowers the bar to entry with container development, and if you've got a standard ASP.Net application, it's easy to throw it in a container. I just want to put a disclaimer before I begin. This functionality is currently in preview. Example Here's an simple example of building a docker container in .NET in just a few simple steps. Create the Project Using the…
The release of .NET 7 is around the corner with it now in RC. There are several new features that have grabbed my attention that I decided to try out. The first of these is Output Caching in ASP.Net Core 7. What is Output Caching? Output caching stores the response of an ASP.Net endpoint based on a policy so that it will not be re-calculated on a future request. This is different from Response Caching previously in ASP.Net Core. Response used cache headers and responses from…
I've been working with Roslyn Source Generators and have gotten to the pointer where there are a few I would like to use for other projects. In order to share the code between these projects, I've decided to create a NuGet package. While I've used NuGet for years and occasionally have had to create a NuGet package here and there for work, I've never actually published one to the official public NuGet repository before. NuGet NuGet is the package system for .NET. It has been…
In every project there is boilerplate code. It is a particular evil more seen in statically typed languages with the need to express every object in a type safe way. In this post I'm going to be talking about building a Source Generator with Roslyn to auto generate some of this boilerplate. More specifically I'll be auto generating a factory for an object based off a constructor. What's a Factory A factory is a design pattern focused on creating objects. While factories have…
When I'm unit testing in .NET many times I need a very large string or set of data to provide as input to a test case or as a final insertion. I like to use XUnit, but there aren't a lot of clear options to do this in any unit testing framework. One way to do this is to just store the large amount of data in a file somewhere near the test it's self. Common options to reference this file are around finding the test assembly DLL, making sure the files are copied to the output…
I've been working with Docker for close to 4 years now. My first project was a React application that I needed to deploy an on-premsis server. I was fairly new to containers, so I decided I'll just install it on a Linux server and see what the fuss is about. Once I had something working, I was hooked. They just made life so much easier! While it is very easy to containerize applications, there are a few tips and tricks I've learned over the years that really make Docker much…
Over the New Years break, I built a little console app to help with my new practice of engineering daybook. Engineering daybooks are the practice of documenting what happened in a work day. If you have read the Pragmatic Programmer, the practice is discussed in Topic 22. It has also be an very long time since I've just written a simple console application, so I wanted to see what's available in the latest version of .NET and NuGet libraries. Engineering Daybook I started…
I keep finding new little gems in .NET 6. The latest was the DateOnly and TimeOnly structs in .NET 6. Previous to .NET 6, time was typically represented as a DateTime, a DateTimeOffset, or sometimes a TimeSpan for intervals. DateTime and DateTimeOffset worked, but there are odd situations where you need to represent just a Time or just a Date. Trying to represent a Time in a DateTime can lead to all kinds of odd situations. Is one DateTime UTC vs Local, etc? What if I just…