The .NET Stacks #54: 🎀 Putting a bow on .NET 6 date and time updates
Tags: dotnet, azure, csharp
Published: 2021-06-21 13:15:56

---
title: The .NET Stacks #54: 🎀 Putting a bow on .NET 6 date and time updates
published: true
date: 2021-06-20 15:30:00 UTC
tags: dotnet,azure,csharp
canonical_url: https://www.daveabrock.com/2021/06/20/dotnet-stacks-54/
---

_NOTE: This is the web version of my weekly newsletter, released on June 14, 2021. To get the issues right away, subscribe at_ [_dotnetstacks.com_](https://dotnetstacks.com/) _or the bottom of this post._

Happy Monday! Here's what's going on this week:

- **The big thing**: Putting a bow on .NET 6 date and time updates
- **The little things**: Have I Been Pwned project updates, VS Code remote repositories extension, App Service support on .NET 6, Azure Functions updates
- Last week in the .NET world

* * *

## The big thing: Putting a bow on .NET 6 date and time updates

In a previous issue, we briefly spent some time exploring the new date and time APIs in .NET 6. (Despite feedback of the cringy title, I stand behind _[DateTime might be seeing other people](https://www.daveabrock.com/2021/04/03/dotnet-stacks-43/)_.) In these posts, I passed along the information from various GitHub issues. This week, it was nice to see Matt Johnson-Pint officially [write about it in detail on the .NET Blog](https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/).

Here's the gist: the .NET team is rolling out _new_ `DateOnly` and `TimeOnly` types for .NET 6.

The `DateOnly` type, if you can believe it, only supports a date—like a year or a month. You might want to use this when you don't need an associated time, like birthdays and anniversaries. With `DateOnly` Microsoft promises better type safety when you only want dates, serialization improvements, and simplicity when interacting with databases. `DateOnly` ships with a robust constructor but no deconstructor.

As for `TimeOnly`, you'd use it only to represent a time of day. Potential use cases are alarm clock times, when a business is open, or recurring appointment times. Why not `TimeSpan`? Here, `TimeOnly` is intended for a time of day and not elapsed time. Again, you'll gain type safety and more accuracy when calculating ranges.

There's a lot of chatter in the community asking: why not use Noda Time instead? From the post:

> Noda Time is a great example of a high-quality, community developed .NET open source library ... However, we didn’t feel that implementing a Noda-like API in .NET itself was warranted. After careful evaluation, it was decided that it would be better to _augment_ the existing types to fill in the gaps rather than to overhaul and replace them. After all, there are many .NET applications built using the existing `DateTime`, `DateTimeOffset`, `TimeSpan`, and `TimeZoneInfo` types. The `DateOnly` and `TimeOnly` types should feel natural to use along side them.

As an FYI, the new structs aren't supported in Entity Framework Core 6 yet, but [you can check out this comment](https://github.com/dotnet/runtime/issues/49036#issuecomment-806444260) to find a relevant tracking issue. You'll want to check out the post—in addition to the new `DateOnly` and `TimeOnly` structs, the .NET team is rolling out time zone enhancements as well.

These changes aren't replacing any `DateTime` APIs, just augmenting them. So when it comes time for you to switch to .NET 6, do what works for you.

* * *

## The little things: Have I Been Pwned project updates, VS Code remote repositories extension, Azure Functions updates, App Service support on .NET 6

This week, we'll talk about Have I Been Pwned, a new Visual Studio Code extension, and updates on running Azure Functions and Azure App Service updates on .NET 6.

### Have I Been Pwned project updates

You've likely heard of Troy Hunt's [Have I Been Pwned project](https://haveibeenpwned.com/). At the risk of oversimplifying all that Troy does, you can use it to check if your personal data has been compromised by data breaches. With the help of Cloudflare and Azure Functions, he's been able to operate [at a tremendous scale with minimum cost](https://www.troyhunt.com/serverless-to-the-max-doing-big-things-for-small-dollars-with-cloudflare-workers-and-azure-functions/). That site is now getting [around 1 billion requests a month](https://twitter.com/troyhunt/status/1397727343167250433?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1397727343167250433%7Ctwgr%5E%7Ctwcon%5Es1_&ref_url=https%3A%2F%2Fwww.troyhunt.com%2Fpwned-passwords-open-source-in-the-dot-net-foundation-and-working-with-the-fbi%2F).

Last August, Troy announced [his plans to take HIBP to open source](https://www.troyhunt.com/im-open-sourcing-the-have-i-been-pwned-code-base/). Recently, Troy wrote that the Pwned Passwords component [is now a .NET Foundation project](https://www.troyhunt.com/pwned-passwords-open-source-in-the-dot-net-foundation-and-working-with-the-fbi/).  You can check out the code [at the HaveIBeenPwned organization on GitHub](https://github.com/HaveIBeenPwned/). As a .NET developer, it's a nice way to look at the code and how it all works, especially when it comes to getting hashes and anonymizing requests.

### VS Code remote repositories extension

In this space last week, [we mentioned](https://www.daveabrock.com/2021/06/13/dotnet-stacks-53/) a new VS Code extension for Project Tye. Visual Studio Code is at it again with [a new Remote Repositories extension](https://code.visualstudio.com/blogs/2021/06/10/remote-repositories?WT.mc_id=devcloud-00000-cxa). With this extension, you can browse, search, edit, and commit to any remote GitHub repository without a clone. This extension will support Azure DevOps soon as well. (GitHub is the long-term vision, yet Microsoft is consistently releasing these new capabilities to Azure DevOps. For this and other reasons, I'm pretty sure Azure DevOps will outlive _me_.)

Personally, looking at GitHub repos is good for my learning—both for what to do and what not to do—and there should be a middle ground between browsing g_ithub.com_ and cloning a big repository to my machine. This should help.

### Azure Functions updates

Last week, Azure Functions PM Anthony Chu wrote about recent Azure Functions updates. (I'll be interviewing him soon here, so hit me up if you have any other questions.) We've written about some of what he mentioned, but not everything—here's the latest.

- **Visual Studio support for .NET 5.0 isolated function apps** : Released in May, Visual Studio 2019 16.10 includes full support for .NET 5.0 isolated process Azure Functions apps. You can [check out the tutorial](https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-developer-howtos?tabs=browser&pivots=development-environment-vs).
- **You can run .NET 6 on Azure Functions** : To do this, you'll need Azure Functions V4—right now, it's limited to a preview release of Azure Functions Core Tools V4. Check out the post, as there are a few caveats to keep in mind. It's early, and there's no official support yet. Microsoft [has published a tutorial](https://aka.ms/functions-dotnet6earlypreview-wiki) on writing .NET 6 apps on Azure Functions.

### Azure App Service support on .NET 6

In somewhat related Azure development news, [you can use .NET 6 Preview bits on Azure App Service](https://azure.github.io/AppService/2021/06/09/Dot-Net-6-Preview-on-App-Service.html)—in either Windows or Linux workloads. You can do this through the Azure App Service [Early Access Runtime feature](https://github.com/Azure/app-service-linux-docs/blob/master/Runtime_Support/early_access.md). This feature allows you to get the latest version of SDKs for various languages. With Early Access Runtime, you can get access without waiting for a release cycle.

Microsoft is boasting that it's the first time a pre-release stack is publicly available on App Service before the GA release.

* * *

## 🌎 Last week in the .NET world

We've got another busy week with some great content from the developer community.

### 🔥 The Top 5

- Matt Johnson-Pint [writes about Date, Time, and Time Zone Enhancements in .NET 6](https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6).
- Claudio Bernasconi [works on Blazor component communication and state handling](https://www.claudiobernasconi.ch/2021/06/07/blazor-component-communication-state-handling/).
- Leomaris Reyes [uses Maps with Xamarin Essentials](https://askxammy.com/simple-way-to-use-maps-with-xamarin-essentials/).
- Microsoft announces [the new Remote Repositories extension for Visual Studio Code](https://code.visualstudio.com/blogs/2021/06/10/remote-repositories).
- Joseph Guadagno [migrates to ASP.NET Core MVC from ASP.NET Framework MVC](https://www.telerik.com/blogs/migrate-aspnet-core-mvc-aspnet-framework-mvc).

### 📅 Community and events

- For community standups: ASP.NET [talks about Blazor updates](https://www.youtube.com/watch?v=8xLw-f1iFLw), and Machine Learning [holds office hours](https://www.youtube.com/watch?v=cLtOQuaqtoQ).
- The .NET Docs Show talks to Niels Swimberghe about [making calls with Twilio and Blazor WebAssembly](https://www.youtube.com/watch?v=e8DX7HdSmkU).
- Troy Hunt [expands the Have I Been Pwned volunteer community](https://www.troyhunt.com/expanding-the-have-i-been-pwned-volunteer-community/).

### 🌎 Web development

- The Code Maze blog [uses Hangfire with ASP.NET Core](https://code-maze.com/hangfire-with-asp-net-core/).
- Matthew Jones [starts developing a solitaire game in Blazor](https://exceptionnotfound.net/solitaire-in-blazor-part-1-overview/).
- Adam Storr [extends HttpClient testing with templating](https://adamstorr.azurewebsites.net/blog/extending-httpclient-testing-with-templating).
- Bruno Sonnino [explores Minimal APIs in ASP.NET Core](https://blogs.msmvps.com/bsonnino/2021/06/05/lightweight-web-api-int-asp-net-with-featherhttp/).
- Andrea Chiarelli [builds ASP.NET CRUD Web APIs](https://auth0.com/blog/building-aspnet-web-api/).
- Damien Bowden [explores integration testing for ASP.NET Core using EF Core Cosmos with XUnit and Azure DevOps](https://damienbod.com/2021/06/10/integration-testing-for-asp-net-core-using-ef-core-cosmos-with-xunit-and-azure-devops/).
- Dave Brock [writes about minimal APIs in .NET 6](https://www.telerik.com/blogs/low-ceremony-high-value-tour-minimal-apis-dotnet-6).

### 🥅 The .NET platform

- Jonathan Allen [writes about .NET 6 collections improvements](https://www.infoq.com/news/2021/06/Net6-Collections/).
- Richard Lander [hosts a conversation about containers](https://devblogs.microsoft.com/dotnet/conversation-about-containers).
- Andrew Lock [explores .NET interactive notebooks with VS Code](https://andrewlock.net/exploring-dotnet-interactive-notebooks/).
- Patrick Smacchia [recaps .NET obfuscator tools](https://blog.ndepend.com/in-the-jungle-of-net-obfuscator-tools/).
- John Miller [develops apps for Microsoft Teams with .NET](https://devblogs.microsoft.com/visualstudio/build-apps-for-microsoft-teams-with-net).
- Abhijit Jana [works with command-line arguments and C# 9.0 top-level statements with Visual Studio](https://dailydotnettips.com/command-line-arguments-and-c-9-0-top-level-statement-visual-studio/).

### ⛅ The cloud

- Anthony Chu [writes about what's new with .NET on Azure Functions](https://techcommunity.microsoft.com/t5/apps-on-azure/what-s-new-with-net-on-azure-functions-june-2021/ba-p/2428669).
- Chris Noring [builds apps locally with the Azure Static Web Apps CLI](https://dev.to/azure/azure-static-web-apps-cli-building-apps-locally-3968).
- Dominique St-Amand [works on a CosmosDB Linux container for your CI builds](https://www.domstamand.com/cosmosdb-linux-container-for-your-ci-builds/).
- Shelton Graves [continues his series on working with events in Azure](https://techcommunity.microsoft.com/t5/apps-on-azure/event-driven-on-azure-part-2-architecting-event-driven/ba-p/2414007?WT.mc_id=DOP-MVP-4025064).

### 📔 Languages

- Matthew MacDonald [previews 5 new features in C# 10](https://medium.com/young-coder/a-closer-look-at-5-new-features-in-c-10-f99738b0158e).
- Davide Bellone [writes about how to get the index of an item in a foreach loop](https://www.code4it.dev/csharptips/how-to-get-item-index-in-foreach).
- Ken Bonny [rediscovers implicit casting](https://kenbonny.net/rediscovering-implicit-casting).

### 🔧 Tools

- Anant Vernekar [integrates Swagger With ASP.NET Core Using Entity Framework](https://www.c-sharpcorner.com/article/integrating-swagger-with-web-api-net-core-using-entity-framework/).
- Khalid Abuhakmeh [writes about JetBrains Rider plugins for ASP.NET Core developers](https://blog.jetbrains.com/dotnet/2021/06/08/must-have-jetbrains-rider-plugins-for-asp-net-core-developers/) and [how to import settings from Visual Studio and VS Code to Rider](https://blog.jetbrains.com/dotnet/2021/06/10/import-settings-from-visual-studio-and-vs-code-to-rider/).
- Wael Kdouh [automates deployments of Azure Logic App Using Azure DevOps](https://waelkdouh.medium.com/automating-deployment-of-azure-logic-app-using-azure-devops-c83d2161097f).
- Jon Gallant [uses the GitHub CLI and Git with GitHub Codespaces](https://blog.jongallant.com/2021/06/codespaces-gh-cli-git-credentials/).
- David Ramel [writes about Rider's improvements with Blazor WebAssembly debugging](https://visualstudiomagazine.com/articles/2021/06/10/rider-webassembly-debugging.aspx).
- Lauren Del Signore [writes about useful Visual Studio extensions for working with Blazor](https://www.grapecity.com/blogs/useful-visual-studio-extensions-blazor).

### 🏗 Design, testing, and best practices

- Al Tenhundfeld [asks: what makes a good Git commit?](https://www.simplethread.com/what-makes-a-good-git-commit/)
- Mark Hinkle asks: [has serverless jumped the shark?](https://thenewstack.io/has-serverless-jumped-the-shark/)
- Steve Smith [writes about C# generics best practices](https://ardalis.com/csharp-generics-best-practices/).
- Joydip Kanjilal [writes about best practices for designing RESTful APIs](https://www.developer.com/web-services/best-practices-restful-api/).

### 🎤 Podcasts

- The 6-Figure Developer Podcast [talks to Guy Royse about Redis](https://6figuredev.com/podcast/episode-199-redis-with-guy-royse/).
- The Adventures in .NET Podcast [talks about Uno Platform](https://devchat.tv/adventures-in-dotnet/uno-platform-isnt-a-card-game-net-072/).
- The Xamarin Podcast [talks about .NET MAUI](https://www.xamarinpodcast.com/94).
- Jesse Liberty [talks to Jeff Fritz about Blazor and Azure](http://jesseliberty.com/2021/06/05/jeff-fritz-on-blazor-azure-much-more/).
- .NET Rocks [talks to Jeremy Miller about event sourcing](https://www.dotnetrocks.com/default.aspx?ShowNum=1743).
- The Coding Blocks Podcast [continues talking about the DDIA book](https://www.codingblocks.net/podcast/designing-data-intensive-applications-single-leader-replication/).

### 🎥 Videos

- The ASP.NET Monsters [work on local development with Azure Static Web Apps](https://www.youtube.com/watch?v=apwB2U4cKfU).
- On .NET [talks to Scott Addie about feature flags and Azure App Configuration in .NET](https://channel9.msdn.com/Shows/On-NET/Feature-flags-with-NET-and-Azure-App-Configuration), [sets up observability in Orleans](https://dev.to/dotnet/on-net-episode-setting-up-observability-in-orleans-2dja), [talks to Ed Charbeneau about Blazor components](https://www.youtube.com/watch?v=Q4D5NffKTIk), and [discusses nullable reference types](https://www.youtube.com/watch?v=bXsOOpWavp4).