<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dave Brock</title>
    <description>The latest articles on DEV Community by Dave Brock (@daveabrock).</description>
    <link>https://dev.to/daveabrock</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4834%2Fc730fed4-6bef-4634-bb73-e213094d2735.jpg</url>
      <title>DEV Community: Dave Brock</title>
      <link>https://dev.to/daveabrock</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daveabrock"/>
    <language>en</language>
    <item>
      <title>Don't Do That, Do This: The .NET 6 Edition</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Wed, 08 Dec 2021 14:28:47 +0000</pubDate>
      <link>https://dev.to/daveabrock/dont-do-that-do-this-the-net-6-edition-2oei</link>
      <guid>https://dev.to/daveabrock/dont-do-that-do-this-the-net-6-edition-2oei</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is my annual contribution to the&lt;/em&gt; &lt;a href="https://www.csadvent.christmas/"&gt;&lt;em&gt;2021 C# Advent Calendar&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. Please check out all the great posts from our wonderful community!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Have you heard? .NET 6 &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6/"&gt;has officially arrived&lt;/a&gt;. There's a lot of good stuff: C# 10, performance improvements, Hot Reload, Minimal APIs, and much more. As is the case for most releases, a few big features tend to get most of the hype.&lt;/p&gt;

&lt;p&gt;What about the features and improvements that don't knock &lt;em&gt;both&lt;/em&gt; your socks off but also help to make your daily development experience more productive? A lot of these "quality of life" features in .NET 6 can help by removing boilerplate and pain and can help you get to the point: shipping quality software.&lt;/p&gt;

&lt;p&gt;As I get into the holiday spirit, consider this a stocking of sorts: just some random, little things that I hope you'll find enjoyable. (And despite the catchy title, there are always tradeoffs: do what works for you.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't chunk large collections manually, use the new LINQ API instead
&lt;/h2&gt;

&lt;p&gt;When working with large collections of data, you likely need to work with smaller "chunks" of it—a big use case would be if you're getting a lot of data back from a third-party API. If there's no pagination set up and you have a bunch of data in memory, you'll probably want a way to "page" or split up the data.&lt;/p&gt;

&lt;p&gt;What's a .NET developer to do? Do things the hard way. You'd probably do some logic to set a page size, check what page you're on and if there are any elements left, then update your code when you add pages to a collection. It'd be a series of &lt;code&gt;Take&lt;/code&gt; and &lt;code&gt;Skip&lt;/code&gt; LINQ calls, or maybe even an extension method, like &lt;a href="https://stackoverflow.com/questions/438188/split-a-collection-into-n-parts-with-linq/438513#438513"&gt;this one that's popular on Stack Overflow&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LinqExtensions&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;splits&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;
                     &lt;span class="k"&gt;group&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++&lt;/span&gt; &lt;span class="p"&gt;%&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;
                     &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AsEnumerable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;splits&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't do that, do this: use the new LINQ &lt;code&gt;Chunk&lt;/code&gt; API. When we call &lt;code&gt;Chunk&lt;/code&gt; on 200 elements, we'll get 20 lists of 10 elements each.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;pageSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Employee&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;]&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;employeeChunk&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pageSize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  If you need just a date, don't use DateTime, use DateOnly
&lt;/h2&gt;

&lt;p&gt;If you want to work with dates and times in .NET, you typically start with &lt;code&gt;DateTime&lt;/code&gt;, &lt;code&gt;TimeSpan&lt;/code&gt;, or &lt;code&gt;DateTimeOffset&lt;/code&gt;. What if you only need to work with dates and only need a year, month, or day? In .NET 6, you can use a new &lt;code&gt;DateOnly&lt;/code&gt; struct. (You can also use &lt;code&gt;TimeOnly&lt;/code&gt;. I also promise this isn't the &lt;a href="https://www.farmersonly.com/"&gt;start of a dating app&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;We've all done something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;someDateTime&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2014&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;24&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;justTheDate&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;someDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToShortDateString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;someDateTime&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 8/24/2014 12:00:00 AM&lt;/span&gt;
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;justTheDate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "8/24/2014"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't do that, do this: use the &lt;code&gt;DateOnly&lt;/code&gt; struct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;someDateTime&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;DateOnly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2014&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;24&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;justTheDate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 8/24/2014&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's &lt;a href="https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/"&gt;a lot more you can do with these&lt;/a&gt;, obviously, in terms of manipulation, calculation days between dates, and even combining with &lt;code&gt;DateTime&lt;/code&gt;. Apart from being easier to work with, it also offers better type safety for just dates, a &lt;code&gt;Kind&lt;/code&gt; property, and simpler serialization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't wire up a lot of custom code for logging HTTP requests, use the new logging middleware
&lt;/h2&gt;

&lt;p&gt;Before .NET 6, logging HTTP requests wasn't hard but a little cumbersome. Here's one way: you'd probably have logic to read the request body, use your expert knowledge of ASP.NET Core middleware to pass the stream to whatever is next on the pipeline, and remember to register your middleware—all for a very common activity for any reasonably complex web application.&lt;/p&gt;

&lt;p&gt;Don't do that, do this: use the new .NET 6 &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-logging/?view=aspnetcore-6.0"&gt;HTTP Logging middleware&lt;/a&gt; to make your life easier.&lt;/p&gt;

&lt;p&gt;Add this to your project's middleware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IWebHostEnvironment&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseHttpLogging&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// other stuff here, removed for brevity&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, customize the logger as you see fit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConfigureServices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IServiceCollection&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHttpLogging&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoggingFields&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpLoggingFields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;All&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Request-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Response-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll want to be watchful of what you log and how often you log it, but it's a great improvement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't use hacks to handle fatal Blazor Server exceptions, use the ErrorBoundary component
&lt;/h2&gt;

&lt;p&gt;What happens when an unhandled exception in Blazor Server occurs? It's treated as fatal because "&lt;a href="https://github.com/dotnet/aspnetcore/issues/30940#issue-831895900"&gt;the circuit is left in an undefined state which could lead to stability or security problems in Blazor Server&lt;/a&gt;." As a result, you might need to throw try/catch blocks all over the place as a preventive measure or encapsulate logic in JavaScript since no C# code runs after the unhandled exception.&lt;/p&gt;

&lt;p&gt;Don't do that, do this: &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/handle-errors?view=aspnetcore-6.0"&gt;use the new &lt;code&gt;ErrorBoundary&lt;/code&gt; component&lt;/a&gt;. It isn't a global exception handler but will help deal with unpredictable behavior, especially with components you don't and can't control.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://www.telerik.com/blogs/work-unhandled-exceptions-gracefully-blazor-server-dotnet-6-error-boundaries"&gt;see my article&lt;/a&gt; for the full treatment, but here's the gist: I can add an &lt;code&gt;ErrorBoundary&lt;/code&gt; around the &lt;code&gt;@Body&lt;/code&gt; of my default layout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"main"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"content px-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;ErrorBoundary&amp;gt;&lt;/span&gt;
            @Body
        &lt;span class="nt"&gt;&amp;lt;/ErrorBoundary&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, you probably want to go further than a catch-all boundary. Here's me iterating through a list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
    @foreach (var employee in Employees)
    {
        &lt;span class="nt"&gt;&amp;lt;ErrorBoundary&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"@board"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;ChildContent&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@employee.Id&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@employee.FirstName&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@employee.LastName&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
                 &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/ChildContent&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;ErrorContent&amp;gt;&lt;/span&gt;
                Sorry, I can't show @employee.Id because of an internal error.
            &lt;span class="nt"&gt;&amp;lt;/ErrorContent&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/ErrorBoundary&amp;gt;&lt;/span&gt;
    }
&lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Don't use Server.Kestrel verbose logging for just a few things, use the new subcategories
&lt;/h2&gt;

&lt;p&gt;If I want to enable verbose logging for Kestrel, I'd previously need to use &lt;code&gt;Microsoft.AspNetCore.Server.Kestrel&lt;/code&gt;. That still exists, but there are also &lt;a href="https://github.com/dotnet/aspnetcore/issues/30301"&gt;new subcategories&lt;/a&gt; that should make things less expensive. (Computationally; you're still on the hook for holiday gifts, sorry.)&lt;/p&gt;

&lt;p&gt;In addition to &lt;code&gt;Server.Kestrel&lt;/code&gt;, we now have &lt;code&gt;Kestrel.BadRequests&lt;/code&gt;, &lt;code&gt;Kestrel.Connections&lt;/code&gt;, &lt;code&gt;Kestrel.Http2&lt;/code&gt;, and &lt;code&gt;Kestrel.Http3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's say you only want to log bad requests. You'd normally do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Logging"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"LogLevel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Microsoft.AspNetCore.Server.Kestrel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Debug"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't do that. Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Logging"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"LogLevel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Microsoft.AspNetCore.Server.Kestrel.BadRequests"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Debug"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is it the sexiest thing you'll read today? Unless you love logging more than I thought you did, probably not. But it'll definitely make working with Kestrel verbose logging much easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't get lost in brackets, use C# 10 file-scoped namespaces instead
&lt;/h2&gt;

&lt;p&gt;C# 10 introduces the concept of &lt;a href="https://www.daveabrock.com/2021/10/05/csharp-10-file-scoped-namespaces/"&gt;file-scoped namespaces&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's a typical use of namespaces in C#:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of downloading a bracket colorizer extension, do this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, for the record (ha!), you can make this even simpler if you want to take advantage of &lt;a href="https://www.daveabrock.com/2020/07/06/c-sharp-9-deep-dive-records/"&gt;immutability and value-like behavior&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be aware of what you're getting with &lt;a href="https://www.daveabrock.com/2020/11/02/csharp-9-records-immutable-default/"&gt;positional parameters&lt;/a&gt;, but we can all agree this isn't your grandma's C# (and I'm here for &lt;em&gt;all&lt;/em&gt; of it, my apologies to grandma).&lt;/p&gt;

&lt;h3&gt;
  
  
  Speaking of brackets ...
&lt;/h3&gt;

&lt;p&gt;Since we're on the topic of brackets, C# 10 also introduces &lt;a href="https://www.daveabrock.com/2021/11/18/exploring-c-10-use-extended-property-patterns-to-easily-access-nested-properties/"&gt;e&lt;/a&gt;&lt;a href="https://www.daveabrock.com/2021/11/18/exploring-c-10-use-extended-property-patterns-to-easily-access-nested-properties/"&gt;xtended property patterns&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You could use property patterns in a switch expression like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSuitSurcharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;

        &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Blue"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yellow"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't do that. Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSuitSurcharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;

        &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Blue"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yellow"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I hope you enjoyed this post, and you learned a thing or two about how .NET 6 can make your developer life just a little bit easier. Have you tried any of these? Do you have others to share? Let me know in the comments &lt;a href="https://twitter.com/daveabrock"&gt;or on Twitter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>.NET 6 Has Arrived: Here Are A Few of My Favorite Things</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Fri, 03 Dec 2021 12:59:58 +0000</pubDate>
      <link>https://dev.to/daveabrock/net-6-has-arrived-here-are-a-few-of-my-favorite-things-3kfh</link>
      <guid>https://dev.to/daveabrock/net-6-has-arrived-here-are-a-few-of-my-favorite-things-3kfh</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published on the &lt;a href="https://www.telerik.com/blogs/dotnet-6-arrived-here-few-my-favorite-things"&gt;Telerik Developer Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For the second straight November, .NET developers have received an early holiday gift: &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6/"&gt;a new release of the .NET platform&lt;/a&gt;. Last month, Microsoft made .NET 6 generally available—and &lt;a href="https://www.youtube.com/playlist?list=PLdo4fOcmZ0oVFtp9MDEBNbA2sSqYvXSXO"&gt;hosted a virtual conference&lt;/a&gt; to celebrate its new features.&lt;/p&gt;

&lt;p&gt;What were the goals of .NET 6? If you look at &lt;em&gt;&lt;a href="https://themesof.net/query"&gt;themesof.net&lt;/a&gt;&lt;/em&gt;, you can quickly see the themes of the .NET 6 release, which include some of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Appeal to net-new devs, students, and new technologists&lt;/li&gt;
&lt;li&gt;Improve startup and throughput using runtime exception information&lt;/li&gt;
&lt;li&gt;The client app development experience&lt;/li&gt;
&lt;li&gt;Recognized as a compelling framework for cloud-native apps&lt;/li&gt;
&lt;li&gt;Improve inner-loop performance for .NET developers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We could spend the next ten blog posts writing about all the new .NET 6 improvements and features. I'd love to do that, but I haven't even &lt;em&gt;started&lt;/em&gt; shopping for the holidays. Instead, I'd like to show off some of my favorite things that I'll be using on my .NET 6 projects. Most of these changes revolve around &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-asp-net-core-in-net-6/"&gt;web development in ASP.NET Core 6&lt;/a&gt; since this site focuses on those topics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hot Reload
&lt;/h2&gt;

&lt;p&gt;Way &lt;a href="https://www.telerik.com/blogs/instant-feedback-is-here-introducing-hot-reload-in-dotnet-6"&gt;back in April&lt;/a&gt;, I wrote here about the Hot Reload capability in .NET 6. We've come a long way since then, but I felt the same as I do now: this is the biggest boost to a .NET web developer's productivity over the last few years. If you aren't familiar with Hot Reload, let's quickly recap.&lt;/p&gt;

&lt;p&gt;The idea of "hot reload" has been around for quite a few years: you save a file, and the change appears almost instantaneously. Once you work with hot reloading, it's tough to go back. As the .NET team tries to attract outsiders and new developers, not having this feature can be a non-starter to outsiders: it's table stakes for many developers. The concept is quite popular in the front-end space and .NET developers have been asking for this for a while. (Admittedly, introducing hot reload to a statically typed language is much more complex than doing it for a traditionally interpreted language like JavaScript.)&lt;/p&gt;

&lt;p&gt;With .NET 6, you can use Hot Reload to make changes to your app without needing to restart or rebuild it. Hot Reload doesn't just work with static content, either—it works with most C# use cases and also preserves the state of your application as well—but you'll want to hit up the Microsoft Docs to learn about &lt;a href="https://docs.microsoft.com/en-us/visualstudio/debugger/supported-code-changes-csharp?view=vs-2022"&gt;unsupported app scenarios&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's a quick example to show how the application state gets preserved in a Blazor web app. If I'm in the middle of an interaction and I update the &lt;code&gt;currentCount&lt;/code&gt; from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;10&lt;/code&gt;, will things reset? No! Notice how I can continue increasing the counter, and then my counter starts at 10 when I refresh the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P-L-NdJO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.daveabrock.com/content/images/2021/11/hr-preserve-state.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P-L-NdJO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.daveabrock.com/content/images/2021/11/hr-preserve-state.gif" alt="" width="880" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can leverage Hot Reload in whatever way you prefer: powerful IDEs like &lt;a href="https://blog.jetbrains.com/dotnet/2021/10/25/hot-reload-for-net-6-in-rider-2021-3/"&gt;JetBrains Rider&lt;/a&gt; and &lt;a href="https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights/#improved-user-experience-in-visual-studio-2022"&gt;Visual Studio 2022&lt;/a&gt; have this capability. You can also utilize it from the command line if you prefer (yes, &lt;a href="https://devblogs.microsoft.com/dotnet/net-hot-reload-support-via-cli/"&gt;we do&lt;/a&gt;). It's important to mention that this works for all ASP.NET Core Web apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimal APIs
&lt;/h2&gt;

&lt;p&gt;Have you ever wanted to write simple APIs in ASP.NET Core quickly but felt helpless under the bloat of ASP.NET Core MVC, wishing you could have an &lt;a href="http://expressjs.com/en/starter/hello-world.html"&gt;Express-like model&lt;/a&gt; for writing APIs?&lt;/p&gt;

&lt;p&gt;The ASP.NET team has rolled out minimal APIs—a new, simple way to build small microservices and HTTP APIs in ASP.NET Core. Minimal APIs hook into ASP.NET Core's hosting and routing capabilities and allow you to build fully functioning APIs with just a few lines of code. Minimal APIs do not replace building APIs with MVC—if you are building complex APIs or prefer MVC, you can keep using it as you always have—but it's an excellent approach to writing no-frills APIs. We &lt;a href="https://www.telerik.com/blogs/low-ceremony-high-value-tour-minimal-apis-dotnet-6"&gt;wrote about it in June&lt;/a&gt;, but things have evolved &lt;em&gt;a lot&lt;/em&gt; since then. Let's write a simple API to show it off.&lt;/p&gt;

&lt;p&gt;First, the basics: thanks to lambdas, top-level statements, and C# 10 global usings, this is all it takes to write a "Hello, Telerik!" API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;"Hello, Telerik!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, we'll want to get past the basics. How can I &lt;em&gt;really&lt;/em&gt; use it? Using &lt;code&gt;WebApplication&lt;/code&gt;, you can add middleware just like you previously would in the &lt;code&gt;Configure&lt;/code&gt; method in &lt;code&gt;Startup.cs&lt;/code&gt;. In .NET 6, your configuration takes place in Program.cs instead of a separate &lt;code&gt;Startup&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseResponseCaching&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseResponseCompression&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseStaticFiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to do anything substantial, though, you'll want to add services using a &lt;code&gt;WebApplicationBuilder&lt;/code&gt; (again, like you typically would previously in the &lt;code&gt;ConfigureServices&lt;/code&gt; method in &lt;code&gt;Startup.cs&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;MyCoolService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;MyReallyCoolService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddSwaggerGen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SwaggerDoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ApplicationName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"v1"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Putting it all together, let's write a simple CRUD API that works with Entity Framework Core and a &lt;code&gt;DbContext&lt;/code&gt;. We'll work with some superheroes because apparently, &lt;a href="https://www.daveabrock.com/2021/10/21/csharp-10-global-usings/"&gt;that's what I do&lt;/a&gt;. With the help of &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record"&gt;record types&lt;/a&gt;, we can make our data models a little less verbose, too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.EntityFrameworkCore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddDbContext&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseInMemoryDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Superheroes"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddSwaggerGen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SwaggerDoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ApplicationName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"v1"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/superheroes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToListAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/superheroes/{id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;superhero&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt;
        &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;superhero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NotFound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/superheroes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveChangesAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Created&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"/superheroes/&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapPut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/superheroes/{id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;heroInput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NotFound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heroInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveChangesAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NoContent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapDelete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/superheroes/{id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NotFound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Superheroes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveChangesAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;maxSpeed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperheroDb&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;DbContext&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;SuperheroDb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DbContextOptions&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;SuperheroDb&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;DbSet&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Todos&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, you can &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0"&gt;do a lot with Minimal APIs&lt;/a&gt; while keeping them relatively lightweight. If you want to continue using MVC, that's your call—but with APIs in .NET you no longer have to worry about the overhead of MVC if you don't want it. If you want to learn more, David Fowler has put together a comprehensive document on how to leverage Minimal APIs—it's &lt;a href="https://gist.github.com/davidfowl/ff1addd02d239d2d26f4648a06158727"&gt;worth checking out&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Looking at the code sample above, it's easy to wonder if this is all a race to see what we can throw in the &lt;code&gt;Program.cs&lt;/code&gt; file and how easy it is to get messy. This can happen in any app: I don't know about you, but I've seen my share of controllers that were rife for abuse.&lt;/p&gt;

&lt;p&gt;It's essential to see the true value of this model—not how cool and sexy it is to write an entire .NET CRUD API in one file, but the ability to write simple APIs with minimal dependencies and exceptional performance. If things look unwieldy, organize your project as you see fit, just like you always have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simplified HTTP logging
&lt;/h2&gt;

&lt;p&gt;How often have you used custom middleware, libraries, or solutions to log simple HTTP requests? I've done it more than I'd like to admit. .NET 6 introduces HTTP Logging middleware for ASP.NET Core apps that &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-logging/?view=aspnetcore-6.0"&gt;log information about HTTP requests and responses for you&lt;/a&gt;, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request information&lt;/li&gt;
&lt;li&gt;Properties&lt;/li&gt;
&lt;li&gt;Headers&lt;/li&gt;
&lt;li&gt;Body data&lt;/li&gt;
&lt;li&gt;Response information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also select which logging properties to include, which can help with performance too.&lt;/p&gt;

&lt;p&gt;To get started, add this in your project's middleware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IWebHostEnvironment&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseHttpLogging&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// other stuff here, removed for brevity&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To customize the logger, you can use &lt;code&gt;AddHttpLogging&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConfigureServices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IServiceCollection&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHttpLogging&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoggingFields&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpLoggingFields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;All&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Request-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Response-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we want to pair this with a Minimal API, here's how it would look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.AspNetCore.HttpLogging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHttpLogging&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoggingFields&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpLoggingFields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;All&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Request-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-Response-Header"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseBodyLogLimit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseHttpLogging&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;"I just logged the HTTP request!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Blazor improvements
&lt;/h2&gt;

&lt;p&gt;.NET 6 ships with many great updates to &lt;a href="https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor"&gt;Blazor&lt;/a&gt;, the client-side UI library that's packaged with ASP.NET Core. I want to discuss my favorite updates: error boundaries, dynamic components, and preserving pre-rendered state. Check out Jon Hilton's great post if you want to learn more about .NET 6 Blazor updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error boundaries
&lt;/h3&gt;

&lt;p&gt;Blazor error boundaries provide an easy way to handle exceptions within your component hierarchy. When an unhandled exception occurs in Blazor Server, it's treated as a fatal error because the circuit hangs in an undefined state. As a result, your app is as good as dead, it loses its state, and your users are met with an undesirable &lt;em&gt;An unhandled error has occurred&lt;/em&gt; message, with a link to reload the page.&lt;/p&gt;

&lt;p&gt;Inspired by error boundaries in React, the &lt;code&gt;ErrorBoundary&lt;/code&gt; component attempts to catch recoverable errors that can't permanently corrupt state—and like the React feature, it also renders a fallback UI.&lt;/p&gt;

&lt;p&gt;I can add an &lt;code&gt;ErrorBoundary&lt;/code&gt; around the &lt;code&gt;@Body&lt;/code&gt; of a Blazor app's default layout, like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"main"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"content px-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;ErrorBoundary&amp;gt;&lt;/span&gt;
            @Body
        &lt;span class="nt"&gt;&amp;lt;/ErrorBoundary&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If I get an unhandled exception, I'll get the default fallback error message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I6h-5tH9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/11/image-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I6h-5tH9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/11/image-1.png" alt="" width="880" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, you can always customize the UI yourself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ErrorBoundary&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ChildContent&amp;gt;&lt;/span&gt;
        @Body
    &lt;span class="nt"&gt;&amp;lt;/ChildContent&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ErrorContent&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"custom-error"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Woah, what happened?&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ErrorContent&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ErrorBoundary&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you'd like the complete treatment, check out &lt;a href="https://www.telerik.com/blogs/work-unhandled-exceptions-gracefully-blazor-server-dotnet-6-error-boundaries"&gt;my post from earlier this summer&lt;/a&gt;.  It still holds up (even the MAUI Man references).&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic components
&lt;/h3&gt;

&lt;p&gt;What happens if you want to render your components dynamically when you don't know your types ahead of time? It previously was a pain in Blazor through a custom render tree or declaring a series of &lt;code&gt;RenderFragment&lt;/code&gt; components. With .NET 6, you can render a component specified by type. When you bring in the component, you set the &lt;code&gt;Type&lt;/code&gt; and optionally a dictionary of &lt;code&gt;Parameters&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;DynamicComponent&lt;/span&gt; &lt;span class="na"&gt;Type=&lt;/span&gt;&lt;span class="s"&gt;"@myType"&lt;/span&gt; &lt;span class="na"&gt;Parameters=&lt;/span&gt;&lt;span class="s"&gt;"@myParameterDictionary"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I find dynamic components especially valuable when working with form data—you can render data based on selected values without iterating through a bunch of possible types. If this interests you (or if you like rockets), &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/dynamiccomponent?view=aspnetcore-6.0"&gt;check out the official documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Preserving pre-rendered state
&lt;/h3&gt;

&lt;p&gt;Despite all the performance and trimming improvements with Blazor WebAssembly, initial load time remains a consideration. To help with this, you can prerender apps from the server to help with its &lt;em&gt;perceived&lt;/em&gt; load time. This means that Blazor can immediately render your app's HTML while it is wiring up its dynamic bits. That's great, but it also previously meant that any state was lost.&lt;/p&gt;

&lt;p&gt;Help has arrived. To persist state, there's a new &lt;code&gt;persist-component-state&lt;/code&gt; tag helper that you can utilize:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;component&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"typeof(App)"&lt;/span&gt; &lt;span class="na"&gt;render-mode=&lt;/span&gt;&lt;span class="s"&gt;"ServerPrerendered"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;persist-component-state&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your C# code, you can inject &lt;code&gt;PersistComponentState&lt;/code&gt; and register an event to retrieve and ultimately persist the objects. On subsequent loads, your &lt;code&gt;OnInitializedAsync&lt;/code&gt; method can retrieve data from the persisted state—if it doesn't exist, it'll get the data from your original method (typically a service of some sort).&lt;/p&gt;

&lt;p&gt;To see it in action, check out the &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/persist-component-state?view=aspnetcore-6.0"&gt;Microsoft documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  C# 10 updates
&lt;/h2&gt;

&lt;p&gt;Along with .NET 6, we've also got a new version of C#—C# 10. It ships with some great new features, like file-scoped namespaces, global usings, lambda improvements, extended property patterns, null argument checks, and much more. Check out &lt;a href="https://www.telerik.com/blogs/what-was-added-csharp-10"&gt;Joseph Guadagno's blog post for more details&lt;/a&gt;, as well as &lt;a href="https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10"&gt;Microsoft's blog post&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>web</category>
    </item>
    <item>
      <title>Use AzCopy to migrate files from AWS S3 to Azure Storage</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Sun, 21 Nov 2021 16:47:50 +0000</pubDate>
      <link>https://dev.to/daveabrock/use-azcopy-to-migrate-files-from-aws-s3-to-azure-storage-1l9k</link>
      <guid>https://dev.to/daveabrock/use-azcopy-to-migrate-files-from-aws-s3-to-azure-storage-1l9k</guid>
      <description>&lt;p&gt;At the risk of upsetting Jeff Bezos, I recently moved a few million PDF files from &lt;a href="https://aws.amazon.com/s3/"&gt;Amazon S3&lt;/a&gt; to Azure Storage (&lt;a href="https://azure.microsoft.com/en-us/services/storage/blobs/?OCID=AID2200277_SEM_13b6ab1f0149198aa0b1ca862c00bac7:G:s&amp;amp;ef_id=13b6ab1f0149198aa0b1ca862c00bac7:G:s&amp;amp;msclkid=13b6ab1f0149198aa0b1ca862c00bac7#overview"&gt;Blob Storage&lt;/a&gt;, in fact). I kept it simple and opted to use Microsoft's &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10"&gt;AzCopy tool&lt;/a&gt;. It's a command-line tool that allows you to copy blobs or files from or to an Azure Storage account. AzCopy also integrates &lt;a href="https://azure.microsoft.com/en-us/blog/azcopy-support-in-azure-storage-explorer-now-available-in-public-preview/"&gt;with the Azure Storage Explorer client application&lt;/a&gt;, but using a UI wasn't ideal with the number of files I had.&lt;/p&gt;

&lt;p&gt;In this post, I'd like to show an authorization "gotcha" to keep in mind and a few things I learned that might help you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authorize AzCopy to access your Azure Storage account and Amazon S3
&lt;/h2&gt;

&lt;p&gt;After you &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?toc=/azure/storage/blobs/toc.json#download-azcopy"&gt;install AzCopy&lt;/a&gt;—the installation is a &lt;em&gt;.zip&lt;/em&gt; or &lt;em&gt;.tar&lt;/em&gt; file depending on your environment—you'll need to let AzCopy know that you are authorized to access the Amazon S3 and Azure Storage resources.&lt;/p&gt;

&lt;p&gt;From the Azure side, you can elect to use Azure Active Directory (AD) or a SAS token.  For me, I ran &lt;code&gt;azcopy login&lt;/code&gt; to log in to Azure with my credentials. If you want to run inside a script or have more advanced use cases, it's a good idea to &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-authorize-azure-active-directory?toc=/azure/storage/blobs/toc.json#authorize-a-managed-identity"&gt;authorize a managed identity&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With ownership access to the storage account, I thought that was all I needed. Not so fast!&lt;/p&gt;

&lt;p&gt;You will also need &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-authorize-azure-active-directory?toc=/azure/storage/blobs/toc.json"&gt;one of these permissions in Azure AD&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Storage Blob Data Reader (downloads only)&lt;/li&gt;
&lt;li&gt;Storage Blob Data Contributor&lt;/li&gt;
&lt;li&gt;Storage Blob Data Owner&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : Even if you are a Storage Account Owner, you &lt;em&gt;still&lt;/em&gt; need one of those permissions.&lt;/p&gt;

&lt;p&gt;You'll need to grab an Access Key ID and AWS Secret Access Key from Amazon Web Services from the AWS side. If you're not sure how to retrieve those, &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey"&gt;check out the AWS docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From there, it's as easy as setting a few environment variables (I'm using Windows):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;set AWS_ACCESS_KEY_ID=&amp;lt;my_key&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;set AWS_SECRET_ACCESS_KEY=&amp;lt;my_secret_key&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Copy an AWS bucket directory to Azure Storage
&lt;/h2&gt;

&lt;p&gt;I needed to copy all the files from a public AWS directory with the pattern &lt;code&gt;/my-bucket/dir/dir/dir/dir/&lt;/code&gt; to a public Azure Storage container. To do that, I called &lt;code&gt;azcopy&lt;/code&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;azcopy "https://s3.amazonaws.com/my-bucket/dir/dir/dir/dir/*" "https://mystorageaccount.blob.core.windows.net/mycontainer" --recursive=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command allowed me to take &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-s3?toc=/azure/storage/blobs/toc.json#copy-a-bucket"&gt;anything under the directory&lt;/a&gt; while also keeping the file structure from the S3 bucket. I knew that it was all PDF files, but I could have also used the &lt;code&gt;--include-pattern&lt;/code&gt; flag like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;azcopy "https://s3.amazonaws.com/my-bucket/dir/dir/dir/dir/*" "https://mystorageaccount.blob.core.windows.net/mycontainer" --include-pattern "*.pdf" --recursive=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's a lot of flexibility here—you can specify multiple &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload#specify-multiple-complete-file-names"&gt;complete file names&lt;/a&gt;, &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload#use-wildcard-characters"&gt;wildcard characters&lt;/a&gt; (I could have set multiple file types here), and even based on &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload#upload-files-that-were-modified-before-or-after-a-date-and-time"&gt;file modified dates&lt;/a&gt;. I might need to be more selective in the future, so I was happy to see all the options at my disposal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resuming jobs
&lt;/h2&gt;

&lt;p&gt;If running AzCopy for a while, you might deal with a stopped job. It could be because of failures or a system reboot. To start where you left off, you can run &lt;code&gt;azcopy jobs list&lt;/code&gt; to get a list of your jobs in this format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Job Id: &amp;lt;some-guid&amp;gt;
Start Time: &amp;lt;when-the-job-started&amp;gt;
Status: Cancelled | Completed | Failed
Command: copy "source" "destination" --any-flags

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the correct job ID in hand, I could run the following command to pick up where I left off:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;azcopy jobs resume &amp;lt;job-id&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you need to get to the bottom of any errors, you can &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-configure?toc=/azure/storage/blobs/toc.json#change-the-default-log-level"&gt;change the default log level&lt;/a&gt; (the default is &lt;code&gt;INFO&lt;/code&gt;) and &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-configure?toc=/azure/storage/blobs/toc.json#view-and-resume-jobs"&gt;filter by jobs with a &lt;code&gt;Failed&lt;/code&gt; state&lt;/a&gt;. AzCopy creates log and plan files for every job you run in the &lt;code&gt;%USERPROFILE%\.azcopy&lt;/code&gt; directory on Windows.&lt;/p&gt;

&lt;p&gt;After you finish, you can clean up all your plan and log files by executing &lt;code&gt;azcopy jobs clean&lt;/code&gt; (or &lt;code&gt;azcopy jobs rm &amp;lt;job-id&amp;gt;&lt;/code&gt; if you want to remove just one).&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance optimization tips
&lt;/h2&gt;

&lt;p&gt;Microsoft recommends that individual jobs contain no more than 10 million files. Jobs that transfer more than 50 million files can suffer from degraded performance &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize?toc=/azure/storage/blobs/toc.json#reduce-the-size-of-each-job"&gt;because of the tracking overhead&lt;/a&gt;. I didn't need to worry about performance, but I still &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize?toc=/azure/storage/blobs/toc.json"&gt;learned a few valuable things&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To speed things up, you can increase the number of concurrent requests by setting the &lt;code&gt;AZCOPY_CONCURRENCY_VALUE&lt;/code&gt; environment variable. By default, Microsoft sets the value to 16 multiplied by the number of CPUs on your machine—if you have less than 5 CPUs, the value is 16. Because I have 12 CPUs, AzCopy set the &lt;code&gt;AZ_CONCURRENCY_VALUE&lt;/code&gt; to 192.&lt;/p&gt;

&lt;p&gt;If you'd like to confirm, you can look at the top of your job's log file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2021/11/19 16:39:20 AzcopyVersion 10.13.0
2021/11/19 16:39:20 OS-Environment windows
2021/11/19 16:39:20 OS-Architecture amd64
2021/11/19 16:39:20 Log times are in UTC. Local time is 19 Nov 2021 10:39:20
2021/11/19 16:39:20 Job-Command copy https:/mystorageaccount.blob.core.windows.net/my-container --recursive=true 
2021/11/19 16:39:20 Number of CPUs: 12
2021/11/19 16:39:20 Max file buffer RAM 6.000 GB
2021/11/19 16:39:20 Max concurrent network operations: 192 (Based on number of CPUs. Set AZCOPY_CONCURRENCY_VALUE environment variable to override)
2021/11/19 16:39:20 Check CPU usage when dynamically tuning concurrency: true (Based on hard-coded default. Set AZCOPY_TUNE_TO_CPU environment variable to true or false override)
2021/11/19 16:39:20 Max concurrent transfer initiation routines: 64 (Based on hard-coded default. Set AZCOPY_CONCURRENT_FILES environment variable to override)
2021/11/19 16:39:20 Max enumeration routines: 16 (Based on hard-coded default. Set AZCOPY_CONCURRENT_SCAN environment variable to override)
2021/11/19 16:39:20 Parallelize getting file properties (file.Stat): false (Based on AZCOPY_PARALLEL_STAT_FILES environment variable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can tweak these values to see what works for you. Luckily, AzCopy allows you to &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize?toc=/azure/storage/blobs/toc.json#reduce-the-size-of-each-job"&gt;run benchmark tests&lt;/a&gt; that will report a recommended concurrency value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;This was my first time using AzCopy for any serious work, and I had a good experience. It comes with a lot more flexibility than I imagined and even has features for &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?toc=/azure/storage/blobs/toc.json"&gt;limiting throughput&lt;/a&gt; and &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-optimize?toc=/azure/storage/blobs/toc.json#optimize-memory-use"&gt;optimizing memory use&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To get started, &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?toc=/azure/storage/blobs/toc.json"&gt;click the link&lt;/a&gt; to begin using AzCopy—and let me know what you think of it!&lt;/p&gt;

</description>
      <category>azure</category>
      <category>aws</category>
    </item>
    <item>
      <title>Exploring C# 10: Use Extended Property Patterns to Easily Access Nested Properties</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Thu, 18 Nov 2021 01:34:28 +0000</pubDate>
      <link>https://dev.to/daveabrock/exploring-c-10-use-extended-property-patterns-to-easily-access-nested-properties-d26</link>
      <guid>https://dev.to/daveabrock/exploring-c-10-use-extended-property-patterns-to-easily-access-nested-properties-d26</guid>
      <description>&lt;p&gt;Welcome back to my series on new C# 10 features. So far we've talked about &lt;a href="https://www.daveabrock.com/2021/10/05/csharp-10-file-scoped-namespaces/"&gt;file-scoped namespaces&lt;/a&gt; and &lt;a href="https://www.daveabrock.com/2021/10/21/csharp-10-global-usings/"&gt;global using declarations&lt;/a&gt;. Today, we'll talk about extended property patterns in C# 10.&lt;/p&gt;

&lt;p&gt;Over the last few years, C# has made a lot of property pattern enhancements. Starting with C# 8, the language has supported &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#property-patterns"&gt;extended property patterns&lt;/a&gt;, a way to match an object's specific properties.&lt;/p&gt;

&lt;p&gt;For our example, let's continue the superhero theme with a &lt;code&gt;Person&lt;/code&gt;, a &lt;code&gt;Superhero&lt;/code&gt; that inherits from &lt;code&gt;Person&lt;/code&gt;, and a &lt;code&gt;Suit&lt;/code&gt;. We're going to calculate any special surcharges when making a particular superhero's suit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Suit&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;HasCape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;WordsToPrint&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's create a quick object for Iron Man:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;tonyStark&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Tony"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Stark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Malibu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Suits&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Color&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;HasCape&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our switch expression, let's say we want to determine special pricing based on a particular suit's color.&lt;/p&gt;

&lt;p&gt;Here's how we'd do it in C# 9:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSuitSurcharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;

        &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Blue"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yellow"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With C# 10, we can use dot notation to make it a bit cleaner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSuitSurcharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;

        &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Blue"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yellow"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much like before, you can also use multiple expressions at once. Let's say we wanted to charge a surcharge for a notoriously difficult customer. Look at how we can combine multiple properties in a single line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSuitSurcharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;

        &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Blue"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yellow"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Suit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all there is to it. Will this feature change your life? No. Even so, it's a nice update that allows for cleaner and simpler code.&lt;/p&gt;

&lt;p&gt;There's a lot more you can do with property patterns as well, so I'd recommend hitting up the &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/patterns#property-pattern"&gt;Microsoft Docs&lt;/a&gt; to learn more.&lt;/p&gt;

&lt;p&gt;If you're interested in the design proposal, you can also find it &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/extended-property-patterns"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let me know your thoughts below. Happy coding!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Exploring Fiddler Jam: What's New?</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Sat, 06 Nov 2021 15:00:42 +0000</pubDate>
      <link>https://dev.to/daveabrock/exploring-fiddler-jam-whats-new-2ko9</link>
      <guid>https://dev.to/daveabrock/exploring-fiddler-jam-whats-new-2ko9</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally featured on the &lt;a href="https://www.telerik.com/blogs/exploring-fiddler-jam-whats-new"&gt;Telerik Developer Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In August, &lt;a href="https://www.telerik.com/blogs/exploring-fiddler-jam-get-time-back-solving-issues-faster"&gt;I introduced you to Fiddler Jam&lt;/a&gt;. What is Jam? In short, it’s a solution to help support and development teams troubleshoot remote issues with web applications in a quick, easy and secure fashion. Think of Jam as a band playing perfectly in sync: replace the instruments with end users, support staff and software developers playing in tune—and better yet, you’ll never have to take requests for “Free Bird.”&lt;/p&gt;

&lt;p&gt;If this is your first time learning about Jam, here's a quick rundown. Users of your site can use a Chrome extension to share the full context of an issue, allowing your support team to analyze the data immediately. If needed, developers can reproduce and debug the issue using the &lt;a href="https://www.telerik.com/fiddler/fiddler-everywhere"&gt;Fiddler Everywhere debugging proxy&lt;/a&gt;. (If you'd like to learn more about Fiddler Jam basics, &lt;a href="https://www.telerik.com/blogs/introducing-fiddler-jam#:~:text=Fiddler%20Jam%20is%20a%20troubleshooting%20solution%20for%20support,%28S%29%20network%20logs%20in%20the%20customer%27s%20own%20environment."&gt;check out Rob Lauer's article&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;Jam already has a great set of features, but the development team—let's call them Jammers—has pushed even more capabilities and improvements since we last talked. We can put it through its paces by taking a look at my Blast Off with Blazor site, &lt;a href="https://www.daveabrock.com/2020/10/26/blast-off-blazor-intro/"&gt;which I've written about&lt;/a&gt;. Let's see what the Jammers have been up to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Video recordings
&lt;/h2&gt;

&lt;p&gt;When we last talked, we were able to see screenshots of a lot of user actions so we could see what users were doing when issues occurred. When you start to look at a sequence of actions, though, it might be hard to work through all the steps one by one. My favorite update is definitely a new video recording feature.&lt;/p&gt;

&lt;p&gt;After a user sends your support team a link to their Jam session, you’ll notice that the first item in the log (“Capturing Started”) is a full video recording of their experience. This only records the tab in which the user allowed their session to be captured. At this phase, you can choose to watch the whole video.&lt;/p&gt;

&lt;p&gt;As you watch it, notice how the recording highlights the corresponding log entries as they are happening. You can pause the video where needed and go right where you need to be with full context. You can also click on an event in the log and be sent to the place in the video where it occurred. From there, you can play the recording or go back and forward as needed. Instead of dealing with word-of-mouth context, you’ve got everything you need.&lt;/p&gt;

&lt;p&gt;In my case, I have a 14-second capture full of lots of media, searching and scrolling. Watch the play icon at the left and how it jumps through the log events as time passes. Very cool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9hHtFjhx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.daveabrock.com/content/images/2021/09/play-video-2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9hHtFjhx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.daveabrock.com/content/images/2021/09/play-video-2.gif" alt="" width="880" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While this is a powerful feature, Corporate Dave is here to inform you that Jam enables video recordings and screenshots by default. Be careful when dealing with sensitive data like passwords, credit card numbers, or anything else you want to keep private. Read &lt;em&gt;&lt;a href="https://docs.telerik.com/fiddler-jam/security#capture-options"&gt;Fiddler Jam Security&lt;/a&gt;&lt;/em&gt;&lt;a href="https://docs.telerik.com/fiddler-jam/security#capture-options"&gt;for details&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Better tracking for user events
&lt;/h2&gt;

&lt;p&gt;When we last Jam'ed, I briefly discussed how Fiddler Jam could track a few common events, like button clicks. The Jammers have cranked this up a notch and now allow you to track a ton of other events like clicking on &lt;code&gt;div&lt;/code&gt; elements, keyboard events, and scroll events.&lt;/p&gt;

&lt;p&gt;I don't know about you, but when I debug front-end issues, it isn't as easy as finding that a file wasn't found or there's a big error in the browser console. It's subtle things that make me clamor for the simplicity of Geocities, &lt;a href="https://javascript.info/bubbling-and-capturing"&gt;like event bubbling&lt;/a&gt; and misapplied styles.&lt;/p&gt;

&lt;p&gt;The Jammers now give us the ability to click the Inspectors tab to understand metadata about the event, like tag type and CSS class. In addition to video recording, you'll see I also have the event highlighted (in this case, typing into a search box) in a convenient screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XIHr8k1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XIHr8k1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-1.png" alt="" width="880" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Capture storage information
&lt;/h2&gt;

&lt;p&gt;A new option, &lt;em&gt;Capture storage info&lt;/em&gt;, allows you to capture &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage"&gt;local storage&lt;/a&gt; and session storage data. If you aren't familiar, local and session storage are HTML5 storage objects that allow you to store data on the client using convenient key-value pairs. Local storage exists until deleted and has no expiration date, while session storage deletes the data when the user closes a browser.&lt;/p&gt;

&lt;p&gt;While Corporate Dave will tell you to not store sensitive data here—as local/session storage isn't super secure and, also, the data is easily accessible and hackable from standard browser tooling—it can sometimes be a lightweight solution for simple data lookup. It can work well with simple user preferences or activities: if we want to remember that a user prefers Dark Mode or has already seen our introductory modal that tours our website, we can store it in local storage for easy retrieval.&lt;/p&gt;

&lt;p&gt;The Jammers have introduced the ability for you to view storage details from an aptly named Storage Details tab. If I go to a random website—look, the Telerik Blogs website, what a coincidence!—I can determine when a local storage value was set, and what it is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zcX16Sgy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zcX16Sgy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-3.png" alt="" width="880" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How do the Advanced Options work now?
&lt;/h2&gt;

&lt;p&gt;With all these great updates, let's take a look at the new &lt;a href="https://docs.telerik.com/fiddler-jam/get-started/capture-options"&gt;Advanced Options&lt;/a&gt; that users can set before capturing a session with Fiddler Jam. Most of these are enabled by default, so you won't have to ask users to explicitly turn them on, but let's review. (Don't worry, there isn't a quiz ... yet.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YcOtwDUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YcOtwDUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-2.png" alt="" width="400" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unless stated otherwise, all these options are enabled by default.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Capture video&lt;/strong&gt; - As we discussed, this option captures video recording from the active, inspected Chrome tab. Corporate Dave says: "If the screen shows sensitive data, consider disabling it."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capture screenshots&lt;/strong&gt; – This option adds a screenshot from the active Chrome tab. Corporate Dave says: "If the screen shows sensitive data, consider disabling it."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capture console&lt;/strong&gt; – This option records any developer console outputs. Again, consider disabling this if your logs have sensitive information. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capture storage info&lt;/strong&gt; - This option captures local or session storage from the Chrome tab. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mask cookies&lt;/strong&gt; – This option masks cookie values so that they aren’t visible in the logs. The cookie names will still be visible. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mask all post data&lt;/strong&gt; – This option masks data sent along in a POST request, like form information. &lt;em&gt;This option is not enabled by default.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disable cache&lt;/strong&gt; – This option asks the browser to skip network requests cache and download fresh content from the server.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Updated sharing options
&lt;/h2&gt;

&lt;p&gt;In addition to these new Advanced Options, end users can also view capture details and customize who needs to access the session's details.&lt;/p&gt;

&lt;p&gt;First, users can access session details by clicking &lt;em&gt;Capture Successful!&lt;/em&gt; I imagine the exclamation point to show the excitement that a user's issue will be diagnosed so quickly! Yes!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--loZobigL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/capture-successful.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--loZobigL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/capture-successful.png" alt="" width="554" height="807"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Users can click this area to see a quick event log. It's a nice sanity check so users can confirm they are sending you the right logs. If they have 92 tabs open—I would never, but some might—this will help provide a sanity check to make sure they are passing the correct session to you, and not cute cat videos. Again, I would never.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5-eUNDwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5-eUNDwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-4.png" alt="" width="549" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After optionally confirming users are sending the right tab, users can choose to share the details as a link or with specific people. When sharing as a link, I (and Corporate Dave) would suggest using the Password Protection feature.&lt;/p&gt;

&lt;p&gt;When you share with specific people, enter the recipient email addresses(es) to send it over electronic mail. When you do this, only the people with corresponding email addresses will have access to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SDmftjcV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SDmftjcV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.daveabrock.com/content/images/2021/09/image-5.png" alt="" width="546" height="870"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  More coming!
&lt;/h2&gt;

&lt;p&gt;There's more coming to Fiddler Jam soon—consider &lt;a href="https://www.telerik.com/support/whats-new/fiddler-jam/roadmap"&gt;bookmarking the Fiddler Jam roadmap&lt;/a&gt; for details.&lt;/p&gt;

&lt;p&gt;Get started with Fiddler Jam today by going to the Fiddler Jam site and &lt;a href="https://www.telerik.com/fiddler-jam"&gt;signing up for a free 14-day trial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Pretty good work from the Jammers, yes? Good work, team. Take the rest of the day off. You've deserved it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Saying goodbye to The .NET Stacks</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Thu, 04 Nov 2021 12:42:14 +0000</pubDate>
      <link>https://dev.to/daveabrock/saying-goodbye-to-the-net-stacks-3nc3</link>
      <guid>https://dev.to/daveabrock/saying-goodbye-to-the-net-stacks-3nc3</guid>
      <description>&lt;p&gt;I wanted to write a quick note to let everyone know that I will no longer be producing &lt;em&gt;The .NET Stacks&lt;/em&gt;. This does not mean I'll be going away or leaving the wonderful .NET community—it just means I'll be producing content in other ways.&lt;/p&gt;

&lt;p&gt;I wouldn't call the newsletter a smashing success by any means, but was thrilled that something I started while bored during a pandemic grew to a few thousand readers every week on various mediums (whether over e-mail, &lt;em&gt;dev.to&lt;/em&gt;, or &lt;em&gt;daveabrock.com&lt;/em&gt;). I'm grateful to all of you for reading and being so supportive—and if it helped you, I'm even happier. It's been a lot of fun and I've even "met" quite a few friends along the way, even if we've never physically met.&lt;/p&gt;

&lt;p&gt;I initially set out to produce something more substantive and not a weekly thing where I send out links every week, as I felt there wasn't a lot of that out there. I wanted to write about trends and topics, and interview folks, and provide a little more context. I quickly realized why there wasn't a lot of that out there: it's so much work to do that on a weekly basis, week in, week out.&lt;/p&gt;

&lt;p&gt;With a busy personal life, I'm passionate about community work but with limited time. I did a lot of work to automate things as I could, but &lt;em&gt;The .NET Stacks&lt;/em&gt; doesn't leave time for any other community work or projects that I'm passionate about. To me, I could either slim down the newsletter and its quality and make it easier to manage, or focus work in other areas. I've chosen the latter.&lt;/p&gt;

&lt;p&gt;It's hard to believe I've produced 70 weekly issues over 18 months, and have used the newsletter to ramble about .NET to the tune of about 104,000 words. Thanks to you all: thanks for reading every week, and thanks for those of you who have emailed me nice words or to ask if I've lost my marbles—both valid, by the way—and thanks for listening. I hope you'll continue to keep up with me at &lt;em&gt;daveabrock.com&lt;/em&gt;. Talk to you soon and keep in touch.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>azure</category>
    </item>
    <item>
      <title>The .NET Stacks #68: 🍿 What a week</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Tue, 26 Oct 2021 23:27:37 +0000</pubDate>
      <link>https://dev.to/daveabrock/the-net-stacks-68-what-a-week-316b</link>
      <guid>https://dev.to/daveabrock/the-net-stacks-68-what-a-week-316b</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cE__rAeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyj39876oiw8wibd4qdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cE__rAeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyj39876oiw8wibd4qdl.png" alt="Image description" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy ... Tuesday? It's been quite an interesting week. We have one thing to discuss, and then straight to the links.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.NET Open Source: Who does Microsoft want to be?&lt;/li&gt;
&lt;li&gt;Last week in the .NET world&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  .NET Open Source: Who does Microsoft want to be?
&lt;/h2&gt;

&lt;p&gt;To put it lightly, last week was a very eventful week for the .NET community. I'd like to talk about what happened, what we learned, and what it means for .NET open source.&lt;/p&gt;

&lt;p&gt;Before diving in, I want to say that I am voicing my opinions only and my intent is not to "create more drama" or keep harping on about past events. While Microsoft resolved the current issue a few days ago, I often find that I can view events with better clarity after spending a few days stepping back and thinking about it. You might agree with what I have to say, think I'm blowing it out of proportion, or somewhere in between. I expect that.&lt;/p&gt;

&lt;p&gt;What happened? If you've been subscribed here for the last few months, you know that one of the core objectives of .NET 6 is to &lt;a href="https://github.com/dotnet/core/issues/5511"&gt;improve the "inner development loop" for the .NET platform&lt;/a&gt;. The core feature is the "Hot Reload" functionality, which allows developers to see changes applied instantly while running their application. Already viewed as table stakes for modern web application development—front-end developers have enjoyed this capability for many years—it's finally making its way to the .NET platform. As the .NET team is trying to embrace new developers or developers from other platforms, it's a key selling point. If you try to get React or Angular developers to consider something like Blazor, and they learn it isn't available out of the box, you'll likely get a "Seriously?" Once you have it, you can't live without it.&lt;/p&gt;

&lt;p&gt;Anyway, Hot Reload was announced and then rolled out in .NET 6 Preview 3, and I wrote about it in detail &lt;a href="https://www.telerik.com/blogs/instant-feedback-is-here-introducing-hot-reload-in-dotnet-6"&gt;all the way back in April&lt;/a&gt;. At the time, it was rolled out in the .NET CLI via &lt;code&gt;dotnet watch&lt;/code&gt; as a lot of new features are. Eventually, Microsoft said, it would make its way to Visual Studio or whatever tool you enjoy—but since it resides in the core SDK, you could use it across a wide variety of environments and platforms. It worked well and as a whole, the community was thrilled. Right around the time .NET 6 RC 2 was released last week—the last "preview" release that ships with a go-live production license—Microsoft decided to scrap it from &lt;code&gt;dotnet watch&lt;/code&gt; and only make it &lt;a href="https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights/"&gt;available for Visual Studio 2022&lt;/a&gt; "so we can focus on providing the best experiences to the most users" so long as you enjoy Visual Studio on Windows. As if it wasn't abundantly clear, .NET engineers leaked to &lt;em&gt;The Verge&lt;/em&gt; that this was a &lt;a href="https://www.theverge.com/2021/10/22/22740701/microsoft-dotnet-hot-reload-removal-decision-open-source"&gt;business decision made at the CVP level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After a ton of almost &lt;a href="https://github.com/dotnet/sdk/issues/22247"&gt;universal backlash&lt;/a&gt;, the capability &lt;a href="https://devblogs.microsoft.com/dotnet/net-hot-reload-support-via-cli/"&gt;was restored&lt;/a&gt; to &lt;code&gt;dotnet watch&lt;/code&gt;, in a blog post whose only strength was providing political cover and delivered on none of what we all wanted: being honest, authentic, or transparent with the community.&lt;/p&gt;

&lt;p&gt;I don't think anyone is confusing a trillion-dollar corporation for being a charitable organization. And it is true that a majority of .NET developers are on Visual Studio. If Microsoft decided to make this a Visual Studio feature from the beginning, the pushback would be minimal.&lt;/p&gt;

&lt;p&gt;The deserved furor comes from Microsoft ripping out a core feature right before completing a release and done with a PR that was closed to community feedback. This all feels like we got transported to Ballmer-esque Microsoft, and not the "new Microsoft" that appears to be less concerned with sticking you to specific tooling but doing all it can to meet you where you are, so long as you deploy your workloads to Azure.&lt;/p&gt;

&lt;p&gt;With the popularity of Visual Studio Code and the emergence of wonderful competitive tools like JetBrains Rider, Microsoft is at odds with being open in the name of that fat Azure cash or being protective of pricey enterprise licensing with Visual Studio. This week highlighted their conflict of interest and desire to have their cake and eat it, too.&lt;/p&gt;

&lt;p&gt;We've been slowly reaching a breaking point. Over the last few years, Microsoft &lt;a href="https://github.com/dotnet/core/issues/505"&gt;restricted debugger licensing&lt;/a&gt;, the &lt;a href="https://blog.lextudio.com/the-end-of-monodevelop-80b383dab34b"&gt;abandonment of MonoDevelop&lt;/a&gt;, and now we have the hot reload controversy. Include the .NET Foundation issues, and Microsoft's "open-source friendly" reputation has taken its hits. The common logic is that while Visual Studio is a moneymaker, for sure, it's a rounding error compared to Azure, so it's good business sense for Microsoft to shed its protectionism in favor of inclusiveness and community goodwill.&lt;/p&gt;

&lt;p&gt;Of course, none of this criticism should take away from the amazing work the .NET team has done for both their platform and open source. As a matter of fact, that team is likely the most upset here as a decision out of control has hurt their reputation with the community. But where does .NET fit? For me, it begs the question about how Microsoft views .NET: is it an open, innovative platform that drives Azure investment, or a piggy bank that Microsoft executives can shake until every last penny comes out?&lt;/p&gt;

&lt;p&gt;To Microsoft's credit, they should be commended for writing their wrongs so quickly. They listened and reacted, and pushed out an apology in just a few days—an amazing feat at a trillion-dollar company with many layers of top-down management. All in all, I think last week was a wonderful testament to the true value of community, where a group of devoted people can help drive change (or undo unfortunate decisions).&lt;/p&gt;

&lt;p&gt;However, &lt;a href="https://devblogs.microsoft.com/dotnet/net-hot-reload-support-via-cli/"&gt;the apology post&lt;/a&gt; is littered with inconsistencies and seems to be protecting senior management's decisions and not their reputation with the community.&lt;/p&gt;

&lt;p&gt;The post explains that: "In our effort to scope, we inadvertently ended up deleting the source code instead of just not invoking that code path." In my opinion, this wasn't an engineer running the wrong command, but trying to make a last-minute change at the demands of their management and closing the PR for comments. While reading the post, I couldn't help but feel how it contradicted this new open Microsoft—build what you want, on any platform you want, so long as you use Azure—and reeked of the political cover and protectionism that defined its past.&lt;/p&gt;

&lt;p&gt;Where do we go from here? Is this a team hitting some bumps with a recent reorg, or a sign of things to come? Have the higher-ups at Microsoft learned their lessons, or is this the beginning of protecting the most coveted SDK features to their exclusive tooling? And most importantly, how will Microsoft balance conflicts of interest with all their tooling choices? As Visual Studio Code is an amazing editor, as &lt;a href="https://dusted.codes/can-we-trust-microsoft-with-open-source"&gt;Dustin Gorski&lt;/a&gt; and others have wondered aloud, isn't it strange that Microsoft's own .NET platform is one of the worst supported platforms on Code?&lt;/p&gt;

&lt;p&gt;If Microsoft wants to be honest with its community, it needs to answer: What do you want .NET to be? To keep it an open, open-source friendly platform, or to make it a piggy bank? It appears to be that Microsoft wants it both ways and risks harming its reputation with the community while promising openness.&lt;/p&gt;

&lt;p&gt;We know Microsoft will never have a perfect relationship with its developer community. At the end of the day, their responsibilities are to their shareholders. With that said, I have all the faith in the world in the .NET team. I admire them and all the work they have done on the .NET platform. I hope the team aligns with their management and can eventually be transparent with the community about what they truly want .NET to be—no BS, no corporate-speak.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌎 Last week in the .NET world
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📢 Announcements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Emily Stoll &lt;a href="https://devblogs.microsoft.com/visualstudio/weve-upgraded-the-ui-in-visual-studio-2022"&gt;writes about Visual Studio 2022 UI updates&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dmitry Lyalin &lt;a href="https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights"&gt;provides an update on .NET Hot Reload&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Microsoft introduces &lt;a href="https://code.visualstudio.com/blogs/2021/10/20/vscode-dev"&gt;vscode.dev&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Paul Thurrott &lt;a href="https://www.thurrott.com/dev/258377/microsoft-officially-deprecates-uwp"&gt;writes about Microsoft deprecating UWP&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Kathleen Dollard &lt;a href="https://devblogs.microsoft.com/dotnet/whats-new-in-fsharp-6"&gt;writes about what's new in F# 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Microsoft releases &lt;a href="https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-12-release"&gt;Windows Terminal Preview 1.12&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Rachel Appel &lt;a href="https://blog.jetbrains.com/dotnet/2021/10/20/debugging-experience-debug-uwp-apps-and-debug-windows-docker-containers-in-rider-2021-3/"&gt;writes about various updates in Rider 2021.3&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📅 Community and events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Help decide &lt;a href="https://dotnetfoundation.org/blog/2021/10/18/net-foundation-face-to-face-questions"&gt;what questions to answer at the .NET Foundation's next meeting&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Uno Blog &lt;a href="https://platform.uno/blog/recent-uwp-and-net-5-net-6-news-and-uno-platform-plans/"&gt;writes about recent UWP &amp;amp; .NET 5, .NET 6 news and Uno Platform plans&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Matthew MacDonald &lt;a href="https://medium.com/young-coder/the-ghost-of-silverlight-or-lessons-learned-from-dying-frameworks-cb745b16a61f"&gt;writes about lessons learned from dying frameworks&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Sergey Tihon &lt;a href="https://sergeytihon.com/2021/10/18/f-advent-calendar-2021/"&gt;announces the 2021 F# advent calendar&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌎 Web development
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Richard MacManus &lt;a href="https://thenewstack.io/growth-of-progressive-web-apps/"&gt;writes about the growth of PWAs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Microsoft Edge Blog &lt;a href="https://blogs.windows.com/msedgedev/2021/10/21/improved-authoring-debugging-devtools-visual-studio-code"&gt;writes about the improved authoring and debugging experiences in Microsoft Edge DevTools and Visual Studio Code&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Davide Bellone &lt;a href="https://www.code4it.dev/csharptips/ping-endpoint"&gt;writes about pinging endpoints&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Imar Spaanjars &lt;a href="https://imar.spaanjaars.com/626/improving-your-aspnet-core-sites-file-handling-capabilities-part-1-introduction"&gt;writes about improving your ASP.NET Core site's file handling capabilities&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;David Ramel &lt;a href="https://visualstudiomagazine.com/articles/2021/10/15/aspnet-update.aspx"&gt;writes about native dependencies with Blazor WebAssembly&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Chris Coyier &lt;a href="https://css-tricks.com/supports-selector/"&gt;writes about the supports() CSS selector&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🥅 The .NET platform
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Matthew Jones &lt;a href="https://exceptionnotfound.net/bite-size-dotnet-6-linq-ordefault-overloads/"&gt;uses LINQ OrDefault() overloads in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Andrew Lock &lt;a href="https://andrewlock.net/exploring-dotnet-6-part-6-supporting-integration-tests-with-webapplicationfactory-in-dotnet-6/"&gt;supports integration tests with WebApplicationFactory in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📔 Languages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Dave Brock &lt;a href="https://www.daveabrock.com/2021/10/21/csharp-10-global-usings/"&gt;writes about using global declarations in C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Khalid Abuhakmeh &lt;a href="https://khalidabuhakmeh.com/bulk-import-records-into-sqlite-csharp"&gt;uses C# to bulk insert records into SQLLite&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jorge Levy &lt;a href="https://www.c-sharpcorner.com/article/azure-functions-with-net-5-execution-on-isolated-process/"&gt;writes about using Azure Functions with .NET 5&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Thomas Claudius Huber &lt;a href="https://www.thomasclaudiushuber.com/2021/10/21/c-10-extended-property-patterns/"&gt;talks about extended property patterns in C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Muhammed Saleem &lt;a href="https://code-maze.com/csharp-async-enumerable-yield/"&gt;uses IAsyncEnumerable with yield in C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;David McCarter &lt;a href="https://dotnettips.wordpress.com/2021/10/21/collection-performance-converting-a-list-to-different-types/"&gt;writes about collection type performance in C#&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔧 Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Thomas Scott &lt;a href="https://dzone.com/articles/5-jetbrain-plugins-upgrade-git-support"&gt;talks about JetBrains Git plugins&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Andrea Chiarelli &lt;a href="https://auth0.com/blog/exploring-auth0-aspnet-core-authentication-sdk/"&gt;explores the Auth0 ASP.NET Core Authentication SDK&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏗 Design, testing, and best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Zaher Talab &lt;a href="https://www.developer.com/web-services/api-testing-tools-tips/"&gt;provides API testing tips&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Derek Comartin &lt;a href="https://codeopinion.com/leaking-value-objects-from-your-domain/"&gt;writes about leaking value objects from your domain&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Sam Milbrath &lt;a href="https://blog.trello.com/4-ways-to-manage-your-energy-and-have-a-balanced-productive-workday"&gt;writes about managing your energy&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Overflow Blog &lt;a href="https://stackoverflow.blog/2021/10/18/code-quality-a-concern-for-businesses-bottom-lines-and-empathetic-programmers/"&gt;writes about code quality&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Stackify Blog &lt;a href="https://stackify.com/net-developer-skills/"&gt;discusses top .NET developer skills&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Oren Eini &lt;a href="https://ayende.com/blog/195041-C/finding-a-bug-with-code-that-isnt-there?Key=ce6fc440-4aef-4063-b1ca-f6337258b17f"&gt;tracks down a sticky bug&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Joana Carvalho &lt;a href="https://dzone.com/refcardz/full-stack-observability-essentials"&gt;writes about full-stack observability essentials&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Peter Vogel &lt;a href="https://www.telerik.com/blogs/unit-testing-azure-functions-in-isolated-environment"&gt;unit tests Azure Functions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dennis Doomen &lt;a href="https://www.continuousimprover.com/2021/10/laws-test-driven-development.html"&gt;writes about his 17 laws of TDD&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎤 Podcasts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The .NET Podcast &lt;a href="https://dotnetcore.show/episode-85-clean-code-in-c-sharp-with-jason-alls/"&gt;talks about clean code in C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Merge Conflict &lt;a href="https://www.mergeconflict.fm/276"&gt;writes about .NET 6 and C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Adventures in .NET &lt;a href="https://adventuresindotnet.com/how-fluent-are-your-assertions-net-091"&gt;talks to Dennis Doomen about Fluent Assertions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Overflow &lt;a href="https://stackoverflow.blog/2021/10/22/podcast-386-quality-code-is-the-easiest-to-delete/"&gt;talks about code quality&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The 6-Figure Developer Podcast &lt;a href="https://6figuredev.com/podcast/episode-216-visual-studio-2022-with-mads-kristensen/"&gt;talks to Mads Kristensen about Visual Studio 2022&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎥 Videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The ASP.NET Monsters &lt;a href="https://www.youtube.com/watch?v=QUHa7ojibjY"&gt;talk about improved .NET 6 LINQ methods&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Cecil Phillip &lt;a href="https://www.youtube.com/watch?v=AAQSShtl9S0"&gt;walks through Dapr&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>azure</category>
    </item>
    <item>
      <title>The .NET Stacks #67: 🆕 .NET 6 RC2 arrives</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Sun, 24 Oct 2021 16:39:29 +0000</pubDate>
      <link>https://dev.to/daveabrock/the-net-stacks-67-net-6-rc2-arrives-4mab</link>
      <guid>https://dev.to/daveabrock/the-net-stacks-67-net-6-rc2-arrives-4mab</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eU5gFzhX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8wmj31d8thcg8zvnb5t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eU5gFzhX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8wmj31d8thcg8zvnb5t.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Welcome to another week, full of &lt;a href="https://www.theverge.com/2021/10/18/22732912/apple-macbook-pro-notch-display"&gt;top-notch product announcements&lt;/a&gt; and the proclamation of "View Source" &lt;a href="https://twitter.com/GovParsonMO/status/1448697768311132160"&gt;as a crime&lt;/a&gt;.  I too am a hacker, apparently.&lt;/p&gt;

&lt;p&gt;Anyway, here's what we have going on this week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web updates with .NET 6 RC 2&lt;/li&gt;
&lt;li&gt;New .NET 6 LINQ API: Chunk&lt;/li&gt;
&lt;li&gt;Last week in the .NET world&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Web updates with .NET 6 RC 2
&lt;/h2&gt;

&lt;p&gt;Right on time, last week Microsoft &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/"&gt;rolled out the .NET 6 RC 2 release&lt;/a&gt;. It's the second of two "go live" RCs that are actually supported in production. Richard Lander's announcement post gets you up to speed on &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#c-10"&gt;what is new with C# 10&lt;/a&gt;, including &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#record-structs"&gt;record structs&lt;/a&gt;, &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#global-usings"&gt;global usings&lt;/a&gt;, &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#file-scoped-namespace-declaration"&gt;file-scoped namespaces&lt;/a&gt;, &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#const-and-interpolated-strings"&gt;interpolated strings&lt;/a&gt;, and &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#extended-property-patterns"&gt;extended property patterns&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Despite being oh-so-close to the official release next month, the ASP.NET Core team was busy shipping updates for this release and I'd like to &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2/"&gt;pay attention to those&lt;/a&gt;. We saw updates in two big areas: &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2/"&gt;native dependencies&lt;/a&gt; and Minimal APIs—the latter of which I've admittedly beaten to death, but also plays a pivotal future in how you build new APIs in the .NET ecosystem (if you want to get over MVC, of course).&lt;/p&gt;

&lt;p&gt;With Blazor WebAssembly, in .NET 6 you can now use native dependencies that are built to run on WebAssembly. Using new .NET WebAssembly build tools, you can statically link native dependencies. You can use any native code with this, like C/C++ code, archives, or even standalone .wasm modules. If you have some C code, for example, the build tools can compile and link it to a &lt;code&gt;dotnet.wasm&lt;/code&gt; file. To extend it some more, you can use libraries with native dependencies as well.&lt;/p&gt;

&lt;p&gt;As for Minimal APIs, you can now leverage parameter binding improvements. With RC2, you can use &lt;code&gt;TryParse&lt;/code&gt; and &lt;code&gt;BindAsync&lt;/code&gt; for inherited methods. For example, &lt;code&gt;BindAsync&lt;/code&gt; allows you to bind a complex type using inheritance. Check out Daniel Roth's &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2/#parameter-binding"&gt;blog post for details&lt;/a&gt;. The RC2 release also makes some &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2/#openapi"&gt;OpenAPI enhancements&lt;/a&gt; and includes some analyzers to help you find issues with &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2/#source-code-analysis"&gt;middleware issues or route handling&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's hard to believe the next .NET 6 announcement will be the full release itself. As part of that &lt;a href="https://www.dotnetconf.net/"&gt;.NET Conf will celebrate the launch&lt;/a&gt;, and Visual Studio 2022 will launch on November 8. In the year 2021. (I know.)&lt;/p&gt;




&lt;h2&gt;
  
  
  New .NET 6 LINQ API: Chunk
&lt;/h2&gt;

&lt;p&gt;If you haven't heard, .NET 6 will roll out some nice LINQ API improvements. Matt Eland recently &lt;a href="https://raygun.com/blog/linq-net-6-improvements/"&gt;wrote a nice piece about them&lt;/a&gt;. As a whole, it's nice to see .NET 6 roll out quite a few API improvements that were previously done with some light hacking. We all do some light hacking, of course, but for millions of .NET developers there are a lot of common use cases—and it's nice to see those being addressed.&lt;/p&gt;

&lt;p&gt;My favorite recent LINQ API improvement is the Chunk API. If you work with large collections of objects, you can now chunk them in case you want to work through pagination or other "chunking" use cases. For paging, you previously had to set a page size, loop through the collection, add to some paging collection, and update some counts.&lt;/p&gt;

&lt;p&gt;Instead, as Matt notes, you could try something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IEnumerable&amp;lt;Movie[]&amp;gt; chunks = movies.Chunk(PAGE_SIZE);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should really help folks page through big API datasets. When you don't control the data coming back, you had to set this up yourself. Very nice.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌎 Last week in the .NET world
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📢 Announcements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Richard Lander &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2"&gt;announces .NET 6 Preview 2&lt;/a&gt;, and Daniel Roth discusses &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-rc-2"&gt;ASP.NET Core updates&lt;/a&gt;. Also, David Ortinau &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-9"&gt;introduces .NET MAUI Preview 9&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Visual Studio 2022 for Mac Preview 2 &lt;a href="https://devblogs.microsoft.com/visualstudio/visual-studio-2022-for-mac-preview-2-is-now-available"&gt;is now available&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jeremy Likness &lt;a href="https://devblogs.microsoft.com/dotnet/prime-your-flux-capacitor-sql-server-temporal-tables-in-ef-core-6-0"&gt;writes about SQL Server temporal tables in EF Core 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Auth0 is now &lt;a href="https://auth0.com/blog/auth0-on-microsoft-azure-as-a-private-cloud-deployment-option/"&gt;available on Azure&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📅 Community and events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Brendan Burns &lt;a href="https://cloudblogs.microsoft.com/opensource/2021/10/13/kubecon-north-america-2021-kubernetes-on-azure-and-open-source-updates"&gt;provides updates on KubeCon&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jeremy Miller &lt;a href="https://jeremydmiller.com/2021/10/11/marten-v4-hard-deletes-soft-deletes-un-deletes-all-the-deletes-you-meet/"&gt;writes all about deletes in Marten v4&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Aaron Stannard &lt;a href="https://aaronstannard.com/future-of-dotnet-foundation/"&gt;writes about the Future of the .NET Foundation and .NET OSS&lt;/a&gt;. In related news, The .NET Foundation &lt;a href="https://dotnetfoundation.org/blog/2021/10/14/come-talk-to-us-a-net-foundation-face-to-face"&gt;is holding a Tell Me Anything meeting&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Microsoft has a VS 2022 launch event &lt;a href="https://devblogs.microsoft.com/visualstudio/join-us-november-8th-for-the-launch-of-visual-studio-2022"&gt;on November 8&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌎 Web development
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Vedran Cindric &lt;a href="https://dzone.com/articles/the-rest-of-the-10-commandments"&gt;provides some REST guidance&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Niels Swimberghe &lt;a href="https://swimburger.net/blog/dotnet/get-your-head-together-with-blazors-new-headcontent-and-pagetitle"&gt;works with Blazor’s new HeadContent and PageTitle&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Matthew MacDonald &lt;a href="https://medium.com/young-coder/blazors-aot-compilation-isn-t-the-silver-bullet-you-re-expecting-2a454e524bc7"&gt;throws some cold water on Blazor AOT compilation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🥅 The .NET platform
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Scott Hanselman &lt;a href="https://www.hanselman.com/blog/dotnet-could-not-execute-because-the-application-was-not-found-or-a-compatible-net-sdk-is-not-installed"&gt;debugs a .NET SDK issue&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Matthew Jones &lt;a href="https://exceptionnotfound.net/bite-size-dotnet-6-chunk-in-linq/"&gt;writes about the new Chunk() method in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Code Maze &lt;a href="https://code-maze.com/cqrs-mediatr-fluentvalidation/"&gt;works through a CQRS validation pipeline with MediatR and FluentValidation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Andrew Lock &lt;a href="https://andrewlock.net/exploring-dotnet-6-part-5-supporting-ef-core-tools-with-webapplicationbuilder/"&gt;supports EF Core migrations with WebApplicationBuilder&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Muhammad Rehan Saeed &lt;a href="https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/"&gt;writes about his issues with C# 10 implicit usings&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⛅ The cloud
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Lee Briggs &lt;a href="https://www.pulumi.com/blog/azure-container-solutions/"&gt;compares Azure container solutions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Norm Johanson &lt;a href="https://aws.amazon.com/blogs/developer/dotnet-deployment-projects/"&gt;writes about the new AWS .NET Deployment Experience&lt;/a&gt;, and François Bouteruche &lt;a href="https://medium.com/i-love-my-local-farmer-engineering-blog/migrating-our-trusty-ol-net-framework-applications-to-aws-i-couldn-t-believe-it-2b111fcd8146"&gt;migrates .NET Framework apps to AWS&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Daniel Krzyczkowski &lt;a href="https://daniel-krzyczkowski.github.io/Asynchronous-communication-with-Azure-Service-Bus/"&gt;writes about async communication with the Azure Service Bus&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Pavel Krymets &lt;a href="https://devblogs.microsoft.com/azure-sdk/introducing-experimental-opentelemetry-support-in-the-azure-sdk-for-net"&gt;introduces experimental OpenTelemetry support in the Azure SDK for .NET&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Stephanie Lee &lt;a href="https://medium.com/asos-techblog/azure-functions-in-net-5-6faae95c1b72"&gt;writes about using Azure Functions with .NET 5&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔧 Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Khalid Abuhakmeh &lt;a href="https://khalidabuhakmeh.com/cursor-paging-with-entity-framework-core-and-aspnet-core"&gt;works on cursor paging with Entity Framework Core and ASP.NET Core&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Pro Code Guide &lt;a href="https://procodeguide.com/programming/polly-in-aspnet-core/"&gt;uses Polly with ASP.NET Core&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;James Croft &lt;a href="https://www.jamescroft.co.uk/running-selenium-ui-tests-in-an-azure-devops-pipeline/"&gt;runs Selenium UI Tests with Azure DevOps&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Cody Merritt Anhorn &lt;a href="https://codyanhorn.tech/blog/enable-net-cli-tab-completion"&gt;enables .NET CLI tab completion&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Thomas Ardal writes about &lt;a href="https://blog.elmah.io/updating-nuget-packages-from-command-line-deep-dive/"&gt;updating NuGet packages from the command line&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Davide Bellone &lt;a href="https://www.code4it.dev/blog/serilog-log-on-console"&gt;adds logs with .NET Core and Serilog&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Grace Taylor &lt;a href="https://devblogs.microsoft.com/visualstudio/vs-code-themes-in-vs"&gt;writes about using VS Code themes with Visual Studio 2022&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Matthias Koch &lt;a href="https://blog.jetbrains.com/dotnet/2021/10/11/copy-code-reference-in-resharper-and-rider-2021-3-eap/"&gt;writes about the reworked Copy Code Reference feature in ReSharper and Rider 2021.3 EAP&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏗 Design, testing, and best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Derek Comartin &lt;a href="https://codeopinion.com/data-consistency-between-microservices/"&gt;explores data consistency between microservices&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Camille Fournier &lt;a href="https://www.elidedbranches.com/2021/10/how-new-managers-fail-individual.html"&gt;writes about how new managers fail individual contributors&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dennis Doomen &lt;a href="https://www.continuousimprover.com/2021/10/symptoms-testability.html"&gt;describes 15 flags that tell you that your testability practices need maturing&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Overflow &lt;a href="https://stackoverflow.blog/2021/10/13/why-solve-a-problem-twice-design-patterns-let-you-apply-existing-solutions-to-your-code/"&gt;explores design patterns&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jennifer Riggins &lt;a href="https://thenewstack.io/observability-is-the-new-kubernetes/"&gt;writes about the emergence of observability&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎤 Podcasts and videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Adventures in .NET &lt;a href="https://adventuresindotnet.com/vs-2022-64-bit-net-090"&gt;talk about VS 2022&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Coding Blocks asks: &lt;a href="https://www.codingblocks.net/podcast/should-you-speak-at-a-conference/"&gt;should you speak at a conference?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;.NET Rocks &lt;a href="https://www.dotnetrocks.com/default.aspx?ShowNum=1761"&gt;talks to Mads Torgersen about C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;AzureFunBytes talks to Burke Holland &lt;a href="https://devblogs.microsoft.com/devops/azurefunbytes-episode-59-remote-possibilities-with-burkeholland"&gt;about remote development&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The ASP.NET Monsters &lt;a href="https://www.youtube.com/watch?v=lfVEv54BfLE"&gt;build GitHub Actions in C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Scott Hanselman &lt;a href="https://www.youtube.com/watch?v=VT2L1SXFq9U"&gt;makes the ultimate terminal prompt on Windows 11&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The .NET MAUI Podcast &lt;a href="https://www.dotnetmauipodcast.com/100"&gt;talks all about .NET 6 RC 2&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Exploring C# 10: Global Using Declarations</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Thu, 21 Oct 2021 03:18:57 +0000</pubDate>
      <link>https://dev.to/daveabrock/exploring-c-10-global-using-declarations-lab</link>
      <guid>https://dev.to/daveabrock/exploring-c-10-global-using-declarations-lab</guid>
      <description>&lt;p&gt;Welcome back to my series on new C# 10 features. I kicked off this series by writing about &lt;a href="https://www.daveabrock.com/2021/10/05/csharp-10-file-scoped-namespaces/" rel="noopener noreferrer"&gt;file-scoped namespaces&lt;/a&gt;, a simple but powerful way to remove unnecessary verbosity from your C# code. This time, we're talking about a new feature that achieves similar goals: global using declarations.&lt;/p&gt;

&lt;p&gt;To see how this works, let's revisit my model from the last post, a &lt;code&gt;Superhero&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say I wanted to do some basic work with this model in a standard C# 10 console application. It would look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Tony"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Stark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Malibu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;500&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Natasha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Romanova"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Look, it's &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The first superhero in the list is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;First&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice that &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements" rel="noopener noreferrer"&gt;thanks to top-level statements&lt;/a&gt;, the file is already looking pretty slim. If I create a new file, like &lt;code&gt;GlobalUsings.cs&lt;/code&gt;, I could store any usings that I want to be shared across my project's C# files. While you can declare global usings anywhere, it's probably a good idea to isolate it somewhere. (This is scoped for the project and not the solution, so if you want this across multiple files you'd want to specify global usings in every project.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;ConsoleApp6.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I go back to my &lt;code&gt;Program.cs&lt;/code&gt; file, Visual Studio reminds me that &lt;code&gt;Superhero.Models&lt;/code&gt; is referenced elsewhere (in my &lt;code&gt;GlobalUsings.cs&lt;/code&gt;), so it can be safely removed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can also use the &lt;code&gt;global static&lt;/code&gt; keyword when I use common static methods, like the &lt;code&gt;Math&lt;/code&gt; class or writing to &lt;code&gt;Console&lt;/code&gt;.  While static usings aren't new—they've been around since C# 6—I can use it freely with global usings. Let's update my &lt;code&gt;GlobalUsings.cs&lt;/code&gt; file to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Back in my &lt;code&gt;Program.cs&lt;/code&gt;, Visual Studio tells me I don't need to use &lt;code&gt;Console&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aside from supporting standard namespaces (and system ones) and static namespaces, you can also use aliases. Let's say I wanted to globally use &lt;code&gt;System.DateTime&lt;/code&gt; and alias it as &lt;code&gt;DT&lt;/code&gt;. Here's how my &lt;code&gt;GlobalUsings.cs&lt;/code&gt; file looks now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;DT&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Going back to my main &lt;code&gt;Program.cs&lt;/code&gt;, here's how everything looks now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Tony"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Stark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Malibu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;500&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Natasha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Romanova"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Look, it's &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The first superhero in the list is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;First&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Last ran on &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;DT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Are some common namespaces globally available by default?
&lt;/h2&gt;

&lt;p&gt;When I created a collection and read from it, I'm using calls from a few standard Microsoft namespaces: &lt;code&gt;System.Collections.Generic&lt;/code&gt; and &lt;code&gt;System.Linq&lt;/code&gt;. You may have noticed something: why didn't I need to explicitly include these namespaces in a global usings file? The answer lies in the &lt;code&gt;obj/Debug/net6.0&lt;/code&gt; folder. After you build your project, you'll notice a &lt;code&gt;GlobalUsings.g.cs&lt;/code&gt; file, which contains &lt;em&gt;implicit usings&lt;/em&gt;. Enabled by default in .NET 6, you don't need to explicitly include them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// &amp;lt;auto-generated/&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Collections&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Generic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Linq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Http&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Threading&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;global&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The funky &lt;code&gt;global::&lt;/code&gt; syntax ensures that you don't see collisions if you have your own namespaces. For example, if I had a few drinks one night and decided to write my own (very buggy) I/O library and call it &lt;code&gt;DaveIsCool.System.IO&lt;/code&gt;, this ensures I'm using the Microsoft namespace.&lt;/p&gt;

&lt;p&gt;These usings are driven by an &lt;code&gt;&amp;lt;ImplicitUsings&amp;gt;&lt;/code&gt; flag in my project file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Project&lt;/span&gt; &lt;span class="na"&gt;Sdk=&lt;/span&gt;&lt;span class="s"&gt;"Microsoft.NET.Sdk"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;OutputType&amp;gt;&lt;/span&gt;Exe&lt;span class="nt"&gt;&amp;lt;/OutputType&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TargetFramework&amp;gt;&lt;/span&gt;net6.0&lt;span class="nt"&gt;&amp;lt;/TargetFramework&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ImplicitUsings&amp;gt;&lt;/span&gt;enable&lt;span class="nt"&gt;&amp;lt;/ImplicitUsings&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Nullable&amp;gt;&lt;/span&gt;enable&lt;span class="nt"&gt;&amp;lt;/Nullable&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you remove the &lt;code&gt;&amp;lt;ImplicitUsings&amp;gt;&lt;/code&gt; line, for example, you would see build errors:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage-3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A word of caution: in .NET 6 implicit usings are enabled by default, so if implicit usings aren't for you, this is where you would disable it. For details, take a look at &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/implicit-namespaces" rel="noopener noreferrer"&gt;the following document&lt;/a&gt; from the .NET team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can I incorporate global usings with project configuration?
&lt;/h2&gt;

&lt;p&gt;To me, it does seem a little strange to be using C# source files to configure project details. If you don't want to use a C# file to specify your global using declarations, you can delete your file and &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-2/#global-usings" rel="noopener noreferrer"&gt;use MSBuild syntax instead&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you open your project file, you can encapsulate your global usings in an &lt;code&gt;&amp;lt;ItemGroup&amp;gt;&lt;/code&gt;, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Using&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"SuperheroApp.Models"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Using&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"System.Console"&lt;/span&gt; &lt;span class="na"&gt;Static=&lt;/span&gt;&lt;span class="s"&gt;"True"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Using&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"System.DateTime"&lt;/span&gt; &lt;span class="na"&gt;Alias=&lt;/span&gt;&lt;span class="s"&gt;"DT"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Do I have to use these?
&lt;/h2&gt;

&lt;p&gt;Much like other .NET 6 improvements, you can use it as much or as little as you want. You can use nothing but global and implicit &lt;code&gt;using&lt;/code&gt; statements, mix them with regular namespace declarations, or do things as we've always done before. It's all up to you.&lt;/p&gt;

&lt;p&gt;Between C# 9 top-level statements, implicit and global usings, and file-scoped namespaces, the C# team is removing a lot of clutter from your C# files. For example, here's how our &lt;code&gt;Program.cs&lt;/code&gt; file would look in C# 8 or older.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Collections.Generic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Linq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Program&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Tony"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Stark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Malibu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;500&lt;/span&gt;
                &lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Natasha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Romanova"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
                 &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;};&lt;/span&gt;

            &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Look, it's &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The first superhero in the list is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;First&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Last ran on &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;DT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With top-level statements and global and implicit usings, we now have this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Tony"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Stark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"10880 Malibu Point"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Malibu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;500&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Natasha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Romanova"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hero&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Look, it's &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The first superhero in the list is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;heroList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;First&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Last ran on &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;DT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What do you think? Let me know in the comments. Stay tuned for my next topic on CRUD endpoints with the new .NET 6 Minimal APIs.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>The .NET Stacks #66: 🧀 Who moved my cheese?</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Mon, 18 Oct 2021 00:38:34 +0000</pubDate>
      <link>https://dev.to/daveabrock/the-net-stacks-66-who-moved-my-cheese-5gfc</link>
      <guid>https://dev.to/daveabrock/the-net-stacks-66-who-moved-my-cheese-5gfc</guid>
      <description>&lt;p&gt;I know I'm a day or so late. Sorry, I was reading about Web 3.0 and still don't know what it is. Do you? After &lt;a href="https://thenewstack.io/web3-architecture-and-how-it-compares-to-traditional-web-apps/"&gt;reading this&lt;/a&gt;, it made me want to cry, laugh, and then cry again. As if Dapr and Dapper isn't enough, now we have "dapps."&lt;/p&gt;

