The .NET Stacks #17: EF Core 5, Blazor + CSS, and community!
EF Core 5 is done, Blazor CSS isolation, and more!
Just a reminder that in your methods, try to write less than 914 “using var” statements.
We’re talking about a lot of little things this week:
- EF Core 5 is done
- Blazor CSS isolation
- The curious case of unit testing
- September is F#-tember at The .NET Stacks
- Community links
EF Core 5 is done
This week, Arthur Vickers proclaimed that Entity Framework Core 5.0 is done, pending any issues or bug fixes. Arthur says the team has also spent the last two weeks squashing bugs, writing better exception messages, and improving the docs.
You can check out the official plan, but I’ll be looking forward to the following features:
- Many-to-many nav properties and full many-to-many support
- Table-per-type inheritance mapping
- Filtered includes and split includes
You can check out the daily builds today.
Blazor CSS isolation
With the latest .NET preview, the Blazor team released CSS isolation (among many other things). With limited documentation available, I wrote about it.
The gist: CSS isolation allows you to scope your CSS to your components. Instead of loading all your styles unnecessarily and incurring CSS bleed when dealing with multiple components and libraries, you can say: I only want these styles to be associated with my component. There’s a lot of flexibility, too—you can use the ::deep
combinator in your scoped CSS to pass styles down to child components and working with CSS preprocessors is a snap.
CSS isolation in Blazor is a build-time step—this means there’s no reliance on JavaScript or .NET code, you can easily integrate with existing tooling, and there’s no performance hit if you aren’t using it. However, this also means you’re forced to recompile to see any new CSS changes. This will force you into using dotnet watch
if you haven’t already—hitting F5 in Visual Studio every time is no way to go through life.
I’ll be writing the official Microsoft reference doc on it, so if you want anything covered that isn’t in my post or the GitHub issue for the doc, let me know.
The curious case of unit testing
My thinking on unit testing has been shifting a bit in the last six months or so. The timing couldn’t be better: I’m seeing a lot of chatter about unit testing both inside and outside of the .NET developer community.
Back in early July, Alexey Golub wrote a popular piece called Unit Testing is Overrated. It aligned with a lot of what I was thinking about—placing your primary focus on unit tests isn’t always valuable. This is not to say you shouldn’t value them, or champion them, or appreciate them. Quite the opposite. It’s when we decouple so much while saying “we need to make the code testable” where, in the end, the only value is to make unit testing work. In the end, are we just testing our mocks?
Instead of spending a ridiculous amount of time setting up mocks that don’t replicate much of a complex software system, why not rely more on integration tests? This opinion would be blasphemy just ten (or even five) years ago. After all, unit tests should be quick, repeatable, and pure (no side effects). With the rise of containerization and better cloud infrastructure, the “integration tests are slow and flaky” argument is less of an issue.
To that end: last month, Khalid Abuhakmeh wrote Secrets of a .NET Professional, in which he writes this (which led to a spirited Twitter discussion):
The systems we build have many complex external dependencies. The hubris of thinking we could mock away decades of investment in a database, web service, or any other technology has been the source of many frustrating arguments. In my opinion, one good integration test is worth 1,000 unit tests… With the rise of containerization, the pain of writing integration tests has never been lower.
For me, my thought is that unit testing is crucial for testing and verifying core (and pure) business logic. But you need to test against your dependencies, and many times the best bang for your buck comes with integration testing—as long as the tests are reasonably fast and cheap. As for me, I’m no longer obsessing over testing every single layer of an MVC app (as an aside, Andrew Lock wrote a nice post that questions the value of unit testing APIs and MVC controllers).
Our industry gets dogmatic, so opinions like these can get heated. But to me, it doesn’t really seem like a controversial opinion to take a nuanced approach to testing so we can find the most value in our hectic days. Containerization has revolutionized our industry—so let’s take advantage of it.
September is F#-tember at The .NET Stacks
Do you work in F#? Or are you a C# developer and intrigued by its possibilities but haven’t found time to dive in? As C# has “borrowed” a lot of functional programming paradigms, you might be wondering about tradeoffs between C# “with functional bits” and straight F#. I’ve got you covered.
Next week, I’m interviewing Isaac Abraham, author of Get Programming with F#. Soon after, I’ll post an interview with Phillip Carter, the PM for F# at Microsoft. Stay tuned for some great conversations.
🌎 Last week in the .NET world
🔥 The Top 3
- Michael Shpilt discusses assembly versioning and “DLL hell” in .NET.
- The .NET Docs Show talks with Jon Skeet.
- Andrew Lock continues his k8s series: this time, configuring resources with YAML manifests.
📢 Announcements
- Nish Anil announces a free e-book on Blazor for ASP.NET Web Forms developers.
- Timothé Larivière introduces Fabulous, an OSS framework for mobile and desktop apps using functional programming.
- Pierre Boulay discusses how in the latest Windows Insider build, you can attach and mount a physical disk inside WSL 2.
- GitHub announced an integration with Microsoft Teams.
- Rahul Bhandari announces the release of the .NET Core September 2020 security update, and Tara Overfield announces the September 2020 security and quality updates for .NET Framework.
- The .NET Docs team shows off what’s new from the month of August.
- Visual Studio Codespaces is consolidating into GitHub Codespaces.
📅 Community and events
We had three community standups: Languages & Runtime explores miscellaneous topics, Machine Learning talks SciSharp, and ASP.NET talks about Microsoft.Identity.Web.
😎 Blazor
- Dave Brock (ahem) walks through CSS isolation in Blazor.
- Peter Vogel compares performance options among Telerik DataGrid, JavaScript, and Blazor, and also works with local storage in a Blazor PWA.
- Karl Shifflett works with a Blazor WASM GraphQL client.
- Julio Sampaio gets started with Blazor.
🚀 .NET Core
- Nickolas Fisher uses Okta to migrate an ASP.NET Framework to ASP.NET Core.
- Vladimir Pecanac creates a custom config provider in ASP.NET Core.
- David Grace asks: is Entity Framework Core quicker than Dapper?.
- Michał Białecki works with views in EF Core 5.
- Tomasz Pęczek works with HTTP trailers in ASP.NET Core.
- Mark Heath migrates from ASP.NET to ASP.NET Core.
⛅ The cloud
- Damien Bowden secures Azure Functions using an Azure virtual network.
- Seth Juarez fixes mixed-content and CORS issues at ML Model inference time with Azure Functions.
- Jason Farrell continues his work on Azure Durable Functions.
- Siva Ramani and Naveen Balaraman deploy a .NET Core Web API container to Amazon EKS.
- Jamie Maguire adds speech to a chatbot using the Bot Framework and Azure Speech Services.
📔 Languages
- Patrick Lioi talks about evolving an open source test framework with .NET.
- Suresh M talks about understanding C# anonymous types.
- Lawrence Hecht talks about how Visual Basic is lingering on.
- Thomas Claudius Huber discusses target-typed new expressions in C# 9.
- Andrew Nosenko works on async subroutines with C# 8 and IAsyncEnumerable.
🔧 Tools
- Ian Miell talks about the many ways to undo a commit in Git.
- Matthew Jones uses a Dapper base repository in C#.
- ErikEJ uses EF Core Power Tools to rename entities and properties when reverse engineering a database.
- Jason Gaylord adds Azure architecture icons to diagrams.
- Adam Storr uses Project Tye to run dependent services with ASP.NET Core.
📱 Xamarin
- Jean-Marie Alfonsi walks through the TaskLoaderCommand.
- Vicente Gerardo Guzmán Lucio creates custom renderers for a control.
- James Montemagno quickly discusses modal navigation.
🎤 Podcasts
- The .NET Rocks podcast gets started with Xamarin.
- The Xamarin Podcast talks about the Surface Duo, Android startup times, and Xamarin.Essentials.
- The RunAsRadio podcast gets snarky about the cloud with Corey Quinn.
- The Stack Overflow Podcast discusses how developers can become successful writers.
- The Merge Conflict podcast discusses Blazor.
- The .NET Core Podcast talks about IoT and .NET Core with Pete Gallagher.
- The Loosely Coupled Show talks about loosely-coupled monoliths.
🎥 Videos
- The Visual Studio Toolbox talks about the new Git experience.
- Data Exposed talks about Azure SQL Edge, and also works with Power BI and Azure Synapse.
- At the Maintainers, Shawn Wildermuth talks with Dennis Doomen about FluentAssertions.
- The AI Show discusses OSS framework support in the Azure Machine Learning service.
- The ON.NET Show uses .NET microservices with Steeltoe.