Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

What's New in .NET 7

.NET 7 builds on top of .NET 6, which includes a unified set of base libraries, runtime, and SDK, a simplified development experience, and higher developer productivity. Major areas of focus for .NET 7 include improved support for cloud native scenarios, tools to make it easier to upgrade legacy projects, and simplifying the developer experience by making it easier to work with containers.

What's New in .NET 7 Group By Preview

Several improvements have been made in .NET 7 Previews 1, 2 and 3, some of them we will cover in some demos.

Preview 1

  • Nullable annotations for Microsoft.Extensions
  • JIT compiler optimizations
  • New APIs
  • Support for more hot reload scenarios

Preview 2

  • Specialized RegEx pattern matching engine
  • Improved tab completion capabilities to explore templates and parameters when using dotnet new
  • App Trimming due to NativeAOT (Native Ahead of Time compilation) support.

Preview 3

  • Native AOT
  • Default GC regions
  • ASP.NET Core startup time improvements

Demos

Download .NET 7

Download and install latest version of .NET 7.

Latest Version Download
7.0.100-preview.3 https://dotnet.microsoft.com/en-us/download/dotnet/7.0

Create a Console Application in Visual Studio 2022 Preview

Create a new project

picture 1

Configure your new project

picture 2

Select .NET 7.0 (Preview) and click Create

picture 3

Program.cs looks the same as .NET 6.0

picture 4

But the .csproj has a new TargetFramework

picture 5

Available TargetFrameworks

By default, if you select .NET 7.0 (Preview,) your project will be ready to take advantage of the .NET 7.0 features, if you are upgrading a .NET 6 project to .NET 7, all you have to do is to change the TargetFramework value from net6.0 to .net7.0 as shown below.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>

The available options for the TargetFramework Monicker are shown below:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <!--Available TargetFramework values
    net7.0
    net7.0-android
    net7.0-ios
    net7.0-maccatalyst
    net7.0-macos
    net7.0-tvos
    net7.0-windows-->
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>

StringSyntaxAttribute

This new attribute allows you to specify what kind of data a string represents, for example Regex, JSON, or a DateTime. This will be use to support more syntax highlighting and colorization options.

Before

picture 11

After

picture 10

Note

Resource dotnet/runtime#62505

Hot Reload Improvements

Hot Reload now has support for the following edit operations in C# for Blazor WebAssembly and .NET for iOS and Android

  • Adding static lambdas to existing methods
  • Adding lambdas that capture this to existing methods that already have at least one lambda that captures this
  • Adding new static or non-virtual instance methods to existing classes
  • Adding new static fields to existing classes
  • Adding new classes

Nullable Annotations for Microsoft.Extensions

As of .NET 7 Preview 1 the following Microsoft.Extensions libraries have been annotated for Nullability:

  • Microsoft.Extensions.DependencyInjection.Abstractions
  • Microsoft.Extensions.Logging.Abstractions
  • Microsoft.Extensions.Primitives
  • Microsoft.Extensions.FileSystemGlobbing
  • Microsoft.Extensions.DependencyModel
  • Microsoft.Extensions.Configuration.Abstractions
  • Microsoft.Extensions.FileProviders.Abstractions
  • Microsoft.Extensions.FileProviders.Physical
  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.Configuration.Binder
  • Microsoft.Extensions.Configuration.CommandLine
  • Microsoft.Extensions.Configuration.EnvironmentVariables
  • Microsoft.Extensions.Configuration.FileExtensions
  • Microsoft.Extensions.Configuration.Ini
  • Microsoft.Extensions.Configuration.Json

By the time .NET 7 is released, all Microsoft.Extensions libraries are planned to be annotaded for Nullability.

CLI

The dotnet new command has been given a more consistent and intuitive interface for many of the subcommands that users already use. Support for tab completion of template options and arguments has been enhanced, now giving rapid feedback on valid arguments and options as the user types.

dotnet new -help

 carl ❯❯ dotnet new --help
Description:
  Template Instantiation Commands for .NET CLI.

Usage:
  dotnet new [<template-short-name> [<template-args>...]] [options]
  dotnet new [command] [options]

Arguments:
  <template-short-name>  A short name of the template to create.
  <template-args>        Template specific options to use.

Options:
  -?, -h, --help  Show command line help.

Commands:
  install <package>       Installs a template package.
  uninstall <package>     Uninstalls a template package.
  update                  Checks the currently installed template packages for update, and install the updates.
  search <template-name>  Searches for the templates on NuGet.org.
  list <template-name>    Lists templates containing the specified template name. If no name is specified, lists all templates.

Resources

Resource Title Url
.NET 7 Downloads https://dotnet.microsoft.com/en-us/download/dotnet/7.0
ASP.NET Core Roadmap for .NET 7 dotnet/aspnetcore#39504
Announcing .NET 7 Preview 1 https://devblogs.microsoft.com/dotnet/announcing-net-7-preview-1/
Announcing .NET 7 Preview 2 – The New, ‘New’ Experience https://devblogs.microsoft.com/dotnet/announcing-dotnet-7-preview-2/
Announcing .NET 7 Preview 2 https://devblogs.microsoft.com/dotnet/announcing-dotnet-7-preview-3/
StringSyntaxAttribute dotnet/runtime#62505

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages