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 8 RC 1 [WIP] #8439

Closed
3 tasks
leecow opened this issue May 3, 2023 · 10 comments
Closed
3 tasks

What's new in .NET 8 RC 1 [WIP] #8439

leecow opened this issue May 3, 2023 · 10 comments
Assignees

Comments

@leecow
Copy link
Member

leecow commented May 3, 2023

What's new in .NET 8 RC 1

This issue is for teams to highlight work for the community that will release in .NET 8 RC 1

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

Required

## 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 in using the feature.

Optional

Below are three additional items to consider. These will help the .NET 8 blog team and the community throughout the release.

  • Link to documentation.
    • Where can we send people to learn more about the feature?
  • Link to where you'd like people to provide feedback for this feature.
    • Where can people best comment on the direction of this feature?
  • Whether you would like assistance from the .NET 8 writers to craft a story for this feature.

Index of .NET 8 releases

Preview 1: #8133
Preview 2: #8134
Preview 3: #8135
Preview 4: #8234
Preview 5: #8436
Preview 6: #8437
Preview 7: #8438
RC 1: #8439
RC 2: #8440

@fanyang-mono
Copy link
Member

fanyang-mono commented Aug 18, 2023

WasmStripILAfterAOT mode on WASM

dotnet/runtime#88926

Blazor WebAssembly and WASM Browser support ahead-of-time (AOT) compilation, where you can compile your .NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size. This new stripping mode reduces the size of _framework folder by 1.7% - 4.2%, based on the testing we've done mentioned in the above github issue.

When to consider using WasmStripILAfterAOT:

This feature is ideal any time you enable AOT compilation, so give it a try for a smaller application!

How to use WasmStripILAfterAOT:

Set the following MsBuild property for your Blazor WebAssembly or WASM Browser app:

<PropertyGroup>
  <RunAOTCompilation>true</RunAOTCompilation>
  <WasmStripILAfterAOT>true</WasmStripILAfterAOT>
</PropertyGroup>

It will trim away the IL code for most of the compiled methods, including methods from the libraries and the ones authored by the app developers.

Limitations:

Not all of the compiled methods are trimmable. At runtime, there are various scenarios where we have to switch from AOT to interpreter to produce the correct result. With that said, we will be continuously working on reducing the gap in the upcoming .NET9 release.

Final note

We would like to invite everyone to try out this new feature and file any discovered issues to help us improve the user experience further. Issues can be filed directly to dotnet/runtime repository.

@elinor-fung
Copy link
Member

Cross-building Windows apps with Win32 resources on non-Windows

Issue: dotnet/runtime#3828
PR: dotnet/runtime#89303

Many thanks to @anatawa12 for this great contribution!

When building applications targeting Windows on non-Windows platforms, the resulting executable is now updated with any specified Win32 resources - for example, application icon, manifest, version information.

Previously, applications had to be built on Windows in order to have such resources. Fixing this gap in cross-building support has been a popular request, as it was a significant pain point affecting both infrastructure complexity and resource usage.

@mthalman
Copy link
Member

Containers switch to non-preview tagging pattern

Issue: dotnet/dotnet-docker#4772
PR: dotnet/dotnet-docker#4817

In preparation for the GA release of .NET 8, the .NET container images have switched to a new tagging pattern for RC 1 that removes "preview" from the tag name.

In previous preview releases of .NET 8, floating tags were published with the name of 8.0-preview and 8.0-preview-<OS>. These will no longer be maintained starting with the RC 1 release. Instead, you should migrate your tag references to 8.0 or 8.0-<OS>. Making this change will allow for a seamless transition upon the GA release of .NET 8 as these will be the permanent tags that will be maintained throughout the lifetime of .NET 8.

@layomia
Copy link

layomia commented Sep 1, 2023

Breaking change

The configuration binding generator has switched to using the compiler interceptors preview feature to emit binding logic - dotnet/runtime#90835.

In non Web SDK scenarios (i.e. apps that require a Microsoft.Extensions.Configuration.Binder package reference for binding, like console apps), the following additional MSBuild property is now required to enable the generator:

<PropertyGroup>
  <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
+ <Features>$(Features);InterceptorsPreview</Features>
</PropertyGroup>

This is temporary. In RC-2, enabling the generator will switch back to only requiring the one gesture. The compiler inceptors feature will be enabled implicitly in a reliable way.

<PropertyGroup>
  <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
- <Features>$(Features);InterceptorsPreview</Features>
</PropertyGroup>

@dotnet/area-extensions-configuration @captainsafia @eerhardt.

@eiriktsarpalis
Copy link
Member

System.Text.Json Improvements

System.Net.Http.Json extensions for IAsyncEnumerable dotnet/runtime#89258

RC1 sees the inclusion of IAsyncEnumerable streaming deserialization extension methods:

const string RequestUri = "https://api.contoso.com/books";
using var client = new HttpClient();
IAsyncEnumerable<Book> books = await client.GetFromJsonAsAsyncEnumerable<Book>(RequestUri);

await foreach (Book book in books)
{
    Console.WriteLine($"Read book '{book.title}'");
}

public record Book(int id, string title, string author, int publishedYear);

Credit to @IEvangelist for contributing the implementation.

JsonContent.Create overloads accepting JsonTypeInfo dotnet/runtime#89614

It is now possible to create JsonContent instances using trim safe/source generated contracts:

var book = new Book(id: 42, "Title", "Author", publishedYear: 2023);
HttpContent content = JsonContent.Create(book, MyContext.Default.Book);

public record Book(int id, string title, string author, int publishedYear);

[JsonSerializable(typeof(Book))]
public partial class MyContext : JsonSerializerContext 
{ }

Credit to @brantburnett for contributing the implementation.

JsonNode.ParseAsync APIs dotnet/runtime#90006

Adds support for parsing JsonNode instances from streams:

using var stream = File.OpenRead("myFile.json");
JsonNode node = await JsonNode.ParseAsync(stream);

Credit to @DoctorKrolic for contributing the implementation.

JsonSerializerOptions.MakeReadOnly(bool populateMissingResolver) dotnet/runtime#90013

The existing parameterless JsonSerializerOptions.MakeReadOnly() method was designed to be trim-safe and will therefore throw an exception in cases where the options instance hasn't been configured with a resolver.

Calling the new overload with

options.MakeReadOnly(populateMissingResolver: true);

will populate the options instance with the default reflection resolver if one is missing. This emulates the initialisation logic employed by the JsonSerializer methods that accept JsonSerializerOptions. A side-effect of that behavior is that the new overload is marked RequiresUnreferenceCode/RequiresDynamicCode and is therefore unsuitable for Native AOT applications.

@baronfel
Copy link
Member

baronfel commented Sep 7, 2023

SDK: Container publishing now supports Azure Managed Identity

The SDK Container publish feature is an easy way to package .NET applications into containers and push them to container registries like Docker Hub, Azure Container Registry, or other popular registries. Pushing to these remote registries often requires authentication, which is usually handled by the docker login command. Some registries, like Azure Container Registry, don't use a standard username/password setup and instead rely on an OAuth token exchange. The SDK Container publishing tools didn't know how to handle this token exchange, and so users that used Managed Identity on Azure Container Registry (or used any other registry that used Identity Token exchange) would encounter authentication errors when pushing their containers. With .NET 8.0.100 RC1 we're happy to announce that we now support the OAuth token exchange authentication method, so ACR and all other registries that use it now just work. A typical publishing flow might now look like:

> az acr login -n <your registry name>
> dotnet publish -r linux-x64 -p PublishProfile=DefaultContainer

Doesn't get much simpler than that! You can learn more about registry authentication in our docs, and you learn how to get started containerizing your apps as well.

@gewarren
Copy link
Contributor

gewarren commented Sep 7, 2023

@layomia Do you want this published as a breaking change article?

@fanyang-mono
Copy link
Member

fanyang-mono commented Sep 7, 2023