&lt;p&gt;Anyway, here's what we have going on this week (or last week):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Who moved my cheese: New templates for .NET 6 might surprise you&lt;/li&gt;
&lt;li&gt;Community spotlight: Marten v4 is now live&lt;/li&gt;
&lt;li&gt;Last week in the .NET world&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Who moved my cheese: New templates for .NET 6 might surprise you
&lt;/h2&gt;

&lt;p&gt;As the release of .NET 6 is rapidly approaching—with .NET 6 RC2 coming out &lt;em&gt;very&lt;/em&gt; soon with the official release next month—you might be taken aback by C# template changes. The .NET team is leveraging top-level statements and implicit using directives for some new .NET 6 templates. For example, top-level statements are helping to drive new capabilities like &lt;a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#introducing-minimal-apis"&gt;Minimal APIs&lt;/a&gt;. Microsoft has put together a new document, &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates"&gt;&lt;em&gt;New C# templates generate top-level statements&lt;/em&gt;&lt;/a&gt;, and you should check it out.&lt;/p&gt;

&lt;p&gt;With .NET 6, if you create a new console app using &lt;code&gt;dotnet new console&lt;/code&gt; (or from Visual Studio tooling), you might expect to see this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;MyVerboseApp&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Program&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think again. You'll see this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// See https://aka.ms/new-console-template for more information&lt;/span&gt;
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much like with top-level statements, you probably have one of two opinions: it eliminates boilerplate and makes it simpler and more beginner-friendly; or it provides too many abstractions and "I didn't ask for this." I do like top-level statements and agree it eliminates a lot of boilerplate. When it comes to using &lt;code&gt;args&lt;/code&gt;, though, I like to see where they are being passed in and not just a magic variable.&lt;/p&gt;

&lt;p&gt;As of now, to stay consistent with Microsoft pushing to make C# more concise and accessible, it looks like this will be the default template. You can always &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates#use-the-old-program-style"&gt;use the "old" program style&lt;/a&gt; from the terminal using &lt;code&gt;framework&lt;/code&gt; and &lt;code&gt;target-framework-override&lt;/code&gt; flags. This allows you to use the "old" template but force the project framework to be .NET 6.0. (It would have been simpler to pass in &lt;code&gt;--leave-my-stuff-alone&lt;/code&gt;, but I digress.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet new console --framework net5.0 --target-framework-override net6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In terms of the tooling experience, the obvious answer will be to eventually introduce a checkbox in Visual Studio to enable/disable these simplified layouts. Until then, you can &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates#use-the-old-program-style-in-visual-studio"&gt;downgrade the target framework moniker&lt;/a&gt; (TFM) to &lt;code&gt;net5.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you don't like it, you can file an issue in the &lt;a href="https://github.com/dotnet/templating"&gt;dotnet/templating repo&lt;/a&gt; (or &lt;a href="https://github.com/dotnet/templating/issues/3654"&gt;chime in on a similar issue&lt;/a&gt;), or even &lt;a href="https://auth0.com/blog/create-dotnet-project-template/"&gt;create your own templates&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Community spotlight: Marten v4 is now live
&lt;/h2&gt;

