.NET7 Deep Dive
Udaiappa Ramachandran ( Udai )
https://udai.io
About me
• Udaiappa Ramachandran ( Udai )
• CTO-Akumina, Inc.
• Microsoft Azure MVP
• Cloud Expert
• Microsoft Azure, Amazon Web Services, and Google
• New Hampshire Cloud User Group (http://www.meetup.com/nashuaug )
• https://udai.io
Agenda
• .NET 7
• CLI & Documentation
• ASP.NET Core 7
• .NET MAUI
• Containers support
• Regular Expressions
• JSON Improvements
• AOT
• Demo…Demo…Demo…
.NET 6
https://udai.io/boston-net-6-deep-dive-virtual/
.NET 7 Downloads
https://dotnet.microsoft.com/en-us/download/dotnet/7.0
RoadMap
https://themesof.net/roadmap?product=.NET&release=7.0
CLI & Documentation
• Tab completion (PowerShell, bash, zsh, fish)
• dotnet add p<TAB>
• Tab completion for add will list the templates
• Angular, blazorserver, blazorwasm, classlib, console, editorconfig, gitignore, grpc, mstest, mvc,
nugetconfig, nunit, page, proto, razor, react, sln, tool-manifest, viewimports, viewstart, xunit,
web, webapi, webapp, webconfig, winforms, wpf, wpflib
• Documentation
• dotnet new--help
ASP.NET Core
• RateLimitter
• CacheOutput
• Minimal API Filters
• Binding QueryString to array of primitive types
• SignalR
• Nullable types support in MVC and Razor pages
• Blazor WebAssembly
• Access to Hardware API such as filesystem, webcam, etc.,
• Location changing Event
• JavaScript Interop to invoke .NET code
• HTTP 3 (preview)
Zero-to-Container
https://devblogs.microsoft.com/dotnet/announcing-builtin-container-support-for-the-dotnet-sdk/
.NET MAUI
• MAP Control
• Desktop UI improvements
• Context menu via the MenuFlyout control
• Tooltips
• Gestures
• Window size and position with size changed event
• Simplified IDE MAUI App
Regular Expressions
• Fast as compiled Regex
• Faster startup
• Better debugging
• New Regex source generator
• Regex Analyzers and Fixers
https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/
JSON Improvements
• Serialize/Deserialize Object state to JSON Text
• System.Text.Json support polymorphic type hierarchy using JsonDerivedType
attributes
• JSON contract customization (automatic in .net 6 and earlier) using resolver
• Serialize private fields and properties
• Support multiple names for a property
• Ignore properties, based on name, type or value
AOT (Ahead-Of-Compilation)
• AOT generates machine code at build time
• Machine code is targeting specific OS and Hardware
• Multiple Executables against Win32, Win64, Linux64, etc.,
• Everything is platform native like Go, Swift and Rust are compiled
• .NET AOT Tools
• .NET 6
• CrossGen2
• ReadyToRun
• Mano AOT for Mobile
• .NET 7
• Native AOT
• Not a replacement of existing technologies but it adds new capabilities
• <publishAot>true</publishAot>
AOT (Ahead-Of-Compilation)
• Pros
• Faster startup time
• Smaller file size
• Smaller memory footprint on computer
• Cons
• Console apps only
• No reflection allowed
• No dynamic loading
• No runtime code generation
Central Package Management
• Create Directory.Packages.props with ManagePackageVersionsCentrally to
true and include Version
• Declare PackageReference items without Version attributes in project files
https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management
Some of Other Improvements
• Brotli Compression
• Observability
• DateTime
• Tar Archives
• On-Stack Replacement (OSR)
• Profile-Guided Optimization (PGO)
• Much more……
Reference
• What’s new in .NET7: https://learn.microsoft.com/en-us/dotnet/core/whats-
new/dotnet-7
• Performance Improvements:
https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7
• YouTube Performance Improvements:
https://www.youtube.com/watch?v=yNPEdaxkTZw
• RoadMap: https://themesof.net/roadmap?product=.NET&release=7.0
• C#11: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11
• F#7: https://devblogs.microsoft.com/dotnet/announcing-fsharp-7
• Demo Samples: https://github.com/nhcloud/techtalk

.NET7.pptx

  • 1.
    .NET7 Deep Dive UdaiappaRamachandran ( Udai ) https://udai.io
  • 2.
    About me • UdaiappaRamachandran ( Udai ) • CTO-Akumina, Inc. • Microsoft Azure MVP • Cloud Expert • Microsoft Azure, Amazon Web Services, and Google • New Hampshire Cloud User Group (http://www.meetup.com/nashuaug ) • https://udai.io
  • 3.
    Agenda • .NET 7 •CLI & Documentation • ASP.NET Core 7 • .NET MAUI • Containers support • Regular Expressions • JSON Improvements • AOT • Demo…Demo…Demo…
  • 4.
  • 5.
  • 6.
  • 7.
    CLI & Documentation •Tab completion (PowerShell, bash, zsh, fish) • dotnet add p<TAB> • Tab completion for add will list the templates • Angular, blazorserver, blazorwasm, classlib, console, editorconfig, gitignore, grpc, mstest, mvc, nugetconfig, nunit, page, proto, razor, react, sln, tool-manifest, viewimports, viewstart, xunit, web, webapi, webapp, webconfig, winforms, wpf, wpflib • Documentation • dotnet new--help
  • 8.
    ASP.NET Core • RateLimitter •CacheOutput • Minimal API Filters • Binding QueryString to array of primitive types • SignalR • Nullable types support in MVC and Razor pages • Blazor WebAssembly • Access to Hardware API such as filesystem, webcam, etc., • Location changing Event • JavaScript Interop to invoke .NET code • HTTP 3 (preview)
  • 9.
  • 10.
    .NET MAUI • MAPControl • Desktop UI improvements • Context menu via the MenuFlyout control • Tooltips • Gestures • Window size and position with size changed event • Simplified IDE MAUI App
  • 11.
    Regular Expressions • Fastas compiled Regex • Faster startup • Better debugging • New Regex source generator • Regex Analyzers and Fixers https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/
  • 12.
    JSON Improvements • Serialize/DeserializeObject state to JSON Text • System.Text.Json support polymorphic type hierarchy using JsonDerivedType attributes • JSON contract customization (automatic in .net 6 and earlier) using resolver • Serialize private fields and properties • Support multiple names for a property • Ignore properties, based on name, type or value
  • 13.
    AOT (Ahead-Of-Compilation) • AOTgenerates machine code at build time • Machine code is targeting specific OS and Hardware • Multiple Executables against Win32, Win64, Linux64, etc., • Everything is platform native like Go, Swift and Rust are compiled • .NET AOT Tools • .NET 6 • CrossGen2 • ReadyToRun • Mano AOT for Mobile • .NET 7 • Native AOT • Not a replacement of existing technologies but it adds new capabilities • <publishAot>true</publishAot>
  • 14.
    AOT (Ahead-Of-Compilation) • Pros •Faster startup time • Smaller file size • Smaller memory footprint on computer • Cons • Console apps only • No reflection allowed • No dynamic loading • No runtime code generation
  • 15.
    Central Package Management •Create Directory.Packages.props with ManagePackageVersionsCentrally to true and include Version • Declare PackageReference items without Version attributes in project files https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management
  • 16.
    Some of OtherImprovements • Brotli Compression • Observability • DateTime • Tar Archives • On-Stack Replacement (OSR) • Profile-Guided Optimization (PGO) • Much more……
  • 17.
    Reference • What’s newin .NET7: https://learn.microsoft.com/en-us/dotnet/core/whats- new/dotnet-7 • Performance Improvements: https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7 • YouTube Performance Improvements: https://www.youtube.com/watch?v=yNPEdaxkTZw • RoadMap: https://themesof.net/roadmap?product=.NET&release=7.0 • C#11: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11 • F#7: https://devblogs.microsoft.com/dotnet/announcing-fsharp-7 • Demo Samples: https://github.com/nhcloud/techtalk

Editor's Notes

  • #9 Asp.NET Core, Razor Pages, Web API, Blazor SignalR supports for strongly typed clients and requesting results from client invocations. injecting services through DI Hub constructors can accept services from the DI as parameters Minimal API filters to implement business logic that supports code running before, after the route handler, inspecting and modifying parameters provided during the route handler invocation, and intercepting the response behavior of a route handler. Nullable page models for Razor pages and nullable View models for MVC Blazor components within WebView control in the desktop UI access to underlying hardware API to access local file system, webcam. Blazor location changing events -- alert unsaved works JavaScript interop to invoke .NET code (open .NET code from JavaScript using .NET web assembly runtime as well as call into JavaScript functionality from .NET without any dependency on the Blazor UI component model. without dependency
  • #10 Announcing built-in container support for the .NET SDK - .NET Blog (microsoft.com) # create a new project and move to its directory dotnet new mvc -n my-awesome-container-app cd my-awesome-container-app # add a reference to a (temporary) package that creates the container dotnet add package Microsoft.NET.Build.Containers # publish your project for linux-x64 dotnet publish --os linux --arch x64 -c Release -p:PublishProfile=DefaultContainer # run your app using the new container docker run -it --rm -p 5010:80 my-awesome-container-app:1.0.0
  • #11 Windows, macos, ios and android share UI layout and design across platforms Map control delegates the native map rendering to native mobile platform (ios –apple mapss), android (google maps) Pointer gestures, hovering mouse for secondary gestures
  • #12 RegEx is pattern matching is a complex algorithm .NET 5 Rosyln as a source generator Not helpful if regex pattern is not known at compile time Regex analyzers and fixers https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/ IndexOf improvements
  • #14 Dotnet publish –r win-x64 –c release code should be compiled into machine code .net and java relied on JIT -- where code is complied twice one in developer compiletime and JIT at runtime advantage of JIT is to run any platform, one exe can be run in multiple platform AOT generates machine code at build time, machine code is targets specic operating system and hardware architecture such as x64,32 etc., AOT you must compile multiple executable Win32, Win64,Linux64 Native AOT full native pre-compilation (desktop client and services scenario) NAOT not replacing existing technologies, new set of cababilities for unlocking several form factors everything is platform native simillar to how Go,Swift, and Rust are compiled
  • #15 Dotnet publish –r win-x64 –c release Pros when startup time matters the most smaller file sie smaller memory footprint on computer.NET AOT Tools Cons console apps only no reflection allowed no dynamic loading no runtime code generation (sytem.reflection.init)
  • #17 OSR is complement to Tiered compilation (introduced in .net core 3.0) <TieredPGO>true</TieredPGO> Instrument, Train and Optimize