AndroidStripILAfterAOT mode on Android

dotnet/android#8172

We try to choose the best the default configuration for .NET and .NET MAUI applications out of the box. In .NET 6 and higher, specifically, these applications now utilize profiled ahead-of-time (AOT) compilation mode by default when they are built in Release mode. AOT compilation results in faster startup time and runtime performance improvements at the expense of a larger app size. Profiled AOT, only AOT compiles a portion of your application's startup path -- improving startup time, with a minimal increase to application size. The new AndroidStripILAfterAOT setting removes unused IL that was AOT-compiled, reducing the apk size by at least 0 - 3.5% for a dotnet template application.

When to consider using AndroidStripILAfterAOT:

If performance is more of a concern for your Android application than app size, AOT-compiling all code is a great way to achieve the best startup and runtime performance. $(AndroidStripILAfterAOT) goes a step further to remove the unused IL, making the app size increase from AOT-compilation more reasonable. The removed IL will also no longer be present, making it more difficult (but not impossible) to reverse engineer your application's .NET code.

How to use AndroidStripILAfterAOT:

Set the following MsBuild property for your Android app:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AndroidStripILAfterAOT>true</AndroidStripILAfterAOT>
</PropertyGroup>

By default setting AndroidStripILAfterAOT to true will override the default AndroidEnableProfiledAot setting, allowing all trimmable AOT'd methods to be removed. Profiled AOT and IL stripping can be used together by explicitly setting both:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AndroidStripILAfterAOT>true</AndroidStripILAfterAOT>
  <AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
</PropertyGroup>

.apk size results for a dotnet new android app:

$(AndroidStripILAfterAOT) $(AndroidEnableProfiledAot) .apk size
true true 7.7MB
false true 7.7MB
true false 8.1MB
false false 8.4MB

Note that $(AndroidStripILAfterAOT)=false and $(AndroidEnableProfiledAot)=true is the default Release configuration environment, for 7.7MB.

Limitations:

Not all of the AOT-compiled methods are able to be removed. At runtime, there are various scenarios where we have to switch from AOT to JIT to produce the correct result. With that said, we will be continuously working on reducing gaps in the upcoming .NET 9 release.

Final note

We would like to invite everyone to try out this new feature and file any discovered issues to help us improve the user experience further. Issues can be filed directly to dotnet/runtime repository.

@Kuldeep-MS
Copy link
Member

WPF : Hardware Acceleration in RDP

dotnet/wpf#7684

In the past, all WPF applications accessed remotely had to use software rendering, even if the system had hardware rendering capabilities. We have added a new option that enables application developers to opt-in for hardware acceleration for RDP by utilizing an AppContext switch.

Hardware acceleration refers to the use of a computer's graphics processing unit (GPU) to speed up the rendering of graphics and visual effects in an application. This can result in improved performance and more seamless, responsive graphics. In contrast, software rendering relies solely on the computer's central processing unit (CPU) to render graphics, which can be slower and less effective.

How to enable Hardware Acceleration in RDP for WPF app?

We offer two methods for enabling hardware acceleration in RDP:

  1. By adding the RuntimeHostConfigurationOption in the *.csproj file, as demonstrated below:
<ItemGroup>
      <RuntimeHostConfigurationOption Include="Switch.System.Windows.Media.EnableHardwareAccelerationInRdp" Value="true" />
</ItemGroup>
  1. By adding the configProperty in the *.runtimeconfig.json file, as shown below:
"configProperties": {
    "Switch.System.Windows.Media.EnableHardwareAccelerationInRdp": true
  } 

Final note

We would like to invite everyone to try out this new feature and file any discovered issues to help us improve the user experience further. Issues can be filed directly to dotnet/wpf repository.

@JonDouglas JonDouglas self-assigned this Sep 8, 2023
@danroth27
Copy link
Member

WasmStripILAfterAOT mode on WASM

@lewing I'm going to add this one in the ASP.NET Core blog post as well as it is relevant to Blazor WebAssembly users.

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