&lt;p&gt;Do you know about Marten? It's a &lt;a href="https://martendb.io/introduction.html"&gt;popular .NET library&lt;/a&gt; that allows you to use Postgresql as both a document database and a powerful event store. Jeremy Miller &lt;a href="https://jeremydmiller.com/2021/10/08/marten-takes-a-giant-leap-forward-with-the-official-v4-release/"&gt;wrote this week&lt;/a&gt; about the new v4 release. Jeremy got my attention with quoting "the immortal philosopher Ferris Bueller" but also highlighted the massive changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reducing object allocations and dictionary lookups&lt;/li&gt;
&lt;li&gt;LINQ support improvements&lt;/li&gt;
&lt;li&gt;Better tracking for flexible metadata&lt;/li&gt;
&lt;li&gt;Event sourcing improvements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It looks to be a great release, and congrats to the team and all the great contributors. Check out &lt;a href="https://github.com/JasperFx/Marten"&gt;the GitHub repository&lt;/a&gt; for more details about the project.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌎 Last week in the .NET world
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📢 Announcements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Windows 11 &lt;a href="https://blogs.windows.com/windowsexperience/2021/10/04/windows-11-a-new-era-for-the-pc-begins-today"&gt;has arrived&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Mark Weitzel &lt;a href="https://garywoodfine.com/how-to-implement-cross-cutting-concerns-with-mediatr-pipeline-behaviours/"&gt;provides an update on the Azure REST API guidelines&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Azure SDK team &lt;a href="https://devblogs.microsoft.com/azure-sdk/announcing-the-new-azure-monitor-query-client-libraries/"&gt;rolls out new Azure Monitor client libraries&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Bri Achtman &lt;a href="https://devblogs.microsoft.com/dotnet/ml-net-and-model-builder-october-updates"&gt;writes about some ML.NET updates&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The GitHub Advisory Database &lt;a href="https://github.blog/2021-10-07-github-advisory-database-now-powers-npm-audit/"&gt;now powers&lt;/a&gt; &lt;code&gt;npm audit&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📅 Community and events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Last week was an eventful week for the .NET Foundation. I'm not going to rehash all the events—you can read &lt;a href="https://github.com/dotnet-foundation/Home/discussions/38#discussioncomment-1445759"&gt;a thread on the issues&lt;/a&gt;, now former Executive Director Claire Novotny's &lt;a href="https://github.com/dotnet-foundation/Home/discussions/39"&gt;apology&lt;/a&gt;, the comments surrounding it, and the announcement of a &lt;a href="https://github.com/dotnet-foundation/Home/discussions/40"&gt;change in leadership&lt;/a&gt;. Let's hope we see &lt;em&gt;structural&lt;/em&gt; changes, and don't unfairly scapegoat another invaluable member of the .NET community.&lt;/li&gt;
&lt;li&gt;Myles Borins &lt;a href="https://github.blog/2021-10-04-beta-github-releases-improving-release-experience/"&gt;announces a new public beta of GitHub Releases&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;DaprCon is a thing &lt;a href="https://blog.dapr.io/posts/2021/10/05/join-us-for-daprcon-october-19th-20th-2021/"&gt;and is happening next week&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;For community standups: .NET MAUI &lt;a href="https://www.youtube.com/watch?v=cEoSkHZlKa4"&gt;talks about Hot Reload&lt;/a&gt;, EF talks about &lt;a href="https://www.youtube.com/watch?v=2aCgKM41NFw"&gt;SQL Server temporal tables and EF Core 6&lt;/a&gt;, and ASP.NET &lt;a href="https://www.youtube.com/watch?v=1JnshGlNoBg"&gt;updates us on Orchard Core&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Netflix Blog writes about how they &lt;a href="https://netflixtechblog.com/safe-updates-of-client-applications-at-netflix-1d01c71a930c"&gt;safely update client applications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Community releases: Marten v4 &lt;a href="https://jeremydmiller.com/2021/10/08/marten-takes-a-giant-leap-forward-with-the-official-v4-release/"&gt;is now live&lt;/a&gt;, Blazored Toast v3.2 &lt;a href="https://twitter.com/BlazoredTweets/status/1446547399229550595"&gt;is released&lt;/a&gt;, and &lt;a href="https://cakebuild.net/blog/2021/10/cake-v1.3.0-released"&gt;Cake v1.3.0 is out&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;FluentValidation &lt;a href="https://twitter.com/JeremySkinner/status/1446086365767217152"&gt;has reached 100 million downloads&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌎 Web development
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;David Walsh &lt;a href="https://davidwalsh.name/css-accent-color"&gt;writes about the accent-color CSS property&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Damien Bowden &lt;a href="https://damienbod.com/2021/10/04/implement-a-secure-api-and-a-blazor-app-in-the-same-asp-net-core-project-with-azure-ad-authentication/"&gt;implements a secure API and a Blazor app in the same ASP.NET Core project with Azure AD authentication&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Litan Sarker &lt;a href="https://www.c-sharpcorner.com/article/developing-a-web-app-using-angular-12-asp-net-core-web-api-and-sql-server/"&gt;develops a web app with Angular 12, ASP.NET Core Web API, and SQL Server&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Mike Brind &lt;a href="https://www.mikesdotnetting.com/article/357/razor-pages-startup-in-net-6"&gt;writes about the Razor Pages startup experience in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Scott Hanselman &lt;a href="https://www.hanselman.com/blog/aspnet-core-diagnostic-scenarios"&gt;writes about Microsoft's guidance on ASP.NET Core diagnostic scenarios&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;David Ramel &lt;a href="https://visualstudiomagazine.com/articles/2021/10/01/azure-functions-4-preview.aspx"&gt;writes about Azure Functions support for .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Andrew Lock &lt;a href="https://andrewlock.net/exploring-dotnet-6-part-4-building-a-middleware-pipeline-with-webapplication/"&gt;builds a middleware pipeline with WebApplication&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Nwose Lotanna Victor writes about &lt;a href="https://www.telerik.com/blogs/things-developers-do-affect-web-app-load-time"&gt;things developers do&lt;/a&gt; to affect web app load time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🥅 The .NET platform
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Matthew Jones &lt;a href="https://swimburger.net/blog/dynamics/delaying-javascript-execution-until-html-elements-are-present-in-power-apps-and-dynamics-crm"&gt;writes about DateOnly and TimeOnly in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Khalid Abuhakmeh &lt;a href="https://khalidabuhakmeh.com/entity-framework-core-connectionstrings-for-dotnet-apps"&gt;walks through EF Core ConnectionStrings&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Code Maze blog &lt;a href="https://code-maze.com/dotnet-code-coverage/"&gt;writes about code coverage in .NET&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;David McCarter &lt;a href="https://www.c-sharpcorner.com/article/everything-that-every-net-developer-needs-to-know-about-disposable-types-prop/"&gt;writes about properly disposing of objects in .NET&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Scott Hanselman &lt;a href="https://www.hanselman.com/blog/differences-between-hashtable-vs-dictonary-vs-concurrentdictionary-vs-immutabledictionary"&gt;writes about the differences between Hashtable, Dictionary, ConcurrentDictionary, and ImmutableDictionary&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⛅ The cloud
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Microsoft Cloud Show &lt;a href="https://www.microsoftcloudshow.com/podcast/Episodes/429-Azure-App-Configuration/"&gt;talks about Azure App Configuration&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Niels Swimberghe &lt;a href="https://swimburger.net/blog/dynamics/collaborating-on-power-apps-using-personal-environments-power-platform-cli-git-and-azure-devops"&gt;collaborates on Power Apps using personal environments, Power Platform CLI, Git, and Azure DevOps&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Justin Yoo writes about &lt;a href="https://dev.to/azure/6-ways-azure-functions-endpoints-auth-via-openapi-4j0d"&gt;different ways to integrate Azure Functions auth with OpenAPI&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📔 Languages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Elijah Manor &lt;a href="https://elijahmanor.com/byte/js-fill-array"&gt;quickly populates a new array in JavaScript&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dave Brock &lt;a href="https://www.daveabrock.com/2021/10/05/csharp-10-file-scoped-namespaces/"&gt;works with file-scoped namespaces in C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Assis Zang &lt;a href="https://www.telerik.com/blogs/6-tips-writing-elegant-csharp-code"&gt;has 6 tips for writing elegant C# code&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Joël Quenneville asks: &lt;a href="https://thoughtbot.com/blog/who-is-empowered-by-your-design"&gt;who is empowered by your API design&lt;/a&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏗 Design, testing, and best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Peter Vogel &lt;a href="https://www.telerik.com/blogs/unit-testing-legacy-applications-dealing-legacy-code-justmock"&gt;uses JustMock to unit test legacy applications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Steven J. Vaughan-Nichols &lt;a href="https://thenewstack.io/the-latest-owasp-top-10-looks-a-lot-like-the-old-owasp/"&gt;writes about the refresh of the OWASP Top 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dennis Martinez &lt;a href="https://www.telerik.com/blogs/top-challenges-automated-end-to-end-testing"&gt;writes about challenges with automated end-to-end testing&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Sam Scott and Graham Neray &lt;a href="https://stackoverflow.blog/2021/10/06/best-practices-for-authentication-and-authorization-for-rest-apis/"&gt;write about best practices for authentication and authorization for REST APIs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Davide Bellone &lt;a href="https://www.code4it.dev/cleancodetips/use-same-name-for-same-concept"&gt;offers a clean code tip&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Sarah Drasner &lt;a href="https://leaddev.com/culture-engagement-motivation/why-flow-matters-more-passion"&gt;writes about why flow matters more than passion&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Derek Comartin writes about his &lt;a href="https://codeopinion.com/my-top-patterns-for-event-driven-architecture/"&gt;top patterns for event-driven architecture&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎤 Podcasts and videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Adventures in .NET &lt;a href="https://adventuresindotnet.com/want-to-pair-up-net-089"&gt;talk about pair programming&lt;/a&gt; and also &lt;a href="https://adventuresindotnet.com/advocate-for-yourself-part-2-net-088"&gt;continues the discussion on advocating for yourself&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jesse Liberty &lt;a href="https://jesseliberty.com/2021/10/07/mads-torgersen-on-c-10/?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+JesseLiberty-SilverlightGeek+%28Jesse+Liberty%29"&gt;talks to Mads Torgersen about C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The .NET Core Show talks to Carl-Hugo Marcotte &lt;a href="https://dotnetcore.show/episode-84-asp-net-core-5-design-patterns-with-carl-hugo-marcotte/"&gt;about ASP.NET Core 5 design patterns&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Visual Studio Toolbox &lt;a href="https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Solution-Filters-in-Visual-Studio"&gt;discusses Solution Filters in Visual Studio&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;On .NET talks about &lt;a href="https://www.youtube.com/watch?v=yVd7vbeFj-g"&gt;using DynamicData&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>azure</category>
    </item>
    <item>
      <title>The .NET Stacks #65: 💡 Is there hope for a modern C# model?</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Sun, 10 Oct 2021 16:33:00 +0000</pubDate>
      <link>https://dev.to/daveabrock/the-net-stacks-65-is-there-hope-for-a-modern-c-model-235i</link>
      <guid>https://dev.to/daveabrock/the-net-stacks-65-is-there-hope-for-a-modern-c-model-235i</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--03Y6kKmK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfdj4oyud8yggh97sy4s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--03Y6kKmK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfdj4oyud8yggh97sy4s.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Monday to you all and happy October. I hope you have a good week. My goal: to develop a data model &lt;a href="https://developer.apple.com/documentation/contacts/cnlabelcontactrelationyoungercousinmotherssiblingsdaughterorfatherssistersdaughter"&gt;simpler than this one&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's what we have this week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exploring modern C#&lt;/li&gt;
&lt;li&gt;Custom deployment layouts for Blazor WebAssembly apps&lt;/li&gt;
&lt;li&gt;Last week in the .NET world&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Exploring a modern subset of .NET's dominant language
&lt;/h2&gt;

&lt;p&gt;With the official release of .NET 6 next month, we'll see the release of C# 10. Much like the .NET platform as a whole, the language is beginning to adopt incremental, annual releases going forward. The &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10"&gt;C# 10 release brings us&lt;/a&gt; features like record structs, global using directives, extended property patterns, file-scoped namespaces, and so on. Richard Lander's .NET 6 RC2 announcement will be looking into some of these.&lt;/p&gt;

&lt;p&gt;As C# has shifted over the years from a strict OO language to a more general-purpose one, it's experienced some pushback on how heavy it's become. We tend to go in circles in the .NET community: yes, there's a lot—it needs to evolve to be a modern language, but it also can't break people who rely on the older features. Right on time, the newsletter Twitter account &lt;a href="https://twitter.com/dotnetstacks/status/1443334774500859914"&gt;posted a link&lt;/a&gt; to an article asking: is C# too complex? It spawned an interesting discussion, both about the article itself and of C#.&lt;/p&gt;

&lt;p&gt;I like what Kathleen Dollard, a Microsoft PM for .NET Core CLI and Languages, had to say:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--AubqmEXW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/413382903880380416/C9jH1b9f_normal.jpeg" alt="Kathleen Dollard profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Kathleen Dollard
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @kathleendollard
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/dotnetstacks"&gt;@dotnetstacks&lt;/a&gt; It seems you can have 2 of the 3: language evolution, backwards compat, one way to do things.&lt;br&gt;&lt;br&gt;Would you give up the simplicity of var or the simplification possible with tuples for a single way to do things?
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      23:35 PM - 29 Sep 2021
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1443358768616509445" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1443358768616509445" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1443358768616509445" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
 

&lt;p&gt;Still, I don't think it's realistic to expect a single way to do things, but it can get out of hand. As a simple example, there are at least a half dozen ways to check if a string is empty. It's that there are so many ways to do a single thing: some are modern and some best practices, some not—all the while, we know the language will never take anything away for backward compatibility reasons.&lt;/p&gt;

&lt;p&gt;For us experienced developers, we can say the language is evolving and just "use what works best for you." What if you don't, or don't want the mental weight of dealing with it all?&lt;/p&gt;

&lt;p&gt;As I was listening to C# language designer Mads Torgersen &lt;a href="https://nodogmapodcast.bryanhogan.net/157-mads-torgersen-c-10-part-1/"&gt;on Bryan Hogan's &lt;em&gt;No Dogma&lt;/em&gt; podcast&lt;/a&gt;, I found this following exchange quite interesting. (I know there's a lot in this exchange, but I wanted to post it all to avoid taking anything out of context.)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Q: &lt;strong&gt;All of these new features, feel like new ways of doing old things and I would imagine they could get confusing. A criticism about C# that's been around for a while is that there are so many ways to do one thing anyway, and now you've added a whole bunch of new ways to do things I could do already.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Yes. That's a real challenge. If you have a programming language and you want to keep it the best option for somebody making the next project, it has to be modern. It has to have ways of doing things that are as expressive, as sleek,  as ergonomic, performant, fast, and efficient as the other languages. So we have to keep evolving to do that. Now at the same time, we don't like throwing things out because we break people's existing code. What's a programming language designer to do?&lt;/p&gt;

