Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's new in .NET 7 Preview 2 [WIP] #7107

Closed
leecow opened this issue Jan 11, 2022 · 14 comments
Closed

What's new in .NET 7 Preview 2 [WIP] #7107

leecow opened this issue Jan 11, 2022 · 14 comments

Comments

@leecow
Copy link
Member

leecow commented Jan 11, 2022

What's new in .NET 7 Preview 2

This issue is for teams to highlight work for the community that will release .NET 7 Preview 1

To add content, use a new conversation entry. The entry should include the team name and feature title as the first line as shown in the template below.

## Team Name: Feature title

[link to the tracking issue or epic item for the work]

Tell the story of the feature and anything the community should pay particular attention 
to be successful using the feature.

Preview 1: #7106
Preview 2: #7107
Preview 3: #7108
Preview 4: #7378
Preview 5: #7441
Preview 6: #7454
Preview 7: #7455

@joperezr
Copy link
Member

joperezr commented Mar 2, 2022

Note: This feature has been present since Preview 1 but didn't make it to the Preview 1 blog post, so copying the content here again in order to get it into Preview 2 blog.

Introducing the new Regex Source Generator

dotnet/runtime#44676

Ever wished you had all of the great benefits that come from having a specialized Regex engine that is optimized for your particular pattern, without having to pay the costs of building this engine at runtime? We are excited to announce the new Regex Source Generator which is included in Preview 1. It brings all of the performance benefits from our Compiled engine without the startup cost, and it has additional benefits, like providing a great debugging experience as well as being trimming-friendly. If your pattern is known at compile-time, then the new regex source generator is the way to go.

In order to start using it, you only need to turn the containing type into a partial one, and declare a new partial method with the RegexGenerator attribute that will return the optimized Regex object, and that's it! The source generator will fill the implementation of that method for you, and will get updated automatically as you make changes to your pattern or to the additional options that you pass in. Here is an example:

Before:

public class Foo
{
  public Regex regex = new Regex(@"abc|def", RegexOptions.IgnoreCase);

  public bool Bar(string input)
  {
    bool isMatch = regex.IsMatch(input);
    // ..
  }
}

After:

public partial class Foo  // <-- Make the class a partial class
{
  [RegexGenerator(@"abc|def", RegexOptions.IgnoreCase)] // <-- Add the RegexGenerator attribute and pass in your pattern and options
  public static partial Regex MyRegex(); //  <-- Declare the partial method, which will be implemented by the source generator

  public bool Bar(string input)
  {
    bool isMatch = MyRegex().IsMatch(input); // <-- Use the generated engine by invoking the partial method.
    // ..
  }
}

And that's it. Please try it out and let us know if you have any feedback.

@JulieLeeMSFT
Copy link
Member

JulieLeeMSFT commented Mar 3, 2022

CodeGen

Community PRs (Many thanks to JIT community contributors!!)

From @sandreenko

From @SingleAccretion

From @Wraith2

Dynamic PGO

Arm64

General Optimizations

@tarekgh
Copy link
Member

tarekgh commented Mar 4, 2022

Observability

static Meter s_meter = new Meter("MyLibrary.Queues", "1.0.0");
static UpDownCounter<int> s_queueSize = s_meter.CreateUpDownCounter<int>("Queue-Size");
static ObservableUpDownCounter<int> s_pullQueueSize = s_meter.CreateObservableUpDownCounter<int>("Queue-Size", () => s_pullQueueSize);

...

s_queueSize.Add(10);
s_queueSize.Add(-2);

@AngelosP
Copy link

AngelosP commented Mar 4, 2022

The PR for blog post; will remain open until Monday 3/14 noon (PST)
Create dotnet-7-preview-2.md · Pull Request #784 · microsoft/dotnet-blog (github.com)

The plan is to work on the content in the PR until noon (PST) on Monday 3/14. After that the content will be copied over to the blog and we can make any last minute changes if needed there.

@baronfel
Copy link
Member

baronfel commented Mar 8, 2022

SDK Improvements

dotnet new syntax and tab-completion

