Rediscovering a 2021 podcast on Python, .NET, and open source

Yesterday, the kids came home for the Christmas holidays. Marco surprised me by telling me that on his flight from Brussels, he discovered and listened to “my podcast” on Spotify. I was stunned. I didn’t remember ever recording a podcast, even though I’ve given a few interviews here and there over the years. During my usual morning walk today, I went to look for it, and there it was, an interview I had done in 2021 that I had completely forgotten about. I got over the initial embarrassment (it’s always strange to hear your own voice) and resisted the temptation to turn it off, listening to it all the way through. I must admit that it captures that moment in my professional life, and much of the content is still relevant, especially regarding my experience as an open-source author and maintainer and my transition from C# to Python and back. ...

December 22, 2025

On C# and .NET quick release cycle

I sat to jot down a quick introduction to my C# 13 What’s New and Interesting session next week, and what I ended up with instead is a long rant or, should I dare, stream of consciousness that is certainly inappropriate for a five-minute introduction. I’ll have to cut most of it down, especially on the personal story part, but my site might be a good place to host it in all its completeness. I may reference this post at the start of the session on Monday for those few poor souls who might be interested. ...

December 9, 2024

How to handle custom claims in an Open ID Connect-authenticated ASP.NET Core app

Today, I learned how to handle custom claims in an Open ID Connect authenticated ASP.NET Core app. The scenario goes like this. I have an ASP.NET Core app that authenticates with Open Id Connect. It receives a bearer token from the authentication server. Besides OIDC claims, this token has been forged with additional custom claims for use in the app. However, only ODIC claims exist when I parse HttpContext.User.Identity.Claims in my middleware. If I retrieve the token with HttpContext.GetTokenAsync and decode it, I confirm it contains all the claims I need. Where have my custom claims gone? Or, how can I get User.Identity to provide them along with the OIDC ones? ...

May 31, 2024

C# 12 Collection Expressions

This is a follow-up post to C# 12 Primary Constructors. Like that article, this one originates from the preparation notes for my presentation at the ABP Dotnet Conference 2024. I love collection expressions. Like primary constructors, collection expressions will see a significant adoption in the long run. Collection expressions introduce a new way to initialize common collection values in a terse, unified syntax. This is how we initialize collections today: var x1 = new int[] { 1, 2, 3, 4 }; var x2 = Array.Empty<int>(); WriteByteArray(new[] { (byte)1, (byte)2, (byte)3 }); List<int> x3 = new() { 1, 2, 3, 4 }; Span<DateTime> dates = stackalloc DateTime[] { GetDate(0), GetDate(1) }; WriteByteSpan(stackalloc[] { (byte)1, (byte)2, (byte)3 }); Notice how the code is diverse depending on the type and the context. It is also verbose. Look at how we initialize an empty int array (second line); it’s lengthy and starkly contrasts with the previous line, where we initialize the same type with some actual values. In many situations, casting is needed; again, take a look at the WriteByteArray and WriteByteSpan calls. ...

May 10, 2024

C# 12 Primary Constructors

I wrapped up my C# 12 session at the ABP Dotnet Conference 2024, and I wanted to share the take-home points, at least about the most relevant features in this language version. Posting the slides made no sense as they were minimal; all the content was packed in the live demo. In a follow-up post, I plan to address Collection Expressions (done) and maybe “type any aliases”; this is about Primary Constructors. ...

May 9, 2024

I am speaking at ABP Dotnet Conf'24

I am thrilled to have the opportunity to present at an international conference once again. On May 9th, I will speak at the ABP Donet Conf'24. My session, titled C #12: What’s New and Interesting, is on a topic I’m passionate about. With the alignment of C# and Dotnet Core release cycles, the C# release cadence has increased (we’re on a yearly cycle now), while feature quantity has reduced for individual releases, which is good. The faster, smaller iterations allow for quicker course corrections, and introducing fewer new features makes it easier to embrace the changes. ...

April 15, 2024
Early in the morning at the Microsoft House in Milan. Preparations underway

Video of my C# 12 session at .NET Conference Italia 2023

The video and slides of my C# 12 session at .NET Conference Italia 2023 is finally available online. Unfortunately it’s just my voice and my laptop screen, and that’s too bad because the location was as cool as it can get, and the room was packed. It is in Italian1 and you need to login in order to see it (sorry, I don’t have control over it.) I also submitted to several international conferences; let’s see what happens. Since the COVID hiatus, I’ve had no luck with international events. ↩︎ ...

January 26, 2024

How to implement a PKCE code challenge in C#

Today’s fun was implementing OAuth2’s RFC 7636’s PKCE (Proof Key for Code Exchange) in C#. It’s relatively straightforward, but I decided to share my implementation should it be helpful to someone else out there. PKCE is an extension to the Authorization Code flow to prevent CSRF and authorization code injection attacks. [..] It was originally designed to protect the authorization code flow in mobile apps, but its ability to prevent authorization code injection makes it useful for every type of OAuth client, even web apps that use client authentication (source). ...

January 17, 2024

How to use XmlWriter along with StringWriter to properly serialize a UTF-8 string

Today, I (re)learned how to serialize an XML to a UTF-8 string. Like all the other times I did this, I got backstabbed by StringWriter, which only supports UTF-16. A simple code snippet like this: await using var sw = new StringWriter(); await using var w = XmlWriter.Create(sw, new() { Async = true }); ... await w.FlushAsync(); return sw.ToString(); Will emit this output: <?xml version="1.0" encoding="utf-16"?><... There’s nothing inherently wrong with UTF-16, but XML is usually UTF-8, so one must do something about it. StringWriter exposes an Encoding property, but it is read-only for unknown reasons. One might think that given that the XmlWriter allows setting its own Encoding value, something like this would work: ...

November 9, 2023

LINQ DistinctBy on a property for .NET Standard and older .NET versions

Today I learned how to implement a custom Enumerable.DistinctBy extension method that returns distinct elements from a sequence according to a specified key selector function. .NET 6 and its successors have the method built in within LINQ, but I needed it in a .NET Standard 2.0 class library, so I was out of luck. My implementation is simple, not different from others I found online, and should also work fine with old .NET releases. Here it is: ...

October 25, 2023