&lt;p&gt;We've lived with this conundrum for a while. I think we're starting to circle in on at least a partial solution to it. I can't say for sure that we're going to do this or how we're going to do it, but ... someone like Bill Wagner, who is doing our documentation and working on the C# Standard ...he's very essential in this discussion, said: "How about we try to define modern C#?" If you're coming to C# fresh or even as an existing C# programmer in general—if you have a pretty clean slate, this is the subset that you should be using. If you're outside of that subset it's either because you're trying something fancy like using &lt;code&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt; to do efficiency stuff or unsafe code, or it's because you're doing some legacy things. Otherwise, these are the ways you should be doing things.&lt;/p&gt;

&lt;p&gt;And then we could reinforce that from the documentation point of view, from a learning point of view, and also from a tooling point of view—we would take these templates and take those little suggestions and say: "Hey, that's kind of an old fashioned thing you're doing there, it would be sleeker to use pattern matching here, why don't you?" In fact, we have plenty of those in place already. We just don't have a coordinated set of features that are like "this is modern C#."&lt;/p&gt;

&lt;p&gt;Then that evolves with the language, like when usings come in and some other things fall out of what modern C# is. And now there's a better way to do things. Now, we don't tell you to put usings on top of the file anymore, and we don't have guidelines about whether to prune or not ... that's just gone out of modern C# and now a modern C# programmer doesn't do that anymore.  A sliding window that's current C# might help as long as we don't make it a worse experience to use all of the language. But maybe we can make it an even better experience to use the modern part of the language and can give you more guidance if you're not a veteran or if you don't want to chase down all the reasons for doing one or the other and you just want a recommendation—how should I be doing this? This is what we're currently working on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I found this very interesting. A C# subset is not a new idea but I think Microsoft working on it is. In the past, I've seen some Microsoft resistance to that idea. It's early days but promising for the future of C#.&lt;/p&gt;




&lt;h2&gt;
  
  
  Custom deployment layouts for Blazor Web Assembly apps
&lt;/h2&gt;

&lt;p&gt;This week, on the ASP.NET Blog, Javier Calvarro Nelson &lt;a href="https://devblogs.microsoft.com/aspnet/custom-deployment-layout-for-blazor-webassembly-apps/"&gt;wrote about new .NET 6 extensibility points&lt;/a&gt; that will allow development teams to customize which files to package and publish with Blazor WebAssembly apps. The idea is that you could reuse this as a NuGet package. As Javier notes, this is important because some environments block and download the execution of DLLs from the network for security reasons.&lt;/p&gt;

&lt;p&gt;The article lays out how to build the package yourself, but you don't have to. According to Daniel Roth, you can use a &lt;a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.MultipartBundle"&gt;prebuilt experimental NuGet package&lt;/a&gt; to try it out. To use it, &lt;a href="https://devblogs.microsoft.com/aspnet/custom-deployment-layout-for-blazor-webassembly-apps/#using-the-multipartbundle-package"&gt;add a reference from your client project, update the server project to add the endpoint, and then publish your app&lt;/a&gt;. This is a good first step—hopefully, the end goal is to provide this out of the box.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌎 Last week in the .NET world
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📢 Announcements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Michael Staib &lt;a href="https://chillicream.com/blog/2021/09/27/hot-chocolate-12"&gt;releases Hot Chocolate 12&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jiachen Jiang &lt;a href="https://devblogs.microsoft.com/nuget/introducing-the-new-nuget-org-package-details-page"&gt;writes about the new nuget.org package details page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;JetBrains launches &lt;a href="https://blog.jetbrains.com/dotnet/2021/09/28/resharper-2021-3-eap/"&gt;the EAP for Resharper 2021.3&lt;/a&gt; and also for &lt;a href="https://blog.jetbrains.com/dotnet/2021/09/28/rider-2021-3-eap/"&gt;Rider 2021.3&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Javier Calvarro Nelson writes about &lt;a href="https://devblogs.microsoft.com/aspnet/custom-deployment-layout-for-blazor-webassembly-apps"&gt;custom deployment layouts for Blazor WebAssembly apps&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📅 Community and events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Rodney Littles II writes a difficult, but important, post about &lt;a href="https://rodneylittlesii.com/posts/topic/foundation-echo-chamber"&gt;his experience on the .NET Foundation board&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Carol Smith &lt;a href="https://cloudblogs.microsoft.com/opensource/2021/09/28/announcing-azure-credits-for-open-source-projects"&gt;announces Azure credits for open source projects&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Beau Carnes &lt;a href="https://www.freecodecamp.org/news/git-for-professionals/"&gt;launches a free Git for Professionals course&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Henning Dieterichs &lt;a href="https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization"&gt;writes about how the VS Code team made bracket pair colorization 1000x faster&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Austin Lamb introduces &lt;a href="https://devblogs.microsoft.com/performance-diagnostics/sizebench-a-new-tool-for-analyzing-windows-binary-size"&gt;SizeBench, a new tool for analyzing Windows binary size&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jeremy Miller &lt;a href="https://jeremydmiller.com/2021/09/28/efficient-web-services-with-marten-v4/"&gt;writes about how to build efficient web services with Marten v4&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌎 Web development
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Kristoffer Strube &lt;a href="https://blog.elmah.io/ahead-of-time-compilation-for-blazor-wasm/"&gt;uses Blazor AoT compilation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jon Hilton &lt;a href="https://jonhilton.net/blazor-component-folder-structure/"&gt;writes about how he organizes his Blazor components&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Nancy Young &lt;a href="https://www.webdesignerdepot.com/2021/09/the-pros-and-cons-of-tailwind-css/"&gt;writes about the pros and cons of Tailwind&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Andrew Lock &lt;a href="https://andrewlock.net/exploring-dotnet-6-part-3-exploring-the-code-behind-webapplicationbuilder/"&gt;explores the code behind WebApplicationBuilder in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⛅ The cloud
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Tomasz Pęczek &lt;a href="https://www.tpeczek.com/2021/09/handling-transient-errors-in-durable.html"&gt;handles transient errors in Azure Durable Functions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Mark Heath &lt;a href="https://markheath.net/post/azure-functions-isolated"&gt;asks: is it time to start creating C# Azure Functions in isolated mode?&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Steve Smith &lt;a href="https://ardalis.com/github-actions-on-demand/"&gt;writes about running GitHub Actions on demand&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📔 Languages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Michael Moreno asks: &lt;a href="https://medium.com/nerd-for-tech/is-c-getting-too-complicated-for-its-own-good-83c149a6faca"&gt;is C# getting too complex?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Vladimir Pecanac &lt;a href="https://code-maze.com/csharp-events/"&gt;explores events in C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Scott Hanselman &lt;a href="https://www.hanselman.com/blog/implicit-usings-in-net-6"&gt;writes about implicit usings in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Khalid Abuhakmeh &lt;a href="https://khalidabuhakmeh.com/compress-strings-with-dotnet-and-csharp"&gt;compresses strings with .NET and C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jeff Fritz &lt;a href="https://www.youtube.com/watch?v=sfe8UX9b9xM"&gt;introduces LINQ in C#&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Thomas Claudius Huber &lt;a href="https://www.thomasclaudiushuber.com/2021/09/30/c-10-global-using-directives/"&gt;uses global using directives in C# 10&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔧 Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Kubernetes Blog &lt;a href="https://kubernetes.io/blog/2021/09/29/how-to-handle-data-duplication-in-data-heavy-kubernetes-environments/"&gt;discusses how to handle data duplication&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Davide Bellone &lt;a href="https://www.code4it.dev/blog/testing-httpclientfactory-moq"&gt;tests HttpClientFactory with Moq&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;David Ramel &lt;a href="https://visualstudiomagazine.com/articles/2021/09/24/github-copilot-alternatives.aspx"&gt;writes how GitHub Copilot AI is spawning OSS Alternatives&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Christian Gunderman &lt;a href="https://devblogs.microsoft.com/visualstudio/avoiding-memory-leaks-in-visual-studio-editor-extensions"&gt;avoids memory leaks in Visual Studio editor extensions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Mike Melanson &lt;a href="https://thenewstack.io/docker-defends-desktop-pricing-says-support-led-to-faster-features/"&gt;writes about Docker defending their new Docker Desktop pricing&lt;/a&gt;, and the Docker Desktop &lt;a href="https://www.docker.com/blog/looking-for-a-docker-alternative-consider-this/"&gt;PR campaign continues&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Tobias Günther &lt;a href="https://css-tricks.com/creating-the-perfect-commit-in-git/"&gt;creates the perfect commit in Git&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Milan Milanović &lt;a href="https://milan.milanovic.org/post/cd-cd-with-azure-devops-yaml/"&gt;writes about CI/CD with Azure DevOps&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏗 Design, testing, and best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Derek Comartin &lt;a href="https://codeopinion.com/always-valid-domain-model/"&gt;talks about an always valid domain model&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Steve Smith &lt;a href="https://ardalis.com/grouping-assertions-in-tests/"&gt;groups assertions in tests&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Thomas Maurer &lt;a href="https://github.blog/2021-09-27-partitioning-githubs-relational-databases-scale/"&gt;writes about how GitHub partitions its relational databases&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Jimmy Bogard &lt;a href="https://jimmybogard.com/domain-driven-refactoring-encapsulating-collections"&gt;continues his DDD series with a write-up on encapsulating collections&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Peter Vogel &lt;a href="https://www.telerik.com/blogs/unit-testing-legacy-code-part-2-leveraging-mock-objects"&gt;continues his series on unit testing legacy code&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎤 Podcasts and videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Coding Blocks Podcast talks about &lt;a href="https://www.codingblocks.net/podcast/transactions-in-distributed-systems/"&gt;transactions in distributed systems&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;.NET Rocks &lt;a href="https://www.dotnetrocks.com/default.aspx?ShowNum=1759"&gt;talks to Mark Seemann about code that fits in your head&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Software Engineering Daily &lt;a href="https://softwareengineeringdaily.com/2021/09/30/git-scales-for-monorepos-with-derrick-stolee/"&gt;talks about scaling Git for monorepos&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The ASP.NET Monsters &lt;a href="https://www.youtube.com/watch?v=c0VwTzQ2gUQ"&gt;discuss new LINQ methods in .NET 6&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Azure Friday &lt;a href="https://channel9.msdn.com/Shows/Azure-Friday/Azure-Cosmos-DB-autoscale-session-state-monitoring-and-more"&gt;walks through CosmosDB&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Azure DevOps Podcast &lt;a href="http://azuredevopspodcast.clear-measure.com/azure-sql-database-with-anna-hoffman-episode-160"&gt;talks to Anna Hoffman about Azure SQL&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>azure</category>
    </item>
    <item>
      <title>Exploring C# 10: Save Space with File-Scoped Namespaces</title>
      <dc:creator>Dave Brock</dc:creator>
      <pubDate>Tue, 05 Oct 2021 03:35:27 +0000</pubDate>
      <link>https://dev.to/daveabrock/exploring-c-10-save-space-with-file-scoped-namespaces-1jfi</link>
      <guid>https://dev.to/daveabrock/exploring-c-10-save-space-with-file-scoped-namespaces-1jfi</guid>
      <description>&lt;p&gt;.NET 6 and C# 10 hit general availability &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10" rel="noopener noreferrer"&gt;next month&lt;/a&gt; (in November 2021). Much like I did &lt;a href="https://www.daveabrock.com/tag/csharp-9-2/" rel="noopener noreferrer"&gt;with C# 9 last year&lt;/a&gt;, I'd like to write about C# 10 over my next few posts. First, let's talk about a simple yet powerful capability: file-scoped namespace declarations.&lt;/p&gt;

&lt;p&gt;If you're new to C# and aren't familiar with what namespaces are, you can use a &lt;code&gt;namespace&lt;/code&gt; keyword to declare scopes that contain a set of related objects. What kind of objects? According to &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace" rel="noopener noreferrer"&gt;the Microsoft documentation&lt;/a&gt;, namespaces can have classes, interfaces, enums, structs, or delegates. By default, the C# compiler adds a default, unnamed namespace for you—typically referred to as the global namespace. When you declare a specific namespace, you can use identifiers present in the global namespace. See &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace" rel="noopener noreferrer"&gt;the C# docs&lt;/a&gt; for details.&lt;/p&gt;

&lt;p&gt;So, how can you declare namespaces in C# 9 and earlier? Keeping with my superhero theme with &lt;a href="https://www.daveabrock.com/tag/csharp-9-2/" rel="noopener noreferrer"&gt;my C# 9 posts&lt;/a&gt;, a &lt;code&gt;Superhero.cs&lt;/code&gt; class would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even with this simple example, you can see how much space this adds—both horizontally and vertically—with the indents and curly braces. With C# 10, you can make this cleaner with file-scoped namespaces.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use C# 10 file-scoped namespaces to simplify your code
&lt;/h2&gt;

&lt;p&gt;With C# 10, you can remove the curlies and replace it with a semicolon, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have &lt;code&gt;using&lt;/code&gt; statements in your file, you can have the namespace declaration either before or after it. However, it must come before any other members in a file, like your classes or interfaces. Many code analyzers like StyleCop &lt;a href="https://documentation.help/StyleCop/SA1200.html" rel="noopener noreferrer"&gt;encourage the use of usings inside namespaces&lt;/a&gt; to avoid type confusion.&lt;/p&gt;

&lt;p&gt;It's worth noting that as the "file-scoped" naming implies, this applies to any objects in the file—like classes, interfaces, structs, and so on. Also, you are limited to only defining one file-scoped namespace per file. You likely aren't surprised, as most of your files typically only have a single namespace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations with file-scoped namespaces
&lt;/h2&gt;

&lt;p&gt;Now, let's review what you cannot do with file-scoped namespaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mix traditional namespaces and file-scoped namespaces
&lt;/h3&gt;

&lt;p&gt;If you want to mix a non-C# 10 namespace declaration and a file-scoped namespace, you can't. Here's what you'll see from Visual Studio.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fimage.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Define multiple file-scoped namespaces
&lt;/h3&gt;

&lt;p&gt;What if you want multiple namespaces in a file like this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models.Marvel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MarvelSuperhero&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;MoviesIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As discussed previously, you can only define one file-scoped namespace per file. It won't work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fmultiple-fs-namespaces-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fmultiple-fs-namespaces-1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to accomplish this, you'll need to stay old school and define namespace declarations as you usually have.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models.Marvel&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MarvelSuperhero&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;MoviesIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nesting namespaces
&lt;/h3&gt;

&lt;p&gt;With traditional namespaces, you can nest them like in the following example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;StreetAddress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MaxSpeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;SuperheroApp.Models.Marvel&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MarvelSuperhero&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Superhero&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;MoviesIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, you can not do this with file-scoped namespaces. When I try to do this, I'll get another compiler error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fnested-namespaces.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.daveabrock.com%2Fcontent%2Fimages%2F2021%2F10%2Fnested-namespaces.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up: another way to simplify C# code
&lt;/h2&gt;

&lt;p&gt;If you've been following the last couple of C# releases, you've noticed this isn't the first change to simplify boilerplate code—see positional C# records and top-level statements for a few examples—and it likely won't be the last, either. Changes like this allow you to simplify your programs and cut out boilerplate.&lt;/p&gt;

&lt;p&gt;In the next post, I'll continue this theme by writing about &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10#global-using-directives" rel="noopener noreferrer"&gt;global using directives&lt;/a&gt; in C# 10. I'll talk to you then.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
  </channel>
</rss>