dotnet/templating#2191

For 7.0.100-preview2, the dotnet new command has been given a more consistent and intuitive interface for many of the subcommands that users already use. In addition, support for tab-completion of template options and arguments has been massively updated, now giving rapid feedback on valid arguments and options as the user types.

Here's the new help output as an example:

❯ 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.

New Command Names

Specifically, all of the commands in this help output no longer have the -- prefix that they do today. This is more in line with what users expect from subcommands in a CLI application. The old versions (--install, etc) are still available to prevent breaking user scripts, but we hope to add obsoletion warnings to those commands in the future to encourage migration.

Tab Completion

The dotnet CLI has supported tab completion for quite a while on popular shells like PowerShell, bash, zsh, and fish (instructions for enabling that can be found here). It's up to individual dotnet commands to implement meaningful completions, however. For .NET 7, the new command learned how to provide tab completion for

  • available template names (in dotnet new <template-short-name>
❯ dotnet new angular
angular              grpc                 razor                viewstart            worker               -h
blazorserver         mstest               razorclasslib        web                  wpf                  /?
blazorwasm           mvc                  razorcomponent       webapi               wpfcustomcontrollib  /h
classlib             nugetconfig          react                webapp               wpflib               install
console              nunit                reactredux           webconfig            wpfusercontrollib    list
editorconfig         nunit-test           sln                  winforms             xunit                search
gitignore            page                 tool-manifest        winformscontrollib   --help               uninstall
globaljson           proto                viewimports          winformslib          -?                   update
  • template options (the list of template options in the web template)
❯ dotnet new web --dry-run
--dry-run                  --language                 --output                   -lang
--exclude-launch-settings  --name                     --type                     -n
--force                    --no-https                 -?                         -o
--framework                --no-restore               -f                         /?
--help                     --no-update-check          -h                         /h
  • allowed values for those template options (choice values on an choice template argument)
❯ dotnet new blazorserver --auth Individual
Individual     IndividualB2C  MultiOrg       None           SingleOrg      Windows

There are a few known gaps in completion - for example, --language doesn't suggest installed language values.

Future work

In future previews we plan to continue filling gaps left by this transition, as well as make enabling completions either automatic or as simple as a single command that the user can execute. We hope that this will make improvements in tab-completion across the entire dotnet CLI more broadly used by the community!

What's next

dotnet new users - go enable tab completion and try it for your templating use! Template authors - try out tab completion for the options on your templates and make sure you're delivering the experiences you want your users to have. Everyone - raise any issues you find on the dotnet/templating repo and help us make .NET 7 the best release for dotnet new ever!

@AngelosP
Copy link

AngelosP commented Mar 11, 2022

Introducing the new Regex Source Generator

Added it to the draft of the blog post

@AngelosP
Copy link

AngelosP commented Mar 11, 2022

CodeGen

Added it to the draft of the blog post

@AngelosP
Copy link

SDK Improvements

Added it to the draft of the blog post

@AngelosP
Copy link

Observability

Added it to the draft of the blog post

@AngelosP
Copy link

AngelosP commented Mar 11, 2022

Logging Source Generator

Added it to the draft of the blog post

@agocke
Copy link
Member

agocke commented Mar 14, 2022

NativeAOT Update

We previously announced that we're moving the NativeAOT project out of experimental status and into mainline development in .NET 7. Over the past few months we've been heads down doing the coding to move NativeAOT out of the experimental dotnet/runtimelab repo and into the dotnet/runtime repo. That work has now been completed, but we have yet to add first-class support in the dotnet SDK for publishing projects with NativeAOT. We hope to have that work done shortly, so you can try out NativeAOT with your apps. In the meantime, please try trimming your app and ensure there are no trim warnings. Trimming is a requirement of NativeAOT. If you own any libraries there are also instructions for preparing libraries for trimming.

@JeremyLikness
Copy link
Member

Adding NativeAOT update now...

@leecow
Copy link
Member Author

leecow commented Jan 24, 2023

.NET 7 GA is available. Closing these pre-release issues.

@leecow leecow closed this as completed Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants